AnsweredAssumed Answered

How do you add a net and attach it to a pin on a symbol?

Question asked by mcrist on Jul 31, 2013
Latest reply on Oct 9, 2019 by lorenz_scheurer

We often get Excel spreadsheets with a list of connector pins and signal names that are connected to those pins.  We then have to manually place a connector symbol (which represents a single pin on the connector) and type in the name of the signal and the pin number.  This is a very tedious process.  Instead, I am trying to write a bit of code that will place the connector symbols automatically, create a net attached to the single pin on the symbol, then name the net.


The Excel spreadsheet has 5 columns:

- Partition (stored in the addpartition variable)

- Part Number (stored in the addpart variable)

- Symbol Name (stored in the addsym variable)

- Pin Number (stored in the addpin variable)

- Reference Designator (stored in the addref variable)

- Net Name (stored in the addnet variable)


Placing the symbol works properly with the code below.




thispart = vdApp.ActiveView.Block.AddPartInstance(addpartition, addpart, addsym, offsetx, offsety)

thispart.Refdes = addrefdes

thispart.Selected = True




I think I need to have a pin object to use the vdApp.ActiveView.Block.AddNet function properly.  However, when I try to determine the pin on the symbol to connect to using Query, I get 0 objects for pins.  I have also tried with a type mask of VDM_PIN with no luck (0 objects). 




mypins = vdApp.Query(ViewDraw.VdObjectTypeMask.VDM_COMPPIN, ViewDraw.VdAllOrSelected.VD_SELECTED)





For obj As Integer = 1 To mypins.Count

     thisobj = mypins.Item(obj)




     If thisobj.Type = ViewDraw.VdObjectType.VDTS_COMPPIN Then

          attachpin = mypins.Item(obj)

     End If










How can I get the pin object from the symbol that I just placed?  Also, in the code below, am I using the vdApp.ActiveView.Block.AddNet function properly?


thisnet = vdApp.ActiveView.Block.AddNet(offsetx + 80, offsety, offsetx + 100, offsety, attachpin,Nothing, ViewDraw.VdBusOrWire.VD_WIRE)


thisnet.AddLabel(thisnet.GetSegments(), addnet, 0, 0)