As far as implementation it will be much simpler to first select two (or more) nets, then work on them. The mouse event handling in Expedition is difficult, and you will spend a ton of time just getting that to work when it's not really necessary.
Also there is the issue of CES automation being unavailable. There is still a Clearance object in the PCB Document automation available, but I get exceptions thrown using it. Clearance.GetNetClearanceRuleByType and Clearance.GetClearanceRule both cause errors.
I do not know what is happening under the hood, but I suspect that the Clearance object is no longer valid in the current releases of Expedition. The CES database no doubt has higher level functions that the PCB is now accessing, and the leftover Clearance functionality may not have any data behind it.
What is really going on with that function is a question for the folks at Mentor.
I did a quick try at it, which you might try using as a starting point. Perhaps you can find a way to overcome the exception errors that crop up with this.
Dim nets As MGCPCB.Nets
Dim net As MGCPCB.Net
Dim n, i As Integer
Dim str As String
Dim a As Object
Dim b As Object
Dim clr As MGCPCB.Clearance
Dim dist as Double
nets = doc.Nets(1)
clr = doc.Clearance
str = ""
For n = 0 To nets.Count
For i = 0 To nets.Count
If Not i = n Then
a = nets(n)
b = nets(i)
dist = clr.GetClearanceRule(a, b, 1, 1, 0)
str = str & nets(n).Name & " < > " & nets(i).Name & " = " & dist & vbcrlf
'now do whatever you want with the str value
mhm. Good Idea with GetClearanceRule.
But when I try, I get an "Invalid Parameters" Error.
Set pcbNets = pcbDoc.Nets(epcbSelectSelected)
Set a = pcbNets(1)
Set b = pcbNets(2)
dist = pcbDoc.Clearance.GetClearanceRule(a, b, 1, 1, epcbUnitMM)
Any Idea why ?
No, I don't know. I thought of changing the data type of a and b to MGCPCB.Net, but that yields the same result with an exception error thrown.
I strongly suspect that because Expedition now uses CES for all its rules, and the Clearance object is a holdover from back when all the rules were self-contained (pre-CES) that the Clearance object is no longer valid.
I would like someone from Mentor who knows for certain to confirm this and let us know how to do this. Removing the automation hooks to CES cripples us in this regard.
We use the following snippit to get the minimal distance between 2 nets ....
For Layer_tmp = 1 to pcbDoc.LayerCount step 1
MinClearanceLayer = 99
For Each NetComp1 In pcbDoc.Nets
For Each NetComp2 in pcbDoc.Nets
if NetComp1.Name <> NetComp2.Name then
if ( ClearanceObj.GetNetClearanceRuleByType( epcbClearanceTrace, NetComp1, Layer_tmp, epcbClearanceTrace, NetComp2, Layer_tmp, "(Master)", epcbUnitMM) < MinClearanceLayer) then
MinClearanceLayer = ClearanceObj.GetNetClearanceRuleByType( epcbClearanceTrace, NetComp1, Layer_tmp, epcbClearanceTrace, NetComp2, Layer_tmp, "(Master)", epcbUnitMM)
NetStr1 = NetComp1.Name
NetStr2 = NetComp2.Name
f1.WriteLine(" Mindestabstand innerhalb Layer " & Layer_tmp & " (mm): " & MinClearanceLayer )
Maybe this helps ...
great inspirence for me! I changed your code a little bit. At the Moment I will only check on Layer 1,
but in my case, this is no prblem.
If so, I have to think about other ways to get Layer from selected Objekt.
Here my Code-Snippet ....
Dim pcbNets, line, net, dist
Dim i, j, RealDist
Call pcbApp.Gui.StatusBarText("Get Netclasses Clearance... ", epcbStatusField3)
Set pcbNets = pcbDoc.Nets(epcbSelectSelected)
If pcbNets.count = 2 Then
'epcbClearancePad 2 Pad
'epcbClearancePlane 4 Plane
'epcbClearanceSMDPad 5 SMD Pad
'epcbClearanceTrace 1 Trace
'epcbClearanceVia 3 Via
For i = 1 to 5
For j = 1 to 5
Call pcbApp.Gui.StatusBarText("i=" & i & " j=" & j, epcbStatusField3)
If (i = 2 And j = 5) or (i = 5 And j = 2) Or (i = 5 And j = 5) Then
'this Clearance Type is not supported
dist = pcbDoc.Clearance.GetNetClearanceRuleByType( i, pcbNets(1), 1, j, pcbNets(2), 1, "(Master)", epcbUnitMM)
If len(dist) > 0 Then
RealDist = Dist
Line = pcbNets(1).NetClass & "(" & pcbNets(1).Name & ") <> " & pcbNets(2).NetClass & "(" & pcbNets(2).Name & ") : " & RealDist & "mm"
Call pcbApp.Gui.StatusBarText(Line, epcbStatusField3)
line = ""
select case pcbNets.count
line = "No net selected"
line = "only one net selected"
line = "too much nets (" & pcbNets.count & ") selected"
Call pcbApp.Gui.StatusBarText(Line, epcbStatusFieldError)
iCES provides exactly this functionality in Expedition without the need to write any automation. Select the two nets, and open the clearances bar. iCES displays the actual clearnace as well as the specific rule area, net classes and class to class rule for these nets.
that's correct. iCES can do this ... but is only available with DX-Designer. But we are using the good old Design Capture....
Yes, iCES could do that, but if you need a report that shows you the actual minimal distance between two traces you have to read this out with automation.
I did not find any other way ...