Donald Trump blames Mexico and China for stealing millions of jobs from the United States. He might want to bash the robots instead. America has lost more than seven million factory jobs since manufacturing employment peaked in 1979. Yet American factory production, minus raw materials and some other costs, more than doubled over the same span to $1.91 trillion last year, according to the Commerce Department, which uses 2009 dollars to adjust for inflation. That’s a notch below the record set on the eve of the Great Recession in 2007. And it makes U.S. manufacturers No. 2 in the world behind China. Trump and other critics are right that trade has claimed some American factory jobs, especially after China joined the World Trade Organization in 2001 and gained easier access to the U.S. market. And industries that have relied heavily on labor — like textile and furniture manufacturing — have lost jobs and production to low-wage foreign competition. U.S. textile production, for instance, is down 46 percent since 2000. And over that time, the textile industry has shed 366,000, or 62 percent, of its jobs in the United States. But research shows that the automation of U.S. factories is a much bigger factor than foreign trade in the loss of factory jobs. A study at Ball State University’s Center for Business and Economic Research last year found that trade accounted for just 13 percent of America’s lost factory jobs. The vast majority of the lost jobs — 88 percent — were taken by robots and other homegrown factors that reduce factories’ need for human labor.