Hi guys. First time working with macros on Solid.
My problem is the following:
I have to update sheet metal parts when they are changed. I have to save the part as dxf (or export), Change the folder to the respective thickness, and that´s all.
I have a macro working, but it dont separate by the thickness of the part.
What i need is, this exact same macro, but when exporting the DXF, i saves on the folder named by the thickness (or material).
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'swModel.Save
Path = "D:\Engenharia\Desktop\Temp\Sheetmetal" ' Change the path here
sModelName = swModel.GetPathName
If sModelName = "" Then
MsgBox "File is not Saved Yet. You have to Save the file First."
End
End If
sPathName = Mid(swModel.GetPathName, InStrRev(swModel.GetPathName, "\") + 1)
sPathName = Left(sPathName, InStrRev(sPathName, ".") - 1)
'sPathName = Path + sPathName + ".DXF"
sPathName = Path + "\1.DXF"
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
' *******************************************************************************************
' The bitmask for SheetMetalOptions is {12 11 10 9 8 7 6 5 4 3 2 1}, where each bit is either 0 or 1 as follows:
' https://forum.solidworks.com/thread/93981
' Bit #1: 1 to export flat-pattern geometry; 0 to not
' Bit #2: 1 to include hidden edges; 0 to not
' Bit #3: 1 to export bend lines; 0 to not
' Bit #4: 1 to include sketches; 0 to not
' Bit #5: 1 to merge coplanar faces; 0 to not
' Bit #6: 1 to export library features; 0 to not
' Bit #7: 1 to export forming tools; 0 to not
' Bit #8: 0
' Bit #9: 0
' Bit #10: 0
' Bit #11: 0
' Bit #12: 1 to export bounding box; 0 to not
' For example, if you want to export:
' flat-pattern geometry, bend lines, and features, then Bits 1, 3, and 6 are 1, the bitmask is :
' Fill th binary from right starting with 0 column
' 11 10 9 8 7 6 5 4 3 2 1 0 -> Binary Nomber column, filling from right
' 0 0 0 0 1 0 1 0 0 1 0 1 -> 000000001101
' 2^7 2^5 2^2 2^0
' and you need to set SheetMetalOptions = (2^0) + (2^2) + (2^5) + (2^7) = 1 + 4 + 32 + 128= 165
' *******************************************************************************************
options = 101 ' This value determines what would be exported in the DXF/DWG file.
swPart.ExportToDWG2 sPathName, sModelName, swExportToDWG_ExportSheetMetal, True, varAlignment, False, False, options, Null
End Sub
SolidworksApi/macros