AnsweredAssumed Answered

How to open a child in an assembly

Question asked by Willie Roelofs on Sep 15, 2015
Latest reply on Sep 15, 2015 by Ivana Kolin



I'm editing the following macro:


API: Remove Materials from all parts in an assembly


Instead of removing materials. I want to:

- Open a child (both SLDPRT and SLDASM).

- Save the child with a new name in a new path. The newly saved part has to replace the old one in the assembly.

- Close the child.

- Set the main assembly active.


I'm having a hard time opening the child.


I've only edited the last lines:


                ' Get the component's model document
                Set componentModel = childComponent.GetModelDoc2
                ' Get the path to the model
                Set model = swApp.OpenDoc6(componentModel.GetPathName, componentModel.GetType, 0, "", longstatus, longwarnings)
                model.SaveAs FilePath
                ' Sub-Assembly. Recurse into the sub-assembly.
                If componentModel.GetType = swDocASSEMBLY Then RemoveMaterialFromChildren childComponent, processedComponents
            End If
        End If
End If


End Sub