AnsweredAssumed Answered

Adding vias with python

Question asked by martinthompson on May 3, 2018
Latest reply on May 8, 2018 by martinthompson

Hi all,


First, for background: I'm a proficient Python programmer, and have used Python to script modifications to my libraries successfully.


I'm new to PCB automation, and tried to writer a quick script to add a via today, to no avail.


Here's the bare bones:

   app = win32com.client.Dispatch('MGCPCB.ExpeditionPCBApplication')

    doc = app.ActiveDocument


    vianame = "RFEVia_0.15mm hole, 0.45mm pad"


    viastack = None

    for padstack in doc.Padstacks:

        if padstack.Name == vianame:

            viastack = padstack

            print "This is the padstack"


    if viastack is None:

        print "Can't find  a padstack called", vianame


    via = doc.PutVia(10,10, viastack)


which fails as viastack is apparently not a COM object - which surprised me!

Traceback (most recent call last):

  File "", line 79, in <module>


  File "", line 68, in test


  File "<COMObject <unknown>>", line 5, in PutVia

TypeError: The Python instance can not be converted to a COM object


Can anyone suggest how I do this please?