不doc.Visible是可以获得厚度的doc.Visible这行注释掉就无法生成cad展开了static private void TraverseComponent(SldWorks swApp,Component2 component) { // 获取子组件 object[] children (object[])component.GetChildren(); if (children ! null children.Length 0) { } else { var doc(ModelDoc2)component.GetModelDoc2(); if (doc ! null) { string? pathName doc.GetPathName(); if (string.IsNullOrEmpty(pathName)) { Console.WriteLine($警告组件 {component.Name2} 未保存或无法获取路径。); return; } string docname pathName.Replace(\, /); if (docnameCount.ContainsKey(docname)) { docnameCount[docname]; } else { docnameCount[docname] 1; var thickness 0.0; string? dxfname null; Profiler.Time(() thickness get_thickness_from_solidfolder.run2(doc), 获取厚度); if (thickness 0) { Profiler.Time(() doc.Visible true, 打开零件); Profiler.Time(() dxfname Exportdxf.run2(doc, thickness.ToString()), 导出DXF); Profiler.Time(() swApp.CloseDoc(doc.GetPathName()), 关闭文档); } } } } }