I am trying to write/ download and use a macro that will save the current view of each of my part configurations as a DXF file. My part is just a sketch (no solids) with text that changes dynamically in each configuration based on a design table. These are for data plate etching, and there could be up to hundreds of configurations. Obviously in my example, there are only 3. I can manually save each configuration as a DXF and select current view but this will take forever with larger files so I think a macro is appropriate. I tried the following macro I found
Sub main()
Set swApp = Application.SldWorks
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
sModelName = swModel.GetPathName
sPathName = swModel.GetPathName
vConfNameArr = swModel.GetConfigurationNames
For i = 0 To UBound(vConfNameArr)
sConfigName = vConfNameArr(i)
bRebuild = swModel.ForceRebuild3(False)
sPathName = Left(swModel.GetPathName, Len(swModel.GetPathName) - 7)
sPathName = sPathName & ".dxf"
Debug.Print "" & sPathName
Set swPart = swModel
dataAlignment(0) = 0#
dataAlignment(1) = 0#
dataAlignment(2) = 0#
dataAlignment(3) = 0#
dataAlignment(4) = 0#
dataAlignment(5) = 0#
dataAlignment(6) = 0#
dataAlignment(7) = 0#
dataAlignment(8) = 0#
dataAlignment(9) = 0#
dataAlignment(10) = 0#
dataAlignment(11) = 0#
varAlignment = dataAlignment
dataViews(0) = ""
varViews = dataViews
swPart.ExportToDWG sPathName, sModelName, 3, False, varAlignment, False, False, 0, varViews
Next i
Set swApp = Application.SldWorks
End Sub
but it is not executing correctly it seems, it give me an error that says perhaps the macro was not played in the correct context. I think I will also need to rebuild each configuration before saving DXF's in this macro as well. Any help would be greatly appreciated.