Hello
I started to write a macro with small pieces found here and there on the net.
The idea is to rename (3D files + feature manager) all components whose property " SWOODCP_PanelStockLength " is different from "".
I can't get the parts to be renamed in the assembly and in the windows explorer.
I'm attaching the beginning of my code if you could help me.
Thanks in advance
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swRootComp As SldWorks.Component2
Dim Children As Variant
Dim swChild As SldWorks.Component2
Dim SwSelData As SldWorks.SelectData
Dim ChildCount As Long
Dim oldName As String
Dim newName As String
Sun i As Long
Sun j As Long
Dim ParentName As String
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swRootComp = swModel.ConfigurationManager.ActiveConfiguration.GetRootComponent3(True)
Children = swRootComp.GetChildren
ChildCount = UBound(Children)
Set SwSelData = swModel.SelectionManager.CreateSelectData
For i = 0 To ChildCount
j = 1
Set swChild = Children(i)
swChild.Select4 False, SwSelData, False
ParentName = Left(swModel.GetTitle, 7)
newName = ParentName & "-" & "000" & j
swModel.Extension.RenameDocument newName
j = d + 1
Next i
swModel.ForceRebuild3 True
End Sub
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swRootComp As SldWorks.Component2
Dim Children As Variant
Dim swChild As SldWorks.Component2
Dim SwSelData As SldWorks.SelectData
Dim ChildCount As Long
Dim oldName As String
Dim newName As String
Sun i As Long
Sun j As Long
Dim ParentName As String
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swRootComp = swModel.ConfigurationManager.ActiveConfiguration.GetRootComponent3(True)
Children = swRootComp.GetChildren
ChildCount = UBound(Children)
Set SwSelData = swModel.SelectionManager.CreateSelectData
For i = 0 To ChildCount
j = 1
Set swChild = Children(i)
swChild.Select4 False, SwSelData, False
ParentName = Left(swModel.GetTitle, 7)
newName = ParentName & "-" & "000" & j
swModel.Extension.RenameDocument newName
j = d + 1
Next i
swModel.ForceRebuild3 True
End Sub