Professional Documents
Culture Documents
Solidworks Macro (Rename and Save Bodies)
Solidworks Macro (Rename and Save Bodies)
swCutListTransferOptions_e.swCutListTransferOptions_FileProperties
Const OUT_DIR As String = ""
Option Explicit
Dim swApp As Object
Dim modelName As String
Dim MainPart As Object
Dim swPart As SldWorks.PartDoc
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
try_:
On Error GoTo catch_
Dim i As Integer
For i = 0 To UBound(vCutLists)
ProcessCutLists swCutListFeat
Next
Else
MsgBox "Please open the document"
End If
GoTo finally_
catch_:
swApp.SendMsgToUser2 Err.Description, swMessageBoxIcon_e.swMbStop,
swMessageBoxBtn_e.swMbOk
finally_:
If IsEmpty(vBodies) Then
vBodies = swPart.GetBodies2(swBodyType_e.swSolidBody, True)
End If
Dim j As Integer
For j = 0 To UBound(vBodies)
Else
Err.Raise vbError, "", "Failed to select body " & swBody.name
End If
Next
End Sub
Dim i As Integer
For i = 1 To selMgr.GetSelectedObjectCount2(-1)
End If
Next
If isInit Then
GetSelectedBodies = swBodies
Else
GetSelectedBodies = Empty
End If
End Function
End Function
Dim i As Integer
For i = 0 To UBound(vArr)
If vArr(i) Is item Then
Contains = True
Exit Function
End If
Next
Contains = False
End Function
End Function
Dim i As Integer
For i = 0 To UBound(invalidSymbols)
Dim invalidSymb As String
invalidSymb = CStr(invalidSymbols(i))
res = Replace(res, invalidSymb, REPLACE_SYMB)
Next
End Function
End Function
Loop
End Function
For i = 0 To UBound(featsArr)
If swApp.IsSame(featsArr(i), thisFeat) =
swObjectEquality.swObjectSame Then
Exit Sub
End If
Next
End If
End Sub
End If
End Function
Dim i As Integer
Dim check As Integer
check = 1
For i = 0 To UBound(bodies)
Dim swBody As SldWorks.Body2
Set swBody = bodies(i)
swBody.name = bodyName & "-" & i + 1
Do While check = 1
boolstatus = swPart.Extension.SelectByID2(bodyName & "-" & i + 1,
"SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)
swBody.name = bodyName
check = 0
Loop
Next
End If
End Function