2 Replies Latest reply on Sep 15, 2015 4:29 AM by Ivana Kolin

    How to open a child in an assembly

    Willie Roelofs

      Hi,

       

      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
          Next
      End If

       

      End Sub