MathPt = mathPt.MultiplyTransform(transform) as IMathPoint ĭouble pt = mathPt. IMathVector mathVec = mathUtils.CreateVector( Uint triangsCount = ( uint)tessTriangs.Length / 9 Using (BinaryWriter writer = new BinaryWriter(fileStream)) Using (FileStream fileStream = File.Create(filePath)) IMathTransform transform = (mathUtils.CreateTransform(transformMatrix) as IMathTransform).IInverse() IMathUtility mathUtils = swApp.IGetMathUtility() Private void ExportToStl( string filePath, float tessTriangs, float tessNorms, double transformMatrix) TessNorms = part.GetTessNorms() as float TessTriangs = part.GetTessTriangles( true) as float Private void GetTesselationDataFromPart(IPartDoc part, out float tessTriangs, out float tessNorms) GetTesselationDataFromPart(compModel as IPartDoc, out tessTriangs, out tessNorms) Throw new NotSupportedException( "Only parts are supported") TessNorms = comp.GetTessNorms() as float TessTriangs = comp.GetTessTriangles( true) as float If (Path.GetExtension(comp.GetPathName()).Equals( ".sldprt", StringComparison.CurrentCultureIgnoreCase)) IModelDoc2 compModel = comp.IGetModelDoc() Private void GetTesselationData(IComponent2 comp, out float tessTriangs, out float tessNorms) SwApp.SendMsgToUser2(ex.Message, ( int)swMessageBoxIcon_e.swMbStop, ( int)swMessageBoxBtn_e.swMbOk) Throw new NullReferenceException( "Please open part or assembly") String filePath = BrowseFile(Path.GetFileNameWithoutExtension(fileNameBase)) ĮxportToStl(filePath, tessTriangs, tessNorms, m_Transform) Throw new NotSupportedException( "Document type is not support, parts or assembly components are supported") Throw new NullReferenceException( "Please select component") GetTesselationData(comp, out tessTriangs, out tessNorms) IComponent2 comp = 3( 1, - 1) as IComponent2
![solidworks step to stl conversion solidworks step to stl conversion](https://static.listoffreeware.com/wp-content/uploads/autodesk123D_design_stp_to_stl_converter_2019-04-21_16-57-07.png)
GetTesselationDataFromPart(model as IPartDoc, out tessTriangs, out tessNorms)
![solidworks step to stl conversion solidworks step to stl conversion](https://jandra.files.wordpress.com/2019/09/maxresdefault.jpg)
Use the Get Coordinate System Transform macro to retrieve the transformation from any selected coordinate system.įor example to set the 90 degrees rotation around X axis in clockwise direction it is required to change the values of the m_Transform array to the ones below: In order to configure the orientation of the output file it is required to change the values of 4x4 orientation matrix defined in the m_Transform at the beginning of the macro.
![solidworks step to stl conversion solidworks step to stl conversion](https://www.datakit.com/upload/actu/schema-conversion-smg-crossmanager.png)
It is not required to create a coordinate system for this to happen.įor more information about the STL specification follow this link. Macro can optionally apply the transform to rotate or move the STL file. Simply importing the STL file into SOLIDWORKS and saving as a SLDPRT file give: 49,324 model faces. Macro will create stl from the tessellation triangles of the model. IModelDocExtension::SaveAs SOLIDWORKS API function is not used. This macro is not using the default exporter and overcomes the limitation when the model needs to be loaded in its own window, i.e. Macro will also work with the components loaded lightweight. This C# VSTA macro exports active part or selected component in assembly to STL format using SOLIDWORKS API.