1 Reply Latest reply on Sep 16, 2016 10:56 AM by Patrick.Cashman

    DxDesigner Rename Net Names


      I would like to Rename all Nets in a DxDesigner Design no matter if the net already has a name or not. For this, I have gone the way as mostly described here but it does not work reliably and does not rename empty nets.

      The way I am trying to do this is:

      - Get every Part using a query:

      1. ViewDraw.IVdObjs part = dxdApp.Query(ViewDraw.VdObjectTypeMask.VDM_COMP, ViewDraw.VdAllOrSelected.VD_ALL);

      - Get each component out of the query:

      for (int i = 1; i <= part.Count; i++)


      comp = part.Item(i);


      - Get Reference Designator from part and compare it with the part I am looking the net up

      if (comp.Refdes == netArrayEntries.refDes)



      - Get connections

      conn = comp.GetConnections();


      - Compare pin number from every connection with the pin number I am looking for:

      for (int j = 1; j <= conn.Count; j++)


      if (conn.Item(j).CompPin.Number == netArrayEntries.cmpPin) // Compare component pin number with looked up pin number



      - Get Net from the connection item

      net = conn.Item(j).Net;


      - Set new net for the first segment of the net

      for (int k = 1;k < 2; k++)


      segment = net.GetSegments().Item(k);


      - Set

      net.GetLabel(segment).Selected = true;

      net.GetLabel(segment).Visible = ViewDraw.VdLabelVisibility.VDLABELVISIBLE;    

                                              netLabel = net.GetConnectedLabel(segment);

      netLabel.TextString = netArrayEntries.newNetName;


      As mentioned already, it does rename some nets, it doesn't on other. It works fairly slow and throws an exception on empty net names. It does not seem right to me, that I am getting dozens of segments, but renaming one does the job. Honestly, I assume there must be an easier way to accomplish what I've been looking for.

      As you may figure, this is written in C#, glad though for any examples in VB/VBS or hints that may lead to a proper solution.


      Please see the complete source code of the rename method below:


          private void alterNetnameWithComponentInput(netStruct netArrayEntries)         {               IVdComp comp;             IVdObjs conn;             IVdNet net;             IVdSegment segment;             IVdLabel netLabel;                 if ((netArrayEntries.newNetName == null) || (netArrayEntries.cmpPin == null) || (netArrayEntries.refDes == null))             {                 return;             }               ViewDraw.IVdObjs part = dxdApp.Query(ViewDraw.VdObjectTypeMask.VDM_COMP, ViewDraw.VdAllOrSelected.VD_ALL);      //Query all Components                 for (int i = 1; i <= part.Count; i++)             {                 comp = part.Item(i);                                   if (comp.Refdes == netArrayEntries.refDes)                 {                     //Console.WriteLine("Komponente " + comp.Refdes);                     AppendTextBox("Component " + comp.Refdes + "\n");                     outputFileNets.WriteLine("Component " + comp.Refdes + "\n");                     conn = comp.GetConnections();                                                                           // Get connections associated with component                       for (int j = 1; j <= conn.Count; j++)                     {                         if (conn.Item(j).CompPin.Number == netArrayEntries.cmpPin)                                          // Compare component pin number with looked up pin number                         {                             //Console.WriteLine("Pin Nummer " + conn.Item(j).CompPin.Number);                             AppendTextBox("Pin " + conn.Item(j).CompPin.Number + "\n");                             outputFileNets.WriteLine("Pin " + conn.Item(j).CompPin.Number + "\n");                             net = conn.Item(j).Net;                                                          //for (int k = 1; k < net.GetSegments().Count; k++)                                 for (int k = 1;k < 2; k++)                                 {                                     segment = net.GetSegments().Item(k);                                 try                                 {                                     AppendTextBox("Segment " + net.GetLabel(segment).TextString + "\n");                                     outputFileNets.WriteLine("Segment " + net.GetLabel(segment).TextString + "\n");                                 }                                 catch (Exception ex)                                 {                                     AppendTextBox("Empty Netsegment" + "\n");                                     outputFileNets.WriteLine("Empty Netsegment" + "\n");                                 }                                     try                                 {                                     //Console.WriteLine("Segment " + net.GetLabel(segment).TextString);                                     //net.GetLabel(segment).TextString = "NAME=" + netArrayEntries.newNetName;                                     //if (net.GetLabel(segment) == null)                                        -------CHANGED                                         //if (net.GetConnectedLabel(segment) == null)                                     //{                                         //net.AddLabel(segment, "Name=" + netArrayEntries.newNetName, 100, 100);                                         //net.AddAttribute(segment, "Name", 100, 100, VdVisibilityFlag.VDINVISIBLE);                                         //net.GetLabel(segment).TextString = netArrayEntries.newNetName;                                       //}                                     //else                                     //{                                         //Alternate Version                                          AppendTextBox("Renaming ID" + net.Id.ToString() + " from  " + net.GetLabel(segment).TextString + " to  " + netArrayEntries.newNetName + "\n");                                          net.GetLabel(segment).Selected = true;                                          net.GetLabel(segment).Visible = ViewDraw.VdLabelVisibility.VDLABELVISIBLE;                                              netLabel = net.GetConnectedLabel(segment);                                          netLabel.TextString = netArrayEntries.newNetName;                                           //net.GetLabel(segment).TextString = netArrayEntries.newNetName;                                         net.GetLabel(segment).Visible = ViewDraw.VdLabelVisibility.VDLABELINVISIBLE;                                     //}                                                                                                               AppendTextBox("Replacing Net with " + netArrayEntries.newNetName + "\n");                                     outputFileNets.WriteLine("Replacing Net with " + netArrayEntries.newNetName + "\n");                                     // Netz muss bereits Name haben, dann klappt es                                 }                                 catch (Exception ex)                                 {                                     Console.WriteLine(ex.ToString());                                     AppendTextBox("Error Replacing Net Segment name" + "\n");                                     outputFileNets.WriteLine("Error Replacing Net Segment name" + "\n");                                 }                                 AppendTextBox("DONE-------------------------------------" + "\n");                                 outputFileNets.WriteLine("DONE-------------------------------------" + "\n");                             }                         }                     }                 }             }         }




        • 1. Re: DxDesigner Rename Net Names

          I have a routine that does something similar.  I believe you are on the right track,  with your statement:


          netLabel.TextString = netArrayEntries.newNetName


          I don't remember the details of what went wrong, but I have a built in error check that asks the user if they are sure they have permissions to edit the sheet.  You may look into that and see if perhaps your RSCM server use is not letting you have write access to the sheets you are trying to edit.  If I remember correctly, I have to turn off the RSCM server (edit: uncheck the "Enable Concurrent Design" checkbox in Setup>Settings>Project) and open the schematic in single user mode in order to be able to run some scripts.


          Here is my example routine.  As you see, it is quite similar in basic functionality to yours.  I have been using this routine often for many months now, so it is basically good.  You are not far off a solution.


          Sub change_net_names()

                   Dim itm As ListViewItem

                   Dim net As ViewDraw.Net

                   Dim old_net As String

                   Dim lbl As ViewDraw.Label

                   Dim segs As Object

                   Dim seg As ViewDraw.Segment


                   Dim err_not_changed As Boolean


                   err_not_changed = False

                   For Each itm In lst_new_net_names.Items

                       If itm.Text = "--" Then GoTo next_item

                       If itm.Checked = True Then

                           old_net = d_new_names(itm.Text)

                           For Each net In nets

                               If net.LogicalNetName = old_net Then

                                   segs = net.GetSegments

                                   For Each seg In segs

                                       Exit For



                                   lbl = net.GetConnectedLabel(seg)


                                   If lbl Is Nothing Then

                                       Debug.Print("lbl is nothing")

                                       lbl = net.AddLabel(seg, itm.Text, seg.Location(0).X, seg.Location(0).Y)

                                       lbl.Visible = False

                                   End If


                                   Debug.Print("Renaming net from " & net.LogicalNetName & " to " & itm.Text)

                                   lbl.TextString = itm.Text


                                   If Not net.LogicalNetName = itm.Text Then

                                       err_not_changed = True

                                   End If


                                   net.AddAttribute(seg, "Power Supply Net=" & itm.Text, seg.Location(0).X, seg.Location(0).Y, 0)




                               End If


                       End If




                   If err_not_changed = True Then

                       MsgBox("Net name not changed.  Are you sure you have edit permission on this sheet?  Check and try again. ")

                   End If



          End Sub