Hi People.
I recorded a macro to extract multiple layers (using surface cut) in a drawing and the export each layer to a DXF format (using the Faces/Loops option on the surface).
It seems to run but I do not get any files saved. I am attaching the macro herewith.
Any tips !
Thanks a lot !
=================================================================
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = _
Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Cut", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("", "FACE", 0, 0, 0.006, True, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("", "FACE", 0, 0, 0.006, True, 0, Nothing, 0)
Dim myRefPlane As Object
Set myRefPlane = Part.FeatureManager.InsertRefPlane(264, 0.00025, 0, 0, 0, 0)
boolstatus = Part.Extension.SelectByID2("", "FACE", 0, 0, 0.006, True, 0, Nothing, 0)
Part.ClearSelection2 True
Part.ClearSelection2 True
longstatus = Part.SaveAs3("C:\Users\Data\Surface cut\Microchannels.DXF", 0, 0)
boolstatus = Part.Extension.SelectByID2("", "FACE", -4.30867978686172E-02, 8.6076874028664E-03, 5.74999999997772E-03, True, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Cut", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("", "FACE", 0, 0, 0.006, True, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("", "FACE", 0, 0, 0.006, True, 0, Nothing, 0)
Set myRefPlane = Part.FeatureManager.InsertRefPlane(264, 0.00075, 0, 0, 0, 0)
boolstatus = Part.Extension.SelectByID2("", "FACE", 0, 0, 0.006, True, 0, Nothing, 0)
Part.ClearSelection2 True
Part.ClearSelection2 True
longstatus = Part.SaveAs3("C:\Users\Data\Surface cut\Reservoir.DXF", 0, 0)
boolstatus = Part.Extension.SelectByID2("", "FACE", -3.38894648326336E-02, 0.010140576242197, 5.24999999998954E-03, True, 0, Nothing, 0)
End Sub
SolidworksApi macros