6 Replies Latest reply on Apr 4, 2017 12:58 AM by louise

    Creating Nets Using Scripting


      Is it possible to create and connect a net within DxDesigner using scripting?

        • 1. Re: Creating Nets 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

          • 2. Re: Creating Nets Using Scripting

            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?




            Kind Regards,



            • 3. Re: Creating Nets Using Scripting

              Hello Rajan

              I only did a test with a few components and it works. That is all i did with adding net's.

              Kind regards


              • 4. Re: Creating Nets Using Scripting

                Hi Juergen,




                Would you be able to share your test script so I could have a look at its

                structure please?




                The four examples in the xDx Automation Manual focus on adding new menus etc





                Kind Regards,



                • 5. Re: Creating Nets Using Scripting

                  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


                  Excel VBA:


                  Sub AutoNetzverbinden()
                  On Error Resume Next
                  Dim Acp(10000) As ComponentPin
                  Dim co
                  Dim mynet As Net
                  Dim cmp As Object
                  Dim cons As Object
                  Dim Nname, ref1, Pname1, ref2, Pname2
                  Dim found1 As Boolean
                  Dim 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
                  co = 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
                  Set vdview = Nothing
                  Set vdapp = Nothing
                  End Sub

                  • 6. Re: Creating Nets Using Scripting

                    thank you, I'll have a look, I'm going to write some Matlab code to do this ...