SolidWorks Macro to create DXF file from each configuration
'Hi All,
'The Code as follows:
Dim swApp As SldWorks.SldWorks
Dim swmodel As SldWorks.ModelDoc2
Dim swconfig As SldWorks.Configuration
Dim vconfig As Variant
Dim swpart As SldWorks.PartDoc
Dim dataAlignment(11) As Double
Dim varAlignment As Variant
Dim dataViews(0) As String
Sub main()
Set swApp = Application.SldWorks
Set swmodel = swApp.ActiveDoc
Set swpart = swmodel
vconfig = swmodel.GetConfigurationNames
dataAlignment(0) = 0
dataAlignment(1) = 0
dataAlignment(2) = 0
dataAlignment(3) = 1
dataAlignment(4) = 0
dataAlignment(5) = 0
dataAlignment(6) = 0
dataAlignment(7) = 1
dataAlignment(8) = 0
dataAlignment(9) = 0
dataAlignment(10) = 0
dataAlignment(11) = 1
varAlignment = dataAlignment
dataViews(0) = "*Current"
varviews = dataViews
Dim bool As Boolean
Dim fpath As String
fpath = InputBox("Paste the folder location")
For i = 0 To UBound(vconfig)
'swmodel.Extension.ac
swmodel.ShowConfiguration2 (vconfig(i))
bool = swpart.ExportToDWG2(fpath & "\" & vconfig(i) & ".dxf", swmodel.GetPathName, 3, True, varAlignment, False, False, 0, varviews)
Next
End Sub
'The Code as follows:
Dim swApp As SldWorks.SldWorks
Dim swmodel As SldWorks.ModelDoc2
Dim swconfig As SldWorks.Configuration
Dim vconfig As Variant
Dim swpart As SldWorks.PartDoc
Dim dataAlignment(11) As Double
Dim varAlignment As Variant
Dim dataViews(0) As String
Sub main()
Set swApp = Application.SldWorks
Set swmodel = swApp.ActiveDoc
Set swpart = swmodel
vconfig = swmodel.GetConfigurationNames
dataAlignment(0) = 0
dataAlignment(1) = 0
dataAlignment(2) = 0
dataAlignment(3) = 1
dataAlignment(4) = 0
dataAlignment(5) = 0
dataAlignment(6) = 0
dataAlignment(7) = 1
dataAlignment(8) = 0
dataAlignment(9) = 0
dataAlignment(10) = 0
dataAlignment(11) = 1
varAlignment = dataAlignment
dataViews(0) = "*Current"
varviews = dataViews
Dim bool As Boolean
Dim fpath As String
fpath = InputBox("Paste the folder location")
For i = 0 To UBound(vconfig)
'swmodel.Extension.ac
swmodel.ShowConfiguration2 (vconfig(i))
bool = swpart.ExportToDWG2(fpath & "\" & vconfig(i) & ".dxf", swmodel.GetPathName, 3, True, varAlignment, False, False, 0, varviews)
Next
End Sub
'Thanks
Thank you very much. it saves me a lot of time. God bless!
ReplyDeleteThanks .
DeleteThanks! It`s great.
ReplyDeleteThank you, I have been looking all over for exactly this!
ReplyDelete