1 Reply Latest reply on Mar 11, 2014 7:44 AM by Patrick.Cashman

    Library manager : Reverse Part Number and Part Label

    b.henry

      Hello,

      I defined in my  LMC some Parts with a Part Number value and Part Label value different

      I want to change

      Part Number value must be Part Label value and reverse

      How to do this ?

      Need a script ?

      Regards

        • 1. Re: Library manager : Reverse Part Number and Part Label
          Patrick.Cashman

          This is a vb.net example.  If you use EFM with vbscript it will be somewhat different.  There are examples of how to do it with vbscript in the AATK, if I'm not mistaken.  This should give you a decent overview:

           

          I have a module that connects to the library.  It declares the variables that will represent partitions, parts, and other library objects. It also has the facility to establish a connection to the parts library database. The relevant parts are these:

           

          Public Module DX_Library_Interface

           

              Public job As String    'this is just the path to the central library .lmc file

              Public part_ed_dlg As MGCPCBPartsEditor.PartsEditorDlg

              Public pdb_db As MGCPCBPartsEditor.PartsDB

              Public partitions As MGCPCBPartsEditor.Partitions

              Public partition As MGCPCBPartsEditor.Partition

              Public parts As MGCPCBPartsEditor.Parts

              Public part As MGCPCBPartsEditor.Part

           

              Public Sub Get_Part_Editor()

                  job = prj.CentralLibraryPath

                  part_ed_dlg =CreateObject("MGCPCBLibraries.PartsEditorDlg")

                  pdb_db = part_ed_dlg.OpenDatabaseEx(job, False)

                  If part_ed_dlg.LockServer() Then

                      'do nothing

                  else

                      msgbox("Could not lock database for writing")

                  End If

              End Sub

           

              Public Sub Drop_Part_Editor()

                  'Close the open library and release hooks

                  part_ed_dlg.UnlockServer

                  part_ed_dlg.CloseActiveDatabase

                  pdb_db = Nothing

                  part_ed_dlg = Nothing

              End Sub

           

          End Module

           

           

          Then somewhere else in the project I have a subroutine that runs Get_Part_Editor, and does a part number and part name change:

           

          Public Sub set_library_obsolete_parts()

                  Dim part As MGCPCBPartsEditor.Part

                  Dim partition as MGCPCBPartsEditor.Partition

           

                  Get_Part_Editor()

           

                  partitions = pdb_db.Partitions

           

                  For Each partition In partitions

           

                      parts = partition.parts

                      For Each part In parts

                          If obs_parts.Contains(part.number) Then

                              part.Number = tmp & "-OBS"

                              part.Name = tmp & "-OBS"

                          End If

                      Next

                  part_ed_dlg.SaveActiveDatabase

                  Drop_Part_Editor()

              End Sub