Bonjour,
j'ai commencé a écrire une macro avec des petits morceaux trouvés par ci et par la sur le net.
L'idée étant de renommer ( fichiers 3D + feature manager ) tous les composants dont la propriété " SWOODCP_PanelStockLength " est différente de "".
Je n'arrive pas a ce que les pièces soient renommées dans l'assemblage et dans l'explorateur windows.
Je vous joint le début de mon code si vous pouviez m'aider.
Merci d'avance
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
Dim i As Long
Dim j As Long
Dim NomParent 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
NomParent = Left(swModel.GetTitle, 7)
newName = NomParent & "-" & "000" & j
swModel.Extension.RenameDocument newName
j = j + 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
Dim i As Long
Dim j As Long
Dim NomParent 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
NomParent = Left(swModel.GetTitle, 7)
newName = NomParent & "-" & "000" & j
swModel.Extension.RenameDocument newName
j = j + 1
Next i
swModel.ForceRebuild3 True
End Sub