neshom
Mechanical
- Feb 7, 2016
- 43
I'd like to export only the selected part (in an assembly) as STL, but my code exports all of the parts as stl. Do you know how I can achieve this?
My code:
My code:
Code:
ModelDoc2 swModel = (ModelDoc2)swApp.ActiveDoc;
SelectionMgr swSelectionMgr = (SelectionMgr)swModel.SelectionManager;
int intSelectedObjectCount = swSelectionMgr.GetSelectedObjectCount2(-1);
Component2 swComponent = (Component2)swSelectionMgr.GetSelectedObjectsComponent4(1, -1);
swModel = (ModelDoc2)swComponent.GetModelDoc();
int intError = 0;
int intWarning = 0;
swApp.SetUserPreferenceDoubleValue((int)swUserPreferenceDoubleValue_e.swSTLAngleTolerance, 2.0);
swModel.Extension.SetUserPreferenceString((int)swUserPreferenceStringValue_e.swFileSaveAsCoordinateSystem, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, null);
bool boolstatus = swModel.Extension.SaveAs(swModel.GetPathName()+".stl", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref intError, ref intWarning);