0 Replies Latest reply on Jun 12, 2014 3:13 AM by Yong Ning

    How to get mass in design table?

    Yong Ning

      Use code →

      "SW-Mass@@A1@Part1.SLDPRT"

       

      0.jpg

       

      Help me , Need $PRP@Mass → result in excel

       

      1.jpg

       

      the code is

       

      Sub Main1()

          Dim swApp                   As SldWorks.SldWorks

          Dim swModel                 As SldWorks.ModelDoc2

          Dim vConfNameArr            As Variant

          Dim sConfigName             As String

          Dim nStart                  As Single

          Dim i                       As Long, Str

          Dim bShowConfig             As Boolean

          Dim bRebuild                As Boolean

          Dim bRet                    As Boolean

          Dim swCustProp As CustomPropertyManager

         

          Set swApp = CreateObject("SldWorks.Application")

          Set swModel = swApp.ActiveDoc

         

          Debug.Print "File = " + swModel.GetPathName

         

          vConfNameArr = swModel.GetConfigurationNames

          For i = 0 To UBound(vConfNameArr)

              sConfigName = vConfNameArr(i)

              Set swCustProp = swModel.Extension.CustomPropertyManager(sConfigName)

             

              bShowConfig = swModel.ShowConfiguration2(sConfigName)

             

              nStart = Timer

              bRebuild = swModel.ForceRebuild3(False)

              swCustProp.Add2 "Mass", 30, "MyValue"

              Str = "SW-Mass@@" & sConfigName & "@" & swModel.GetTitle

              'Debug.Print """" & Str & """"

              swCustProp.Set "Mass", Chr(34) & Str & Chr(34)

          Next i

      End Sub

      Sub main()

          Dim swApp As SldWorks.SldWorks, SwModel As SldWorks.ModelDoc2

          Dim vConfigNameArr, vConfigName

          Dim Str, ii

          Set swApp = Application.SldWorks

          Set SwModel = swApp.ActiveDoc

          vConfigNameArr = SwModel.GetConfigurationNames

          ''

          For ii = 0 To UBound(vConfigNameArr)

              vConfigName = vConfigNameArr(ii)

              With SwModel

                 .ShowConfiguration vConfigName

                 Str = "SW-Mass@@" & vConfigName & "@" & SwModel.GetTitle

                 .CustomInfo2(vConfigName, "质量") = """" & Str & """"

                 Debug.Print .CustomInfo2(vConfigName, "质量"),

                 Debug.Print .GetCustomInfoValue(vConfigName, "质量")

              End With

          Next ii

      End Sub