2 Replies Latest reply on Aug 11, 2017 10:33 PM by Yong Ning

    Difference betweent custinfo2 and CustomPropertyManager

    Yong Ning

      Like use CustInfo, it's simple.

       

      The use of CustomPropertyManager have little trouble

       

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

      use custinfo2 → Low than Solidworks 2006 version have

      This property gets and sets the file custom information for the SolidWorks document.

      ***

      use CustomPropertyManager → Heigh than Solidworks 2007 version

      This property gets the custom property information for this configuration.

      ***

       

      use Custinfo2 code is

      '''''

      Function CustInfoName(SwModel As ModelDoc2)

        Dim SwConfig As Configuration, ConfArr, ConfName, CustArr

        Dim Str, kk

          kk = 2

          ConfArr = SwModel.GetConfigurationNames

          For ii = 0 To UBound(ConfArr)

              Set SwConfig = SwModel.GetConfigurationByName(ConfArr(ii))

              ConfName = SwConfig.Name

              With SwModel

                 Str = Chr(34) & "SW-Mass@@" & ConfName & "@" & .GetTitle & Chr(34)

                 .AddCustomInfo3 ConfName, "质量", 30, "12"

                 .CustomInfo2(ConfName, "质量") = Str '"""" & Str & """"

                 Str = Chr(34) & "SW-Material@@" & ConfName & "@" & .GetTitle & Chr(34)

               

               

                 .AddCustomInfo3 ConfName, "材料", 30, "12"

                 If UCase(.GetTitle) Like "*SLDASM" Then

                   .CustomInfo2(ConfName, "材料") = "组合件"

                 Else

                   .CustomInfo2(ConfName, "材料") = Str '"""" & Str & """"

                 End If

                 CustArr = .GetCustomInfoNames2(ConfName)

                 .ShowConfiguration ConfName

              End With

          Next ii

      End Function

       

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

        • Re: Difference betweent custinfo2 and CustomPropertyManager
          Yong Ning

          2010 SolidWorks API Help - Obsolete and New Custom Properties Methods and Properties

          http://help.solidworks.com/2010/English/api/sldworksapiprogguide/miscellaneous/obsolete_and_new_custom_properties_methods_and_properties.htm

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

           

          Obsolete and New Custom Properties Methods and Properties

          The following list identifies the now obsolete custom property methods and properties and their replacements as of SolidWorks 2007 and later.

           

          Obsolete API→

          AddCustomInfo3,CustomInfo2,DeleteCustomInfo2,GetCustomInfoCount2,GetCustomInfoNames2,GetCustomInfoType3,GetCustomInfoValue

          New API→IModelDocExtension::CustomPropertyManager

            • Re: Difference betweent custinfo2 and CustomPropertyManager
              Yong Ning

              ''

              Sub del()

                 

                  Dim Xls As Excel.Application, Rng As Range

                       Set Xls = GetObject(, "Excel.Application")

                       Set Rng = Xls.Selection

                  Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                       Set SwApp = Application.SldWorks

                       Set SwModel = SwApp.ActiveDoc

                  Dim Conf, SwConf As Configuration

                  Dim vCustInfo, CustInfo, ii

                      

                       Set SwConf = SwModel.GetActiveConfiguration ' .GetConfigurationByName(vv)

                       vCustInfo = SwModel.GetCustomInfoNames2(SwConf.Name)

                       For ii = 0 To UBound(vCustInfo)

                           With SwModel

                                Debug.Print vCustInfo(ii),

                                Debug.Print .GetCustomInfoValue(SwConf.Name, CustInfo)

                                Debug.Print Rng(1, ii).Address

                               

                                Rng(1, ii) = vCustInfo(ii)

                           End With

                       Next

              End Sub

              ''

              ''

              Sub del1()

                 

                  Dim Xls As Excel.Application, Rng As Range

                       Set Xls = GetObject(, "Excel.Application")

                       Set Rng = Xls.Selection

                  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 Conf, SwConf As Configuration

                  Dim vCustInfo, CustInfo

                  Dim ii, jj, Vv

                      

                

                  Dim SwTabAnn As TableAnnotation

                  Dim SwBOMTab As BomTableAnnotation

                       Set SwTabAnn = SwSelMgr.GetSelectedObject5(1)

                       ''

                       'Set SwBOMTab = SwTabAnn

                       With SwTabAnn

                          

                           Debug.Print .GetHeaderCount, .ColumnCount

                           For jj = 0 To .ColumnCount

                               'Debug.Print .GetAllCustomProperties(jj),

                               Debug.Print .GetColumnTitle(jj), .Text(.RowCount - 1, jj)

                           Next jj

                       End With

                       Stop

                      

              End Sub