4 Replies Latest reply on Dec 4, 2016 10:32 AM by Ivana Kolin

    How to select two dimension?

    Yong Ning

              Set SwAnn = SwDispDim.GetAnnotation

              Set SwAnn1 = SwDispDim.GetAnnotation

       

              Debug.Print SwAnn.GetName, SwAnn1.GetName → result → D3=D3

       

      help me. How to select two dimension.

       

      0.jpg

       

      Private Sub del20161203()

         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, SwDispDim1 As DisplayDimension

             Set SwDispDim = SwSelMgr.GetSelectedObject5(1)

             Set SwDispDim1 = SwSelMgr.GetSelectedObject5(2)

            

             DimCoordinate SwDispDim, SwDispDim1

            

            

      End Sub

       

       

       

       

      Function DimCoordinate(SwDispDim As DisplayDimension, SwDispDim1 As DisplayDimension)

          Dim SwAnn As Annotation, SwAnn1 As Annotation

          Dim Ss, Ss1

         

              Set SwAnn = SwDispDim.GetAnnotation

              Set SwAnn1 = SwDispDim.GetAnnotation

              Debug.Print SwAnn.GetName, SwAnn1.GetName

              Ss = SwAnn.GetPosition

              Ss1 = SwAnn.GetPosition

             

              Stop

         

      End Function

        • Re: How to select two dimension?
          Deepak Gupta

          If you know the dimension names, then you use can use SelectByID2 method to select them

           

          What end result you looking to get by selecting these dimensions.

            • Re: How to select two dimension?
              Yong Ning

              Align Dimensions | SOLIDWORKS Forums  https://forum.solidworks.com/message/261790#comment-261790

               

              Function AlignDimensions(SwDraw As DrawingDoc, varDims As Variant)

                  Dim ii As Integer

                     For ii = 0 To UBound(varDims)

                          boolstatus = SwDraw.Extension.SelectByID2(varDims(ii), "DIMENSION", 0, 0, 0, True, 0, Nothing, 0)

                     Next ii

                     'SwDraw.AlignDimensions

                     SwDraw.Extension.AlignDimensions swAlignDimensionType_LeftAlignText, 0

                   

                     SwDraw.ClearSelection2 True

                     AlignDimensions = True

              End Function

               

               

              Private Sub del20161204()

                  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

                  Dim SwDispDim As DisplayDimension, SwDim As Dimension

                  Dim Count As Integer, vDims()

                      Set SwView = SwDraw.GetFirstView

                      Do While Not SwView Is Nothing

                          Set SwDispDim = SwView.GetFirstDisplayDimension

                          Do While Not SwDispDim Is Nothing

                              Set SwDim = SwDispDim.GetDimension

                              ReDim Preserve vDims(Count)

                                'vDims(Count) = Replace(SwDim.FullName, "@壳体.Part", "")

                                vDims(Count) = SwDim.FullName & "@" & SwView.Name

                              Debug.Print SwDim.FullName

                              Set SwDispDim = SwDispDim.GetNext

                              Count = Count + 1

                          Loop

                          Set SwView = SwView.GetNextView

                      Loop

                      AlignDimensions SwDraw, vDims

                      Stop

              End Sub

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

               

               

               

              ''

              Private Sub subll1()

                  Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                       Set SwApp = Application.SldWorks

                       Set SwModel = SwApp.ActiveDoc

                       SwModel.AlignDimensions

              End Sub

            • Re: How to select two dimension?
              Ivana Kolin

              Set SwAnn1 = SwDispDim1.GetAnnotation