8 Replies Latest reply on May 23, 2012 7:08 AM by peter.kurlak

    Expedition PCB 2007: Find a branch in a net


      I am using Visual Basic Express 2010 and trying to find if there is a branch in a net, for example U1-1 (U1 pin 1) is connected to U2-2 (U2 pin 2) and U3-3 (U3 pin 3).  I need to get the trace length from U1-1 to brach location, and then from branch location to U2-2 and branch location to U3-3.

      In my current program, I can get the length from U1-1 to U2-2 or from U1-1 to U3-3, but I need to get the common trace between U1, U2, and U3.

      Does anyone have any code samples to show me how to do this?

        • 1. Re: Expedition PCB 2007: Find a branch in a net

          Get the trace collection between U1-1 and U2-2 and the trace collection between U1-1 and U3-3.  Compare the endpoint coordinates of each trace in the first collection with each endpoint coordinates of each trace in the second collection.  If the endpoints match, you've found your branch location.  You can then sort (if the traces aren't already sorted) the trace collections so that the traces go from one pin to the next.  Iterate through the sorted collections while incrementing a length variable until a trace's endpoint coordinate matches the branch coordinate.  Do this for all branches (U1-1 » branch, U2-2 » branch, U3-3 » branch) and you'll have the three branch lengths.  Does that make sense, haha?

          • 2. Re: Expedition PCB 2007: Find a branch in a net

            I agree that your solution covers all the cases for this issue, but I found a much easier solution for my case.


            In my current design, all branches are made at a via location, so I select the two pins (start and end) and get the vias collection object, then iterate thru the vias and check the number of connections for each via.  If number of connections is more than 2 then it is the branch point.  I use the brach point and U1-1 and find the trace length which is the common portion, then from brach point to either U2-2 or U3-3 and get the lengths for the branches.


            I am using "pcbDoc.ObjectsInBetween(object_1, object_2)".


            This will not work for all the cases (your solution is better), but solves my immediate need.  I will implement your solution when I get time.

            • 3. Re: Expedition PCB 2007: Find a branch in a net

              Hello Peter,


              I am trying to implement your algorithm, but I have toruble implementing it.  I use the following to get the trace collection between two pins and then itterate thru all the segments and get the trace length between two pins.  This works fine.

              pcbDoc As MGCPCB.IMGCPCBDocument

              TRACCOLL = pcbDoc.Components(...)
              segments = TRACCOLL.Count

              For j = 1 To segments
                  N1 = TRACCOLL.Item(j)
                  Tot_Len += N1.Length
              Next j


              The problem is how to find the common trace segments.  There is a "T" topology between U1, U2, and U3 so there is a common section (several trace segments) between "U1-1 to U2-2" and "U1-1 to U3-3".


              I listed the min and max extrema for each segments, but it does not exactly match with what I see on Expedition PCB editor.

              Do you have any other suggestions to solve this problem?  Is there any code sample that I review?



              • 4. Re: Expedition PCB 2007: Find a branch in a net

                Hey Marandi,


                Just so I understand your problem, is that what you're talking about?



                If so, then you have to realize that the common segments (U1 to branch location) might be more than 2 in the collection (even though it looks like only 2 segments in Expedition).  You have to loop through the segments until you find one that has an endpoint at exactly the branch location.  How do you know what the branch location is?  Well, if you loop through the segment collection between U1-U2 and U1-U3 and U3-U2, you'll find one point (X,Y) in all three collections.  That is the branch location.

                1 of 1 people found this helpful
                • 5. Re: Expedition PCB 2007: Find a branch in a net

                  Hello Peter,


                  Thanks for adding the picture.  That is exactly what I am referring to, except in some cases I have a via at the branch (junction) point.  For example, trace from U1 to U3 is on the same layer, but trace from U1 to U2 goes thru a via at the branch point and then another via to transition to the layer where U2 is.  U1, U2, and U3 are all on the top side.



                  I also need clarification on endpoints.  Does reading "extrema->MinX and extrema->MinY" OR "extrema->MaxX and extrema->MaxY" provide the endpoint information or I need to read another attribute?



                  • 6. Re: Expedition PCB 2007: Find a branch in a net



                    I'll have to do some experimenting to see how vias change things.


                    In the meantime, I find endpoints using trace.Geometry.PointsArray.  Here's an example from one of my programs:



                    For Each objTrace In objNet.Traces

                        pntsArr = objTrace.Geometry.PointsArray

                        For i = 0 To UBound(pntsArr, 2) - 1

                            ' GetSegment returns class "Segment" that has two points "A" and "B"

                            Set objSeg = GetSegment(pntsArr(0, i), _

                                                    pntsArr(1, i), _

                                                    pntsArr(0, i + 1), _

                                                    pntsArr(1, i + 1))




                    Hope this helps,


                    • 7. Re: Expedition PCB 2007: Find a branch in a net



                      I have added your code to my program (Visual Basic 2010), but it cannot resolve the "GetSegment" and "Segment" class.  I have refernced the following classes in my program:


                      Imports MGCPCB
                      Imports MGCPCB.GuiClass
                      Imports MGCPCB.TracesClass
                      Imports MGCPCB.DocumentClass
                      Imports MGCPCB.EPcbConductorGfxType


                      But "GetSegment" is not in any of them.  Is this part of the MGCPCB class or a VBA function?
                      Does objSeg contain the segment length, strting X,Y and ending X,Y?


                      Thanks for the help!

                      • 8. Re: Expedition PCB 2007: Find a branch in a net



                        objSeg of the "Segment" class can contain anything you want, as it's user-defined.  For one of my projects, my Segment class in pseudo-code looks like this:


                        class Segment {

                            constructor(pointAX, pointAY, pointBX, pointBY)

                            property Point PointA  // user-defined class "Point" with properties X, Y

                            property Point PointB

                            property double Width

                            property double Slope

                            property double Length

                            property int Layer

                            function Point GetPointAlongSeg(dist, height)



                        ....but, yours can contain whatever properties/methods you find helpful!  The point is to easily organize and manipulate the trace collection's PointsArray.  Without classes to abstract the data, working with raw coordinates is pretty tough!

                        1 of 1 people found this helpful