Is it possible to create and connect a net within DxDesigner using scripting?
Yes it is. Have a look to the addnet method for adding a net and the addlabel for naming the net
Block.AddNet(ByVal Locationx1 As Long, ByVal Locationy1 As Long, ByVal Locationx2 As Long, ByVal Locationy2 As Long, ByVal CompPin1 As IVdCmpPin, ByVal CompPin2 As IVdCmpPin, ByVal BusOrWire As VdBusOrWire) As IVdNet
Net.AddLabel(ByVal Segment As IVdSegment, ByVal String As String, ByVal X As Long, ByVal Y As Long) As IVdLabel
Thank you very much Juergen, I discovered these methods at the weekend
while reading the xDx Automation Manual and plan to write a Matlab ActiveX
script to add some nets to my design
Have you ever used these methods?
I only did a test with a few components and it works. That is all i did with adding net's.
Would you be able to share your test script so I could have a look at its
The four examples in the xDx Automation Manual focus on adding new menus etc
I did my test with excel. Is slow, but for testing ok.
First column is the netname to be added and after that the existing components followed by the pin number.
In the first row you see the UID without a pin number. This is for a globel signal symbol. Leave the pin-number column blank.
It works in that way that a connection will be added from first component to the second and then from first to third and so on.
You can change it if needed. My code is only a first test and not very developed. Maybe there are better and shorter ways.
I did not spend much time here.
Test was done only with a schematic with one page.
raster must be set to the minimum. Otherwise you maybe will get open connections
Sub AutoNetzverbinden()On Error Resume NextDim Acp(10000) As ComponentPinDim coDim mynet As NetDim cmp As ObjectDim cons As ObjectDim Nname, ref1, Pname1, ref2, Pname2Dim found1 As BooleanDim found2 As Boolean
Set vdapp = GetObject(, "ViewDraw.Application") Set vdview = vdapp.ActiveView Application.ScreenUpdating = False co = 1 For Each cmp In vdview.Query(VDM_COMP, VD_ALL) 'go through all comp connections Set cons = cmp.GetConnections For i = 1 To cons.Count Set Acp(co) = cons(i).CompPin 'collect all comppins in an array co = co + 1 Next Nextco = co - 1
For Each eintrag In Sheets("Netzliste").Range("A:A") ' get netname, first refdes and pin-number from excel table If eintrag = "" Then Exit For Nname = Sheets("Netzliste").Cells(eintrag.Row, 1) ref1 = Sheets("Netzliste").Cells(eintrag.Row, 2) Pname1 = Sheets("Netzliste").Cells(eintrag.Row, 3) found1 = False For i = 1 To co 'search for the first comppin in the array If ((Acp(i).Component.Refdes = ref1 Or Acp(i).Component.GetName(1) = ref1) And Acp(i).Number = Pname1) Or Acp(i).Component.UID = ref1 And Acp(i).Number = "" Then P1 = i found1 = True Exit For End If Next i For coun = 4 To 1000 Step 2 'get second, third, ..... refdes/UID and pin-number from excel table If Sheets("Netzliste").Cells(eintrag.Row, coun) = "" Then Exit For ref2 = Sheets("Netzliste").Cells(eintrag.Row, coun) Pname2 = Sheets("Netzliste").Cells(eintrag.Row, coun + 1) found2 = False For i = 1 To co 'search for the second comppin in the array If ((Acp(i).Component.Refdes = ref2 Or Acp(i).Component.GetName(1) = ref2) And Acp(i).Number = Pname2) Or Acp(i).Component.UID = ref2 And Acp(i).Number = "" Then P2 = i found2 = True Exit For End If Next i If found1 = True And found2 = True Then ' if first and second pin is found then add net Set mynet = vdview.Block.AddNet(0, 0, 0, 0, Acp(P1), Acp(P2), VD_WIRE) Set seg = mynet.GetSegments Set po = seg(1).Location(VDJ_HIGH) ' get location of segment On Error Resume Next Set lab = mynet.AddLabel(seg(1), Nname, po.X, po.Y) 'give the net the name from excel table lab.Visible = VDLABELINVISIBLE 'net name invisible End If Next coun NextSet vdview = NothingSet vdapp = NothingEnd Sub
thank you, I'll have a look, I'm going to write some Matlab code to do this ...
Retrieving data ...