There is a section in the Automation and Scripting part of the help files for Library Management and Library Editors. The methods for manipulating padstacks are described in there. You can also find the same information on the supportnet website here.
There are some examples given there on how to get started.
I did some work on this to try something out as a test. It was a simple test to see if I could change a padstack and use different sized pads on different layers.
Now, before the actual code, let me talk about methods. You can't do this on an active PCB database. You can query the padstack library of a pcb design, but everything in it is read-only. This is stated in the help documentation. So you can only make edits in the padstack database of a library (.lmc). If I needed to do this, I'd create a secondary library which contains padstacks only to use as a sandbox for this purpose only. Once you have a modified padstack in the library, you have to use library services to import it into your design. If you are changing padstacks a lot, you'd want to keep your main central library intact and not change the default padstacks in it, so just use the secondary library to create or modify them for a specific purpose then import into your design. As long as everyone in your group knows the secondary database will have who knows what in it, and the padstacks in it may be changing frequently, you can safely do this without messing up someone else's design
The following example is not 100% complete. It assumes you have a .net project and the basics of how to use .net and the Mentor COM interfaces under control.
In a public module, I declare the global variables used:
Public app As MGCPCB.Application
Public doc As MGCPCB.Document
Public gui As MGCPCB.Gui
Public prog_id As Integer
Public mglaunch_path As String
Public ps_editor As PadstackEditorLib.PadstackEditorDlg
Public ps_db As PadstackEditorLib.PadstackDB
Public has_ps_editor, has_ps_db As Boolean
Public pcb_path, lib_path As String
You'll need routines to get prog_id and mglaunch_path. I've covered that elsewhere and have made the routines available in a .net automation template.
On that note, remember that you'll need to start the .net IDE with mglaunch if you want to run in debug mode from the IDE. I've also covered how to do that with a shell script, getting mglaunch path from the registry.
Here is the part that connects to the padstack editor and padstack database in an lmc file:
Public Sub ps_connect()
'Creates a handle to the Parts Editor in Library Manager
ps_editor = CreateObject("MGCPCBLibraries.PadstackEditorDlg" & "." & prog_id.ToString)
Catch ex As Exception
Debug.Print("failing to create padstack editor session with this error: " & ex.Message)
has_ps_editor = False
If ps_editor is Nothing Then
Debug.Print("ps_editor is nothing")
has_ps_editor = True
lib_path = "path_to_your_padstack_library.lmc"
ps_db = Nothing
ps_db = ps_editor.OpenDatabaseEx(lib_path, False)
has_ps_db = False
If ps_db Is Nothing Then
Debug.Print("ps_db is nothing")
has_ps_db = True
And here is a simple routine that changes a single via padstack:
Dim pss As PadstackEditorLib.Padstacks
Dim ps As PadstackEditorLib.Padstack
Dim n As Integer
Dim pad As PadstackEditorLib.Pad
Dim pads As PadstackEditorLib.Pads
Dim hole As PadstackEditorLib.Hole
Dim holes As PadstackEditorLib.Holes
pss = ps_db.Padstacks
Debug.Print("there are " & pss.Count & " items in the collection")
For Each ps In pss
If ps.Name = "vsd:ex24y24d13a" Then
ps = ps_db.NewPadstack()
ps.Type = 16
ps.Name = "vsd:ex24y24d13a"
hole = ps_db.FindHole("Rnd 13 +Tol 0 -Tol -13")
ps.Hole = hole
Debug.Print("hole name is " & hole.Name)
pad = ps_db.FindPad("Round 24")
ps.Pad(-1) = pad
ps.Pad(-3) = pad
ps.Pad(-2) = pad
pad = ps_db.FindPad("Round 26")
ps.Pad(3) = pad
ps.Pad(9) = pad
ps_db = Nothing
ps_editor = Nothing
The key bit of information here is that all of the default pads have a designated integer (these are all listed in the help), with a negative sign. For physical layer overrides, use the positive integer that corresponds to the physical layer in your board. I verified that when I pulled the changed via into a pcb design that the via padstack was correctly changed.
In a real situation, you might want to get the pad size information from some external source, such as a text file or spreadsheet. I'm not including that here because it's beyond the scope of this exercise, but it's not hard to do. Using these methods, one could easily create or modify padstacks in the library using padstack names from an external source, along with the values of the pad sizes.
Now if you want to change clearances on a per-layer basis, you'd need to use CES to create clearance rules net class, and apply them appropriately. There is no way to define the clearances in the padstack editor, other than the default plane clearance, which is one of the default layers in the padstack definition. It is possible to automate CES, but you need to request the free license key for that from your Mentor AE.
Thanks for the help...
I'm new with the script's options
Can you upload a working script that change 1 padstack ?
I will try to see if it works.
Sorry, I'm not going to write the whole thing and hand it to you. I've provided everything you'd need here and elsewhere on this forum (my automation template) to implement this. If you get the automation template and add what I've posted here to it, then change the name of the padstack to work on, it will do what you want. You'd also have to change the pad names and layers for how you want your new padstacks.
If your company is in need of more extensive implementation of automation solutions, I may be able to help you out. Contact me at firstname.lastname@example.org if you'd like to pursue that.