AnsweredAssumed Answered

Library automation: How modify part data

Question asked by gigus on Mar 6, 2020
Latest reply on Mar 9, 2020 by gigus

Xpedition 2.2 (64bit)

Hi, I try to modify part data using vbs script inside library manager but it doesn't work.

I open library with "Xpedition Library Manager", all partitions are unreserved.

Then I launch VBS script with  File -> Open script Form ...

I get a run time error message "The partition containing part is reserve. Cannot modify data" at the line

PartsColl.Item(1).Name = "ThisIsNewName"

 

After this message all partitions are reserved.

 

This is a simplified version of the script, it try to modify Part.Name value of a dummy part 12345

 

Option Explicit

' Create the PDBEditor object
Dim pdbEditor
Set pdbEditor = CreateObject("MGCPCBLibraries.PartsEditorDlg")

Dim PartDB
Set PartDB = pdbEditor.OpenDatabaseEx(Application.ActiveLibrary.FullName)
pdbEditor.Visible = False

Dim PartLookFor 
Dim pdbPartition
 
PartLookFor = "12345"
MsgBox "Part to look for = " & PartLookFor

 For Each pdbPartition In PartDB.Partitions

  MsgBox "Actual Partition = " & pdbPartition.Name

  Dim PartsColl
  Set PartsColl = pdbPartition.Parts(-1,PartLookFor)

  If PartsColl.Count = 1 Then
   MsgBox "Part found in Partizion = " & pdbPartition.Name
   If pdbEditor.LockServer Then
    MsgBox "OK_lock"
    PartsColl.Item(1).Name = "ThisIsNewName"
    pdbEditor.SaveActiveDatabase()
   Else
    MsgBox "NO_lock"
   End If
  Else
   MsgBox "Found more than one part"
  End If
  
 next


pdbEditor.CloseActiveDatabase(True) ' Close and save
pdbEditor.Quit()
Set pdbEditor = Nothing
Set PartDB = Nothing

Outcomes