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

    ValidateServer(doc)

    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

        sys.exit(1)

    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 "test1.py", line 79, in <module>

    test()

  File "test1.py", line 68, in test

    viastack,

  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?


Thanks
Martin

Outcomes