There is an example of how to do this in the AATK scripts. In \vbs\Route\, there are several ReplaceVia scripts. You can open one of them to see the full deal. I use ReplaceVias - thales-2007-Final.efm.
What it comes down to is
Set ViaPadstack = doc.PutPadstack(ReplaceViaSpanStart, ReplaceViaSpanEnd, NewViaName, False, False)
Set Via = doc.PutVia(pcbViaX, pcbViaY, ViaPadstack, doc.FindNet(pcbViaNet), Nothing, epcbAnchorNone, epcbUnitCurrent)
Of course there is a lot more surrounding these two lines. A lot of setup and getting all the right information such as location, net name, via span, and so on. Plus some error checking and DRC setup. The EFM I referenced above will show you all that.
Now if you want to change pin padstacks, the best thing to do is to not try to do that. Fix your library or make a new part or whatever. The hassle that will ensue if you try to do it is not worth it.
many thanks for your fast response.
What I really want to do is to modify the pin padstack. The purpose for that is to créate a template for coupon test using allways the same schematic with the same dummy parts changing through the script the default padstacks by the ones readed from the board for which the coupon test is going to be designed.
For that I would most likely skip the schematic step and use automation to place the desired objects on the board directly. Such as placing padstacks as above, then connecting them with traces and planes as needed by way of automation commands. I don't have anything quite like that, but it's definitely possible to place padstacks and traces to simulate pins and connections. You can use Net0 for all these connections so that you don't get as many DRC errrors.
And, not to be snide, but I'd also do whatever I could to avoid placing coupons on a design. I'm sure you have a good reason for it, but if it's possible to avoid doing so, I would. It's a lot of work, time, and effort to do something the board fabrication shop is already geared up to do
I am agree with you about avoiding coupon test in the pcb design. We create the coupon test apart in other PCB and we send design and PCB to the manufacturers who panelize the work according ECSS rules.
For me it is OK to place padstacks and traces simulating pins.
Is the procedure to place padstacks the same that the one to place vías?
OK, I lied. Actually I had just never looked into this, so I thought it would be harder. But it's not.
Dim pstack As MGCPCB.Padstack
Dim pstack_name As String
Dim pin As MGCPCB.Pin
Dim pins As MGCPCB.Pins
pstack_name = "p:ex70y70d38a"
pstack = doc.PutPadstack(1, 1, pstack_name, False, False)
pins = doc.Pins(1)
For Each pin In pins
If doc.TransactionStart(0) Then
pin.CurrentPadstack = pstack
The above works. pin.CurrentPadstack is the key command. Of course you could do it differently, by feeding it the pin to change, the new padstack name, etc., as needed by what you are trying to do. I used it to change an SMT pin to a through hole pin and it didn't complain. The transaction mode 0 I used means no DRC, so use it with caution.
Now I have two ways to do it. One, placing padstacks simulating pins, two, using the components from the schematic and replacing the padstacks. I think both way will cover my needs. I will think now which will be the more efficient and reliable.