4 Replies Latest reply on Sep 30, 2012 10:49 PM by olsmir

    How to add a property to the parts in Central Library

    olsmir

      Hello.

       

      Does anybody know how to add a property to the parts in Central Library?

      I need to automatically add the "Attachment" property to each part in the Central Library where this property is missing.

      Based on the library_editors_auto.pdf, I have created the following script:

       

      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

      Option Explicit

      Dim app,lib
      Dim pdbEditor,pdbDB,i,j,k,m,flag
      Dim PartitionsColl,PartsColl,PropertiesColl
      Dim partition,part,propty,proptynew

      Set app = GetObject (,"LibraryManager.Application")
      Scripting.AddTypeLibrary ("LibraryManager.Application")
      Set lib = app.ActiveLibrary
      Call AddAttr


      Sub AddAttr()

      Set pdbEditor = CreateObject("MGCPCBLibraries.PartsEditorDlg")
      Scripting.AddTypeLibrary ("MGCPCBLibraries.PartsEditorDlg")
      Set pdbDB = pdbEditor.OpenDatabaseEx(lib.FullName, False)
      pdbEditor.Visible = False

      Set proptynew = Nothing

      Set PartitionsColl = pdbDB.Partitions
      For Each partition In PartitionsColl

          If (partition.Name = "Amplifier_BaseC") Then

          Set PartsColl = partition.Parts
          For Each part In PartsColl
              flag = 0
              Set PropertiesColl = part.Properties
              For Each propty In PropertiesColl
                  If (propty.Name = "Attachment") Then flag = 1
              Next

              If (flag = 0) Then proptynew = part.PutPropertyEx("Attachment","some path")

          Next

          End if

      Next

      pdbEditor.SaveActiveDatabase
      pdbEditor.Quit
      MsgBox "End", 0, ""

      End Sub

       

      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

       

      I have opened my CL in Library Manager, and invoked the above script. However, it has failed stating that "proptynew" is not supported in line 36.

      Line 36 is: If (flag = 0) Then proptynew = part.PutPropertyEx("Attachment","some path")

       

      Can anybody tell me what is wrong and how to correct my script?

       

      Oleg