2 Replies Latest reply on Mar 29, 2016 2:36 AM by Yong Ning

    How to determine the number of multiple dimension ?

    Yong Ning

      Select Many Dimension

      a.jpg

       

       

      Follow code → Choose several dimension line。

      Question is see follow picture

       

       

      a1.jpg

       

       

      Help me. How to determine the number of multiple dimension ?

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

      Private Sub ll()

         Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

             Set SwApp = Application.SldWorks

             Set SwModel = SwApp.ActiveDoc

         Dim SwSelMgr As SelectionMgr

             Set SwSelMgr = SwModel.SelectionManager

         Dim SwDispDim As DisplayDimension, SwDim As Dimension

             Set SwDispDim = SwSelMgr.GetSelectedObject5(1)

             Set SwDim = SwDispDim.GetDimension

             Debug.Print SwDim.Name, SwDim.FullName

             Set SwDispDim = SwSelMgr.GetSelectedObject5(2)

             Set SwDim = SwDispDim.GetDimension

             Debug.Print SwDim.Name, SwDim.FullName

             Set SwDispDim = SwSelMgr.GetSelectedObject5(3)

           

             Set SwDispDim = SwSelMgr.GetSelectedObject5(4)

             Set SwDim = SwDispDim.GetDimension

             Debug.Print SwDim.Name, SwDim.FullName

             Stop

           

             Stop

      End Sub

       

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

        • Re: How to determine the number of multiple dimension ?
          Artem Taturevych

          Use SelectionMgr::GetSelectedObjectCount2 to get the number of all selected objects and than just ignore the ones which are not dimensions (SelectionMgr::GetSelectedObjectType3 is not swSelDIMENSIONS)

            • Re: How to determine the number of multiple dimension ?
              Yong Ning

              Thanks you tip.

              code is

              Private Sub ll1()

                 Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                     Set SwApp = Application.SldWorks

                     Set SwModel = SwApp.ActiveDoc

                 Dim SwSelMgr As SelectionMgr, Count

                     Set SwSelMgr = SwModel.SelectionManager

                     Count = SwSelMgr.GetSelectedObjectCount2(-1)

                 Dim SwDispDim As DisplayDimension, SwDim As Dimension

                     For ii = 1 To Count

                         Set SwDispDim = SwSelMgr.GetSelectedObject5(ii)

                         Set SwDim = SwDispDim.GetDimension

                         Debug.Print SwDim.FullName

                     Next ii

                   

              End Sub