I am facing a couple of parts with >100 bodies. I want to save these bodies as part and make an assembly with the "Save Bodies" feature.
Before this, I'd like to rename all bodies so they have a unique name. I'm looking to do this with a macro.
I now have this: but the renaming part is not working...
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swPart As SldWorks.PartDoc
Dim vBodyArr As Variant
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swPart = swModel
vBodyArr = swPart.GetBodies2(0, False)
RenameBodies swModel, vBodyArr
Sub RenameBodies(swModel As SldWorks.ModelDoc2, vBodyArr As Variant)
Dim swBody As SldWorks.Body2
Dim prefixName As String
Dim bodycount As Integer
bodycount = 1
If IsEmpty(vBodyArr) Then Exit Sub
prefixName = "Projectnumber"
For Each vBody In vBodyArr
vBody.Name = prefixName + bodycount '<-- error is here....
bodycount = bodycount + 1
Any tips on how to rename the bodies?
Thanks in advance!