15 Replies Latest reply on Aug 10, 2016 1:55 PM by Todd Bennett

    Perimeter & Bends

    Hrituc Alexandru

      Hi everyone

      I created this code in order to display the perimeter and bends in each configuration but not work properly...

      How can I modify this code so that my perimeter and bends  display  in every configuration ?

      Moreover, how could I change so I subscribe to perimeter values and bends when i run the macro again and again???

       

      for example now i have Bends = 3..... I modify the part and now have 5 bends, and i want to run a macro again to update properties to appear Bends = 5

       

       

       

       

      Dim swApp As SldWorks.SldWorks

      Dim swModel As SldWorks.ModelDoc2

      Dim swFeature As SldWorks.Feature

      Dim swCustPropMgr As SldWorks.CustomPropertyManager

       

       

      Dim Prop1 As String

      Dim Prop2 As String

      Dim Perimeter As String

      Dim Bends As String

       

       

          Dim vConfNameArr            As Variant

          Dim sConfigName             As String

          Dim i                       As Long

       

       

       

       

      Sub main()

       

       

      Set swApp = Application.SldWorks

      Set swModel = swApp.ActiveDoc

       

       

      Set swFeature = swModel.FirstFeature

      While Not swFeature Is Nothing

        If swFeature.GetTypeName = "CutListFolder" Then

          Set swCustPropMgr = swFeature.CustomPropertyManager

         

          swCustPropMgr.Get4 "Cutting Length-Outer", True, 0, Perimeter

          swCustPropMgr.Get4 "Bends", True, 0, Bends

         

          Prop1 = Perimeter

          Prop2 = Bends

         

          'Set swCustPropMgr = swModel.Extension.CustomPropertyManager("")

          Debug.Print Prop1

          Debug.Print Prop2

         

            vConfNameArr = swModel.GetConfigurationNames

         For i = 0 To UBound(vConfNameArr)

             sConfigName = vConfNameArr(i)

             swModel.AddCustomInfo3 sConfigName, "Perimeter", swCustomInfoText, Prop1

             swModel.AddCustomInfo3 sConfigName, "Bends", swCustomInfoText, Prop2

          Next i

          End

        End If

        Set swFeature = swFeature.GetNextFeature

      Wend

       

       

      End Sub

        • Re: Perimeter & Bends
          Deepak Gupta

          Search for cusPropMgr.Add3 and use this with option swCustomPropertyReplaceValue

           

          And use codes from this macro for all configurations: Re: Macro to add Mass and Area Properties to all configurations

            • Re: Perimeter & Bends
              Hrituc Alexandru

              I don't know where to set the code and how to juggle with properties so appear in each configuration..

               

              Dim swApp As SldWorks.SldWorks

              Dim swModel As SldWorks.ModelDoc2

              Dim swFeature As SldWorks.Feature

              Dim swCustPropMgr As SldWorks.CustomPropertyManager

               

               

              Dim Prop1 As String

              Dim Prop2 As String

              Dim Perimeter As String

              Dim Bends As String

               

               

                  Dim vConfNameArr            As Variant

                  Dim sConfigName             As String

                  Dim i                       As Long

               

               

               

               

              Sub main()

               

               

              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

               

               

              Set swFeature = swModel.FirstFeature

              While Not swFeature Is Nothing

                If swFeature.GetTypeName = "CutListFolder" Then

                  Set swCustPropMgr = swFeature.CustomPropertyManager

                 

                  swCustPropMgr.Get4 "Cutting Length-Outer", True, 0, Perimeter

                  swCustPropMgr.Get4 "Bends", True, 0, Bends

                 

                  Prop1 = Perimeter

                  Prop2 = Bends

                 

                  'Set swCustPropMgr = swModel.Extension.CustomPropertyManager("")

                  Debug.Print Prop1

                  Debug.Print Prop2

                 

                    vConfNameArr = swModel.GetConfigurationNames

                 For i = 0 To UBound(vConfNameArr)

                     sConfigName = vConfNameArr(i)

                     swModel.AddCustomInfo3 sConfigName, "Perimeter", swCustomInfoText, Prop1

                     swModel.AddCustomInfo3 sConfigName, "Bends", swCustomInfoText, Prop2

               

                     swModel.AddCustomInfo3 "Perimeter", swCustomInfoText, Prop1, swCustomPropertyReplaceValue

                     swModel.AddCustomInfo3 "Bends", swCustomInfoText, Prop2, swCustomPropertyReplaceValue

               

                  Next i

                  End

                End If

               

                Set swFeature = swFeature.GetNextFeature

              Wend

               

               

              End Sub