AnsweredAssumed Answered

Get selected traces in design using python.

Question asked by vpoblet on Dec 21, 2018
Latest reply on Oct 10, 2019 by mcrist

Hi, I've been developing several tools  using VB, now I've decided to create the new tools in python.


I'm stucked trying to get the selected nets o vias in python.

For instance regarding vias, I using the metode :



But in python using the same mode:

viasColl = pcbDoc.Vias(epcbSelectSelected)


I only got one via and it is not the selected one.


I have the same problem for traces:

SelectedTraces = pcbDoc.Traces(epcbSelectSelected)



Only as a reference here is the old code in VB


If pcbDoc.Traces(epcbSelectSelected).Count <> 0 Then

    Netname = pcbDoc.Traces(epcbSelectSelected).Item(1).Name

    SomeNet = True


ElseIf pcbDoc.Pins(epcbSelectSelected).Count <> 0 Then

    SomeNet = True

    Netname = pcbDoc.Pins(epcbSelectSelected).Item(1).Net.Name


ElseIf pcbDoc.PlaneShapes(epcbSelectSelected).Count <> 0 Then

    SomeNet = True

    Netname = pcbDoc.PlaneShapes(epcbSelectSelected).Item(1).Net.Name


ElseIf pcbDoc.Vias(epcbSelectSelected).Count <> 0 Then

    SomeNet = True

    Netname = pcbDoc.Vias(epcbSelectSelected).Item(1).Net.Name


I'm trying to replicate the same in python but I don't get the same results.


Any help will be welcomed,

Victor P.