Hello.
I am running a macro to make DXF from part. It works, but the problem is with bend lines. Sometimes they are Continuous Line, sometimes they are Hidden. I want to use a Map File for the Bend lines (Up Bend - Centerline, Down Bend - Hidden Lines).
Maybe someone can help me add a syntax to code, to get this result? I am thinking maybe there is a way to attach the Map File to the Macro?
Current code export bend lines one type (no control):
This is result when used with Map File:
Can Map File be attached to the code somehow? Or maybe Bend Lines can be described through the code?
There are some times when I get the bend lines on drawing, but they don't show in the Flat Pattern ..
' ***********
Enum SheetMetalOptions_e
ExportFlatPatternGeometry = 1
IncludeHiddenEdges = 2
ExportBendLines = 4
IncludeSketches = 8
MergeCoplanarFaces = 16
ExportLibraryFeatures = 32
ExportFormingTools = 64
ExportBoundingBox = 2048
End Enum
Dim swApp As SldWorks.SldWorks
Sub main()
Set swApp = Application.SldWorks
Dim swPart As SldWorks.PartDoc
Set swPart = swApp.ActiveDoc
Dim modelPath As String
Dim OUT_PATH As String
'modelPath = swPart.GetPathName
'OUT_PATH = Left(modelPath, InStrRev(modelPath, ".")) & "DXF"
'Custom
Dim swCustProp As CustomPropertyManager
Dim val As String
Dim ValOut As String
Dim bool As String
Set swCustProp = swPart.Extension.CustomPropertyManager("")
bool = swCustProp.Get4("Material", False, val, ValOut) 'custom parameter
' Config
Dim config1 As SldWorks.Configuration
Dim cusPropMgr As SldWorks.CustomPropertyManager
Set config1 = swPart.GetActiveConfiguration
Set cusPropMgr = config1.CustomPropertyManager
Dim ValOut2 As String
Dim ResolvedValOut2 As String
Dim ValOut3 As String
Dim ResolvedValOut3 As String
Dim wasResolved As Boolean
Dim linkToProp As Boolean
lRetVal = cusPropMgr.Get5("Storis", True, ValOut2, ResolvedValOut2, wasResolved) ' Solidworks 2019 Get6
lRetVal = cusPropMgr.Get5("Kiekis", True, ValOut3, ResolvedValOut3, wasResolved) ' Solidworks 2019 lRetVal = cusPropMgr.Get6("Kiekis", True, ValOut3, ResolvedValOut3, wasResolved, linkToProp)
'lRetVal = cusPropMgr.Get5("Storis", True, ValOut, ResolvedValOut, wasResolved) 'Get6 for Solidworks 2019, Get5 for Solidworks 2017
modelPath = swPart.GetPathName
'MD01 = Left(modelPath, InStrRev(modelPath, ".") - 4) ' remove text from end
'-start from here the naming
Dim FileName As String
OUT_PATH = Left(swPart.GetPathName, InStrRev(swPart.GetPathName, "\"))
FileName = Mid(swPart.GetPathName, InStrRev(swPart.GetPathName, "\") + 1)
FileName = Left(FileName, InStrRev(FileName, ".") - 1)
OUT_PATH = OUT_PATH & "S-" & ResolvedValOut2 & " " & FileName & " " & ValOut & " " & ResolvedValOut3 & "vnt" & ".dxf"
'OUT_PATH = OUT_PATH & "S-" & ValOut2 & " " & FileName & " " & ValOut & " " & ValOut3 & "vnt" & ".dxf"
'OUT_PATH = MD01 & " S-" & valout3 & " " & valout2 & " " & valout & "vnt" & ".DXF"
If modelPath = "" Then
Err.Raise vbError, "", "Part document must be saved"
End If
If False = swPart.ExportToDWG2(OUT_PATH, modelPath, swExportToDWG_e.swExportToDWG_ExportSheetMetal, True, Empty, False, False, SheetMetalOptions_e.ExportFlatPatternGeometry + SheetMetalOptions_e.ExportBendLines, Empty) Then
Err.Raise vbError, "", "Failed to export flat pattern"
End If
End Sub
SolidworksDrawings And Detailing