Quick question, is it possible to fix all the parts and assemblies and sub-assemblies simply after opening a step, for the 1st level no worries but then you have to deploy and open to fix. There must surely be something but I can't find it.
Option Explicit
Dim swApp As SldWorks.SldWorks
Sub main()
Dim swModel As ModelDoc2
Dim swAssy As AssemblyDoc
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swAssy = swModel
TransverseComponents swAssy
swApp.SendMsgToUser "Terminé" & Chr(10) & ":-)"
swAssy.ForceRebuild2 (True)
End Sub
Sub TransverseComponents(swAssy As AssemblyDoc)
Dim vComponents As Variant
Dim i As Integer
Dim swComponent As Component2
Dim swModel As ModelDoc2
Dim swAssembly As AssemblyDoc
vComponents = swAssy.GetComponents(True)
For i = 0 To UBound(vComponents)
Set swComponent = vComponents(i)
Set swModel = swComponent.GetModelDoc2
Debug.Print swComponent.Name2
swComponent.Select4 False, Nothing, False
swAssy.FixComponent
If Not swModel Is Nothing Then
If swModel.GetType = swDocASSEMBLY Then
Set swAssembly = swModel
TransverseComponents swAssembly
End If
End If
Next i
End Sub
@stefbeno, during my first uses I hadn't paid attention but after running it two or three times the PRT was fixed. Maybe a small bug due to the new versions because I'm in 2020. Maybe see with @remremif he has also noticed this bug?