Creating a route follows a procedure similar to that used when creating a schematic symbol. In this case we find the physical net in the PhysicalNets collection of the Layout object.

  1. Using the PhysicalNet.Routes.CreateRouteRecord() we create an instance of a RouteRecord object to hold the route shapes.

  2. Next we add segments that will make up the route connecting two points in the layout.

  3. Finally we call the PhysicalNet.Routes.AddRoute() method providing the RouteRecord object as the argument.

This will create a route with the specified segments and associate that route with the PhysicalNet object making it part of the connectivity for that Net. Because a route represents only a point-to-point connection, it may be necessary to create several routes to complete the connections between a set of pins. If so repeat the procedure outlined above to associate additional routes with the physical net. The case we'd like to handle looks like Figure 1

Figure 1 Net connection before adding route. Red flight-line shows area to be connected

Let's look at a routine to perform the steps outlined above:

 Sub AddRoute(ByRef physNet As PhysicalNet, ByRef fltLine As FlightLine)
        Dim dx, dy, x1, x2, y1, y2, w  As Double

        dx = fltLine.End.x - fltLine.Begin.x
        dy = fltLine.End.y - fltLine.Begin.y

        ' Create a route record
        Dim rtRecord As RouteRecord
        Set rtRecord = physNet.Routes.CreateRouteRecord()

        w = 20 * 1.0e-6
        x1 = fltLine.Begin.x
        x2 = fltLine.Begin.x + dx / 2
        y1 = fltLine.Begin.y
        y2 = fltLine.Begin.y

        ' Add segments to the route record
        rtRecord.AddSegment(x1, y1, x2, y2, w, 0, mwEST_TruncateEndStyle, 0 ,mwEST_ExtendedEndStyle, w / 2.0)
        x1 = x2
        y2 = fltLine.End.y
        rtRecord.AddSegment(x1, y1, x2, y2, w, 0, mwEST_ExtendedEndStyle, w / 2.0, mwEST_ExtendedEndStyle, w / 2.0)
        y1 = y2
        x2 = fltLine.End.x
        rtRecord.AddSegment(x1, y1, x2, y2, w, 0, mwEST_ExtendedEndStyle, w / 2.0, mwEST_TruncateEndStyle, 0)

        ' Add The route record to the physical net to create a route.
        physNet.Routes.AddRoute(rtRecord)
End Sub

 

The arguments to the routine are first the PhysicalNet with which we want to associate the Route and second the flight-line associated with that PhysicalNet we want to replace:

Sub AddRoute(ByRef physNet As PhysicalNet, ByRef fltLine As FlightLine)

 

Next we dimension some values to use for coordinates and determine the x and y distances between the flight line end points:

      Dim dx, dy, x1, x2, y1, y2, w  As Double

        dx = fltLine.End.x - fltLine.Begin.x
        dy = fltLine.End.y - fltLine.Begin.y

 

These values will be used as we compute the locations for the segments in the Route object. Next we use the PhysicalNet object's Routes collection to create the RouteRecord object.

      ' Create a route record
        Dim rtRecord As RouteRecord
        Set rtRecord = physNet.Routes.CreateRouteRecord()

 

The RouteRecord object will serve as a temporary container for the segments of the route until we are ready to create the actual route on the physical net. Now that we have a RouteRecord we can begin to compute the end points for the segments. First set a width value to be use for all segments of 20um. And for this case we'll make a three section route so the first segment will go horizontally in the positive X direction from the first end of the flight line to the middle of X distance between the ends of the flight line.

        w = 20 * 1.0e-6
        x1 = fltLine.Begin.x
        x2 = fltLine.Begin.x + dx / 2
        y1 = fltLine.Begin.y
        y2 = fltLine.Begin.y

 

We add this first segment with end styles such that the segment starts truncated and then ends with a half width extension. The half width extension will overlap the width of the next vertical segment when it is added.

      ' Add segments to the route record
        rtRecord.AddSegment(x1, y1, x2, y2, w, 0, mwEST_TruncateEndStyle, 0 ,mwEST_ExtendedEndStyle, w / 2.0)

 

For the next segment we just need to update a couple of values. First the x position will be at the end of the initial segment. The initial Y value is the same and the second y value will be equal to the y value at the end of the line. So with x1 = x2 and different Y values this will be a vertical segment which stretches from the flight line begin y to the flight line end y value. This time both ends will be half-width extended.

      x1 = x2
        y2 = fltLine.End.y
        rtRecord.AddSegment(x1, y1, x2, y2, w, 0, mwEST_ExtendedEndStyle, w / 2.0, mwEST_ExtendedEndStyle, w / 2.0)

 

Finally, we add the third segment which will be horizontal from the end of the vertical segment to the end of the flight line. So y1 gets updated to match y2 and we position the end x value an the flight line end x position. Here we added the values with the start end extended half width and the end truncated to be flush with the pin.

         y1 = y2
        x2 = fltLine.End.x
        rtRecord.AddSegment(x1, y1, x2, y2, w, 0, mwEST_ExtendedEndStyle, w / 2.0, mwEST_TruncateEndStyle, 0)

 

With this routine in place we can create a driver program to call it:

 ' Code Module
Sub Main
        Dim schem As Schematic
        Dim lay As Layout
        Dim physNet As PhysicalNet
        Dim fltLine As FlightLine
        Dim rtRec As RouteRecord

        Debug.Clear
        Set schem = Project.Schematics("Schematic 1")
        Debug.Print schem.Name

        Set lay = schem.Layout
        Debug.Print "PhysicalNets = " & lay.PhysicalNets.Count
        For Each physNet In lay.PhysicalNets
                For Each fltLine In physNet.FlightLines

                        ' Add Route to flight line area.
                        AddRoute physNet, fltLine

                Next fltLine
        Next physNet

End Sub
 

The results of running this program are shown in Figure 2. We get a three segment route connecting the two lines:

Figure 2 After routing flight-line replaced with three segment route.

So the three steps to create a Route are:

  1. Create a RouteRecord object using the Routes collection on the PhysicalNet the Route will be associated with.

  2. Add segments to the route record to form the route connecting two points.

  3. Create the route using the PhysicalNet.Routes.AddRoute() method.

Creating the Route on a PhysicalNet make the Route object part of the physical connectivity for that net and allows the route to replace the flight line. Or if it does not completely connect the points then it will be included in the connectivity and the flight-lines will connect not only the Pins but also the Route object.