1 Reply Latest reply on Jun 19, 2014 12:28 PM by Jacob Corder

    have Dimension → How to set DisplayDimension?

    Yong Ning

      Have DisplayDimension → set  dimension → use sentance →

      Set SwDim = DispDim.GetDimension

      (Dim DispDim As DisplayDimension, SwDim As Dimension)

       

      question

       

      Have dimension → how to set displaydimension

       

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

      follow cde , use feature set displaydimension

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

      Private Sub del0519_1()

        Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2, SwDraw As DrawingDoc

          Set SwApp = GetObject(, "SldWorks.Application")

          Set SwModel = SwApp.ActiveDoc

        Dim SwSelMgr As SelectionMgr, SwFeat As Feature

          Set SwSelMgr = SwModel.SelectionManager

          Set SwFeat = SwSelMgr.GetSelectedObject5(1)

          'Debug.Print SwFeat.Name

        Dim DispDim As DisplayDimension, SwDim As Dimension

          Set SwDim = SwModel.Parameter("D1@阵列")

          Debug.Print SwDim.FullName, SwDim.Value

       

       

         

          Set DispDim = SwFeat.GetFirstDisplayDimension

          Debug.Print DispDim.GetText(1)

          Set DispDim = SwFeat.GetNextDisplayDimension(DispDim)

          Debug.Print DispDim.GetText(1)

          DispDim.SetText 1, Replace(DispDim.GetText(1), "XX", SwDim.Value)

         

      End Sub

        • Re: have Dimension → How to set DisplayDimension?
          Jacob Corder

          There is a way to do it but as far as i know i think you will have to get all DisplayDimensions

          Go through each one to get all of their dimensions using IDisplayDimension.GetDimension2

           

          Public Function GetDisplayDimension(ByVal ThisDimension As Dimension, ByVal DisplayDimensionsToCheck() As DisplayDimension) As DisplayDimension

                  Dim RetDim As DisplayDimension = Nothing

                  For i = LBound(DisplayDimensionsToCheck) To UBound(DisplayDimensionsToCheck)

                      Dim CompareDimension As Dimension = DisplayDimensionsToCheck(i).IGetDimension

                      If ISwapp.IsSame(CompareDimension, ThisDimension) = swObjectEquality.swObjectSame Then

                          RetDim = DisplayDimensionsToCheck(i)

                          Exit For

                      End If

                  Next

                  Return RetDim

              End Function