AnsweredAssumed Answered

Transversing A Part Within An Assembly & Exporting for Each Assembly Configuration

Question asked by Eric Anderson on Dec 27, 2019
Latest reply on Jan 19, 2020 by Deepak Gupta

Hi, I am struggling to write a macro (little to no Visual Basic experience) to help export a few hundred assembly files with a part file configuration changed for each assembly configuration.

 

I have recorded this macro to show what I am having to do manually:

 

 

 

 

Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("C24 - 29inch SEATED", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.ShowConfiguration2("C24 - 29inch SEATED")
boolstatus = Part.Extension.SelectByID2("Desktop - Rectangular-1@FRMA-2-SRD-C", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)

' Component Configuration (Flyout Menu)
Dim swComp As Component2
Set swComp = Part.SelectionManager.GetSelectedObjectsComponent4(1, -1)
swComp.ReferencedConfiguration = "42x30x1"
boolstatus = Part.EditRebuild3()

' Save As
longstatus = Part.SaveAs3("C:\Users\user\Desktop\FRMA-2-SRD-C-42x30x1.STEP", 0, 0)
boolstatus = Part.Extension.SelectByID2("C24 - 42inch STANDING", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.ShowConfiguration2("C24 - 42inch STANDING")
boolstatus = Part.Extension.SelectByID2("Desktop - Rectangular-1@FRMA-2-SRD-C", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)

' Component Configuration (Flyout Menu)
Set swComp = Part.SelectionManager.GetSelectedObjectsComponent4(1, -1)
swComp.ReferencedConfiguration = "48x30x1"
boolstatus = Part.EditRebuild3()

' Save As
longstatus = Part.SaveAs3("C:\Users\user\Desktop\FRMA-2-SRD-C-48x30x1.STEP", 0, 0)
End Sub

 

 

 

 

 

I believe what I am looking to do is transverse the active assembly "FRMA-2-SRD-C" then transverse the part "Desktop - Rectangular-1" and export all possible combinations as step.

 

 

 

Macros I tried combining: Macro to Export Multiple Configurations 
                                          Need to Change a specific Parts Configuration in an Assembly 

 

 

 

Thanks

Outcomes