3 Replies Latest reply on Oct 30, 2017 9:34 PM by Yong Ning

    How to judge  Equations dimension.

    Yong Ning

      ddd.jpg

        • Re: How to judge  Equations dimension.
          Manikandan Babu

          Hi Yong,

           

          Lets try this code.

           

          Dim swApp As SldWorks.SldWorks

          Dim swmodel As SldWorks.ModelDoc2

          Dim swDim As SldWorks.Dimension

          Dim bool As Boolean

           

          Sub main()

          Set swApp = Application.SldWorks

          Set swmodel = swApp.ActiveDoc

          Set swDim = swmodel.Parameter("D2@Sketch1")

            If swDim.DrivenState = 1 Then

            Debug.Print "Equation dimension"

             End If

          End Sub

           

          Note:Consider sketch is having all dimension as  driving dimension.

           

          Manikandan

            • Re: How to judge  Equations dimension.
              Yong Ning

              Thanks for your reply

               

               

              2017 SOLIDWORKS API Help - swDimensionDrivenState_e Enumeration  http://help.solidworks.com/2017/english/api/swconst/SOLIDWORKS.Interop.swconst~SOLIDWORKS.Interop.swconst.swDimensionDrivenState_e.html

               

               

              MemberDescription
              swDimensionDriven1 = Dimension is a driven dimension
              swDimensionDrivenUnknown0 = Driven or driving state is unknown
              swDimensionDriving2 = Dimension is a driving dimension

               

               

               

               

              Private Sub del()

                  Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                      Set SwApp = Application.SldWorks

                      Set SwModel = SwApp.ActiveDoc

                  Dim SwFeat As Feature

                  Dim Str

                  Dim SwDispDim As DisplayDimension, SwDim As Dimension

                      Set SwFeat = SwModel.FirstFeature

                      Do While Not SwFeat Is Nothing

                          Set SwDispDim = SwFeat.GetFirstDisplayDimension

                          Do While Not SwDispDim Is Nothing

                               Set SwDim = SwDispDim.GetDimension

                               If SwDim.DrivenState = 2 And SwFeat.GetTypeName <> "Revolution" Then

                                   Str = SwDim.Name & "@" & SwFeat.Name

                                   Debug.Print Str, SwFeat.GetTypeName, SwDim.DrivenState

                               End If

                               Set SwDispDim = SwFeat.GetNextDisplayDimension(SwDispDim)

                          Loop

                          Set SwFeat = SwFeat.GetNextFeature

                      Loop

              End Sub

              ----------------

              result is

               

              THK@Sketch    ProfileFeature               2

              Ln@Sketch     ProfileFeature               2

              Dn@Sketch     ProfileFeature               2

              D1@Dist       RefPlane       2

            • Re: How to judge  Equations dimension.
              Yong Ning

              2010 SOLIDWORKS 帮助 - Glossary  http://help.solidworks.com/2010/chinese-simplified/solidworks/sldworks/legacyhelp/sldworks/overview/glossary.htm

              从动尺寸(driven dimension)。请参阅参考尺寸

              驱动尺寸(driving dimension)。也称为模型尺寸,为草图实体设定数值。它还可控制距离、厚度、及特征参数。

               

               

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

              2010 SOLIDWORKS API Help - swDimensionDrivenState_e Enumeration  http://help.solidworks.com/2010/english/api/swconst/solidworks.interop.swconst~solidworks.interop.swconst.swdimensiondrivenstate_e.html

               

              SwDim.DrivenState = 1  →  Dimension is a driven dimension→ Equations dimension → 1

               

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

              Private Sub del()

                  Dim Dict As New Dictionary, Dict1 As New Dictionary

                  Dim SwApp As SldWorks.SldWorks, SwMOdel As ModelDoc2

                      Set SwApp = Application.SldWorks

                      Set SwMOdel = SwApp.ActiveDoc

                  Dim SwEqnMgr As EquationMgr, Str, aStr

                      Set SwEqnMgr = SwMOdel.GetEquationMgr

                   

                      With SwEqnMgr

                          For ii = 0 To .GetCount

                             aStr = aStr & .Equation(ii)

                          Next ii

                      End With

                      ''

                   Dim SwFeat As Feature

                   Dim SwDispDim As DisplayDimension, SwDim As Dimension

                       Set SwFeat = SwMOdel.FirstFeature

                       Do While Not SwFeat Is Nothing

                           Set SwDispDim = SwFeat.GetFirstDisplayDimension

                           Do While Not SwDispDim Is Nothing

                               Set SwDim = SwDispDim.GetDimension

                               Str = SwDim.FullName

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

                               If SwDim.DrivenState = 2 Then

                                   Dict(Str) = ""

                               End If

                               If SwDim.DrivenState = 1 Then

                                   If Not aStr Like "*" & Str & "*" Then

                                       'Debug.Print Str, aStr Like "*" & Str & "*"

                                       Dict1(Str) = ""

                                   End If

                                

                               End If

                               Set SwDispDim = SwFeat.GetNextDisplayDimension(SwDispDim)

                           Loop

                           Set SwFeat = SwFeat.GetNextFeature

                       Loop

                       For ii = 0 To Dict.Count - 1

                            Debug.Print Dict.Keys(ii)

                       Next ii

                       For ii = 0 To Dict1.Count - 1

                            Debug.Print "*******", Dict1.Keys(ii)

                       Next ii

              End Sub