2 Replies Latest reply on Feb 2, 2017 6:57 PM by Yong Ning

    select many dimension

    Yong Ning

      Private Sub ll2()

         Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

             Set SwApp = Application.SldWorks

             Set SwModel = SwApp.ActiveDoc

         Dim SwSelMgr As SelectionMgr, Str

             Set SwSelMgr = SwModel.SelectionManager

            

         Dim SwDim As Dimension, SwDispDim As DisplayDimension

            

             ''

             For ii = 1 To 20

                 Set SwDispDim = SwSelMgr.GetSelectedObject5(ii)

                 If Not SwDispDim Is Nothing Then

                     Set SwDim = SwDispDim.GetDimension

                     Str = SwDim.FullName

                     Str = Left(Str, InStrRev(Str, "@") - 1)

                    

                     SwDim.Name = "DrwDim" & Str

                 End If

             Next ii

            

      End Sub

        • Re: select many dimension
          Deepak Gupta

          So what is your issue?

            • Re: select many dimension
              Yong Ning

              Learning notes。

              How to use .GetSelectedObject5(ii)

              Follow code is

               

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

               

               

              Private Sub ll2()

                 ''

                 Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                     Set SwApp = Application.SldWorks

                     Set SwModel = SwApp.ActiveDoc

                 Dim SwDraw As DrawingDoc

                     Set SwDraw = SwModel

                 Dim SwView As View

                     Set SwView = SwDraw.GetFirstView

                     Set SwView = SwView.GetNextView

                 Dim SwSelMgr As SelectionMgr, Str1, Str2, Row

                     Row = 0

                     Set SwSelMgr = SwModel.SelectionManager

                 Dim SwDim As Dimension, SwDispDim As DisplayDimension

                 Dim Arr(), Str

                     ''

                     For ii = 1 To 20

                         Set SwDispDim = SwSelMgr.GetSelectedObject5(ii)

                         If Not SwDispDim Is Nothing Then

                             Set SwDim = SwDispDim.GetDimension

                             SwDim.Name = Replace(SwDim.Name, "DrwDim", "")

                         ReDim Preserve Arr(1, Row)

                             Str = SwDim.FullName

                             Arr(0, Row) = Left(Str, InStrRev(Str, "@") - 1)

                            

                             SwDim.Name = "DrwDim" & SwDim.Name

                             Str = SwDim.FullName

                             Arr(1, Row) = Left(Str, InStrRev(Str, "@") - 1)

                             Row = Row + 1

                         End If

                     Next ii

                     ''

                     Set SwModel = SwView.ReferencedDocument

                 Dim SwEqnMgr As EquationMgr

                     Set SwEqnMgr = SwModel.GetEquationMgr

                     With SwEqnMgr

                        ''

                        For ii = 0 To .GetCount

                            For jj = 0 To UBound(Arr, 2)

                                .Equation(ii) = Replace(.Equation(ii), Arr(0, jj), Arr(1, jj))

                            Next jj

                            'Stop

                            Debug.Print "  ***********  "

                        Next ii

                     End With

              End Sub