2 Replies Latest reply on Sep 15, 2014 8:44 AM by Jesse Seger

    How to get the confignuration name in feature tree?

    Yong Ning

      0.jpg

      ****************

      1.jpg

       

      *********************

      follow code → result → Part1-1

      ***********************************

      Help me

      Hope get configuration name p2

      ***********************************

       

       

       

       

      Private Sub llll()

        Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

          Set SwApp = Application.SldWorks

          Set SwModel = SwApp.ActiveDoc

          Debug.Print SwModel.GetTitle

          Set swSelMgr = SwModel.SelectionManager

          Dim SwComp As Component2

          Set SwComp = swSelMgr.GetSelectedObjectsComponent(1)

       

       

          Set swFeat = SwModel.FeatureByName(SwComp.Name2)

          Debug.Print swFeat.Name

          Stop

       

       

      End Sub

        • Re: How to get the confignuration name in feature tree?
          Rushabh Shah

          Hi Yong,

           

          saw your files, hoping to learn something, but these is dangerous coding, especially for a novice like me .

          - sorry, but i dont answer to your problem.

          - but for curiosity, isn't in your assembly file, you need to 'activate configuration' as required ? because from image of assembly, 'p2' configuration is active.

          - also, when running your macro, it gives error of not find project library, see image below.

          ying_1.jpg

           

          - if you have, references of excel, from, TOOLS -> References -> selecting excel type library. Than i suggest that, you add reference programmatically, so as, other people working on your macro doesn't need to add references manually, i am also learning and working on this same concept.

           

          - Also, which Sub to run ? or am i getting this whole thing wrong ??

          ying_2.jpg

          • Re: How to get the confignuration name in feature tree?
            Jesse Seger

            I added a line below to get the referenced config.

             

            Private Sub llll()

              Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                Set SwApp = Application.SldWorks

                Set SwModel = SwApp.ActiveDoc

                Debug.Print SwModel.GetTitle

                Set SwSelMgr = SwModel.SelectionManager

                Dim SwComp As Component2

                Set SwComp = SwSelMgr.GetSelectedObjectsComponent(1)

             

             

                Set SwFeat = SwModel.FeatureByName(SwComp.Name2)

                Debug.Print SwFeat.Name

                '************ Add this line to get referenced config

                Debug.Print SwComp.ReferencedConfiguration

                Stop

             

             

            End Sub

             

            Maybe you want to set the config??  It's hard to tell from your questions, but below is an example of that too.

             

            Private Sub llll()

              Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                Set SwApp = Application.SldWorks

                Set SwModel = SwApp.ActiveDoc

                Debug.Print SwModel.GetTitle

                Set SwSelMgr = SwModel.SelectionManager

                Dim SwComp As Component2

                Set SwComp = SwSelMgr.GetSelectedObjectsComponent(1)

             

             

                Set SwFeat = SwModel.FeatureByName(SwComp.Name2)

                Debug.Print SwFeat.Name

                '************ Add this line to get referenced config

                Debug.Print SwComp.ReferencedConfiguration

               

                '************** Add this if you want to set the config

                SwComp.ReferencedConfiguration = "p2"

                Debug.Print SwComp.ReferencedConfiguration

                Stop

             

             

            End Sub