Hello,
i created a task to directly export the flat pattern to DXF but code not work
Can anybody tell me what's wrong?
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim vConfNameArr As Variant
Dim sConfigName As String
Dim nStart As Single
Dim i As Long
Dim bShowConfig As Boolean
Dim bRebuild As Boolean
Dim bRet As Boolean
Dim CurFeature As SldWorks.Feature
Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
' Is document active?
If swModel Is Nothing Then
swApp.SendMsgToUser2 "A sheet metal part must be open.", swMbWarning, swMbOk
Exit Sub
End If
' Is it a part document?
Dim modelType As Long
modelType = swModel.GetType
If modelType <> SwConst.swDocPART Then
swApp.SendMsgToUser2 "A sheet metal part must be open.", swMbWarning, swMbOk
Exit Sub
End If
vConfNameArr = swModel.GetConfigurationNames
For i = 0 To UBound(vConfNameArr)
sConfigName = vConfNameArr(i)
If Right(sConfigName, 15) = "SM-FLAT-PATTERN" Then
Else
bShowConfig = swModel.ShowConfiguration2(sConfigName)
bRebuild = swModel.ForceRebuild3(False)
Dim FilePath As String
Dim PathSize As Long
Dim PathNoExtension As String
Dim NewFilePath As String
FilePath = swModel.GetPathName
PathSize = Strings.Len(FilePath)
PathNoExtension = Strings.Left(FilePath, PathSize - 6)
NewFilePath = PathNoExtension + sConfigName & ".DXF"
'Export Flat Pattern
bRet = swModel.ExportFlatPatternView(NewFilePath, 1)
End If
Next i
End
End Sub
What is this line doing
If Right(sConfigName, 15) = "SM-FLAT-PATTERN" Then?? You need to define something I guess after Then (sorry but I've limited knowledge with API)
Can you try the codes posted here: https://forum.solidworks.com/message/124033#124033