Page tree
Skip to end of metadata
Go to start of metadata

Summary

There are a few tips that make wiring schematic elements together easier:

  1. Use the coordinates of the schematic element nodes as the wire connection points to ensure connections.

  2. Wire segments need to be orthogonal, trying to add non-orthogonal wires will fail.

  3. Wires added to a schematic cannot form a connectivity loop. Attempting to add wires that create a loop will fail.

Let's look at an example that adds some elements to a schematic and connects them with wires.

Code Snippets

 ' Code Module
Sub Main
     Dim schem As Schematic
     Dim elem1 As Element
     Dim elem2 As Element

     Set schem = Project.Schematics.Add("MySchematic")

     ' Add a couple of schematic elements.
     Set elem1 = schem.Elements.Add("MLIN", 0, 0)
     Set elem2 = schem.Elements.Add("MLIN", 2000, -2000, 90)


     ' Get connection point coordinates from element nodes
     x1 = elem1.Nodes(2).x
     y1 = elem1.Nodes(2).y

     x2 = elem2.Nodes(1).x
     y2 = elem2.Nodes(1).y

     ' Add two wire segments (must be orthogonal)
     schem.Wires.Add(x1, y1, x2, y1)
     schem.Wires.Add(x2, y1, x2, y2)
End Sub


In this code we start by adding a schematic named "MySchematic" to the project:

  Set schem = Project.Schematics.Add("MySchematic")
    

Next we add two schematic elements to the new schematic:

     ' Add a couple of schematic elements.
     Set elem1 = schem.Elements.Add("MLIN", 0, 0)
     Set elem2 = schem.Elements.Add("MLIN", 2000, -2000, 90)
     

The first element has node 1 located at x = 0, y = 0, with no rotation angle, the second one has node 1 located at x = 2000, y = -2000 and is rotated by an angle of 90 degrees. Next we use the element references to get the coordinates for the nodes we want to connect.

  ' Get connection point coordinates from element nodes
     x1 = elem1.Nodes(2).x
     y1 = elem1.Nodes(2).y

     x2 = elem2.Nodes(1).x
     y2 = elem2.Nodes(1).y

 

So here we want to connect node 2 of the first element to node 1 of the second element. When adding the wires we will add them in two segments, because one segment between to two coordinates would be non-orthogonal and the system would not accept the add wire request. Adding the wire segments is done through the wires collection on the schematic.

 ' Add two wire segments (must be orthogonal)
     schem.Wires.Add(x1, y1, x2, y1)
     schem.Wires.Add(x2, y1, x2, y2)


The resulting schematic looks like below:

Here we've used the node objects associated with the schematic to ensure the wires connect correctly and we've added two orthogonal segments to ensure that the wires will be accepted by the schematic object.