SolidWorks二次开发—特定坐标系输出

SolidWorks二次开发—特定坐标系输出

这个功能比较简单,我就直接上代码了。


       private void btnOutWithCoordSystem_Click(object sender, EventArgs e)
        {
            SldWorks swApp = Utility.ConnectToSolidWorks();

            ModelDoc2 swModel = (ModelDoc2)swApp.ActiveDoc;

            //设置用来导出文件的坐标系名称(需要装配体中有这个名称的坐标系)
            var setRes = swModel.Extension.SetUserPreferenceString(16, 0, "Coordinate System1");

            //设置导出版本

            int error = 0;

            int warnings = 0;
            //x_t的版本设置
            //swApp.SetUserPreferenceIntegerValue((int)swUserPreferenceIntegerValue_e.swParasolidOutputVersion, (int)swParasolidOutputVersion_e.swParasolidOutputVersion_161);

            swModel.Extension.SaveAs(@"D:\export.igs", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref error, ref warnings);
            swModel.Extension.SaveAs(@"D:\export.x_t", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref error, ref warnings);
            //Mark:SolidWorks 2018版本导出 step 用坐标系导出有bug!!! x_t igs没有问题
            //swModel.Extension.SaveAs(@"D:\export.step", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref error, ref warnings);

            MessageBox.Show("输出成功");
        }

导出完成后用Solidworks打开。

去掉这个选项,检查一下:

posted @
2021-05-10 09:48 
painezeng  阅读(
0)  评论(
0
编辑 
收藏 
举报  
来源