7 Replies Latest reply on Aug 31, 2018 1:19 PM by Deepak Gupta

    Coping value from Config Specific Properties <macro help>

    Mart Müllerbeck

      Hi

       

      For starters, I know just about enough VBA and SW API's that's I'm very dangerous to file integrity. I wanted to change variable name in our library part files and wrote this macro that copies value from Config Specific Properties, creates new variable in the same property and pastes this copied value in there. It seems that my program works, but it takes very long time to go through all the custom properties. Is this okey?

       

      Macro is here:

      Dim
      Dim swApp As SldWorks.SldWorks
      Dim swModel As ModelDoc2
      Dim swModelDocExt As ModelDocExtension
      
      
      Dim swCustProp As CustomPropertyManager
      Dim val As String
      Dim valout As String
      Dim bool As Boolean
      Dim fieldname As String
      Dim FieldName1 As String
      Dim FieldType As Integer
      Dim FieldValue As String
      Dim OverwriteExisting As Integer
      Dim value1 As Integer
      Dim i As Integer
      Dim vConfNameArr As Variant
      
      Sub main()
      Set swApp = Application.SldWorks
      Set swModel = swApp.ActiveDoc
      fieldname = "nimetus"
      vConfNameArr = swModel.GetConfigurationNames
      
      For i = 0 To UBound(vConfNameArr)
      
          Set swModelDocExt = swModel.Extension
          Set swCustProp = swModelDocExt.CustomPropertyManager("")
          sConfigName = vConfNameArr(i)
          'Set cpm3 = swModel.Extension.CustomPropertyManager(sConfigName)
                  
          'bool = swCustProp.Get4(fieldname, False, val, valout)
          bool = swModel.Extension.CustomPropertyManager(vConfNameArr(i)).Get4("nimetus", False, val, valout)
      
          FieldName1 = "Description"
          FieldType = 30
          FieldValue = valout
          value1 = swModel.AddCustomInfo3(vConfNameArr(i), "Description", FieldType, valout)
      
      
      Next i
      End Sub
      
      
      

       

      Is everything okey with my code?

      Best regards!