When I run my macro in a batch process it does not work but it does if I use it in the part file directly. I am using a SolidWorks add-in that my company develops but I was wondering if it was part of the code that is having issues when using in a batch process.
batch process
When I run the macro directly in the on the part by individually opening it:
code:
Dim dicFeatsCount As Object
Dim dicBaseNames As Object
Sub main()
Set dicFeatsCount = CreateObject("Scripting.Dictionary")
Set dicBaseNames = CreateObject("Scripting.Dictionary")
'Add the list of predefined base names
'- - - - - - - - - - - - - - - - - - - -
dicBaseNames.Add "ProfileFeature", "Sketch"
dicBaseNames.Add "Extrusion", "Extrude"
dicBaseNames.Add "RefPlane", "Plane"
'- - - - - - - - - - - - - - - - - - - -
Set swApp = Application.SldWorks
Set swAssm = swApp.ActiveDoc
Set swFeat = swAssm.FirstFeature
While Not swFeat Is Nothing
If dicFeatsCount.exists(swFeat.GetTypeName2()) Then
dicFeatsCount.Item(swFeat.GetTypeName2()) = dicFeatsCount.Item(swFeat.GetTypeName2()) + 1
Else
dicFeatsCount.Add swFeat.GetTypeName2(), 1
End If
If dicBaseNames.exists(swFeat.GetTypeName2()) Then
newName = dicBaseNames.Item(swFeat.GetTypeName2())
Else
newName = swFeat.GetTypeName2()
End If
newName = newName & dicFeatsCount.Item(swFeat.GetTypeName2())
swFeat.Name = newName
Set swFeat = swFeat.GetNextFeature
Wend
End Sub
