2 Replies Latest reply on Feb 12, 2015 11:46 AM by John Stoltzfus

    Extract component configuration name

    Mike Campbell

      I have a need to programmatically identify the name of the component configuration in use in an assembly. I've spent a day or so without any success and I'm hoping someone will be willing to give me an example.

        • Re: Extract component configuration name
          Keith Rice

          Mike,

           

          1. If you want to get a list of every component's in-use config, you need only use the macro called "Run code on every part in assembly" I have on my Macros page. (requires free membership)  You will see where it provides sample code that prints config names and also custom properties. If you don't need the latter, just remove that code.

           

          2. If you want to preselect a component, run the macro, and be told what config is in use, you can do that like this:

           

          Dim swApp As SldWorks.SldWorks
          Dim swModel As SldWorks.ModelDoc2
          Dim swSelMgr As SldWorks.SelectionMgr
          Dim swComp As SldWorks.Component2
          
          Sub main()
              Set swApp = Application.SldWorks
              Set swModel = swApp.ActiveDoc
              Set swSelMgr = swModel.SelectionManager
              Set swComp = swSelMgr.GetSelectedObject6(1, -1)
              
              Debug.Print swComp.ReferencedConfiguration
          End Sub
          

           

          Keith

          SolidWorks API Training