AnsweredAssumed Answered

Counting connections in xPCB Layout?

Question asked by mcrist on Jul 26, 2019
Latest reply on Aug 15, 2019 by mcrist

I'm working on a C# plugin that will count the number of connections in xPCB Layout and generate a report similar to Output -> Design Status. However, I can't seem to get the same connection count as design status. I've tried three different methods:

1 - Count the nets that are connected to each pin

foreach (MGCPCB.Component part in parts) {   foreach (MGCPCB.Pin pin in part.Pins) {     if (pin.Net.IsNet0() == false) {       if (pin.IsNoConnect() == false && pin.IsNoRoute() == false) {         retval.Connections++;       } else {         Debug.WriteLine(pin.Net.Name + " is connected to a no connect or no route pin");       }     }   } }

2 - Count the pins in the net.Pins collection except single pin nets

foreach(MGCPCB.Net net in nets) {   if (net.IsNet0() == false) {     if (net.Pins.Count > 1) {       retval.Connections += net.Pins.Count;     }   } }

3 - Use the doc.ConnectionsCountNets 

retval.Connections = doc.ConnectionCountNets.Count;


Note that methods 1 and 2 return the same result, however, the count is higher than the connections reported by Design Status.


How is Design Status counting connections?


Also, is there a better way to post code here that preserves line breaks and formatting? The preformatted "format" doesn't seem to retain the preformatting.