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

Summary

The key to getting elements directly connected together in a schematic is to place them such that the nodes of the schematic symbol overlap one another. To do this use the coordinates from the node of an existing element to place the next element that is to be connected. This will ensure that the coordinates at which the element is placed match the coordinates of the node on the existing element to which you want to connect. Lets look at an example of creating a small two port schematic by placing elements such that they will be directly connected.

Code Snippets

 ' Code Module
Sub Main
     Dim schem As Schematic
     Dim elem1 As Element, elem2 As Element, elem3 As Element
     Dim elem4 As Element, elem5 As Element

        ' Add a schematic
     Set schem = Project.Schematics.Add("MySchematic")

     ' Add horizontal lead-in element
     Set elem1 = schem.Elements.Add("MLIN", 0, 0)

     ' Add vertical element at node 2 of the horizontal segment
     Set elem2 = schem.Elements.Add("MLIN", elem1.Nodes(2).x, elem1.Nodes(2).y, -90)

     ' Ground end
     schem.Elements.Add("GND", elem2.Nodes(2).x, elem2.Nodes(2).y)

     ' Add horizontal element
     Set elem3 = schem.Elements.Add("MLIN", elem1.Nodes(2).x, elem1.Nodes(2).y)

     ' Add verticle element
     Set elem4 = schem.Elements.Add("MLIN", elem3.Nodes(2).x, elem3.Nodes(2).y, -90)

     ' Ground end
     schem.Elements.Add("GND", elem4.Nodes(2).x, elem4.Nodes(2).y)

     ' Add lead-out element
     Set elem5 = schem.Elements.Add("MLIN", elem3.Nodes(2).x, elem3.Nodes(2).y)

     ' Add input/output port
     schem.Elements.Add("PORT", elem1.Nodes(1).x, elem1.Nodes(1).y)
     schem.Elements.Add("PORT", elem5.Nodes(2).x, elem5.Nodes(2).y, 180)
End Sub

 

We start by adding a new schematic to the Project named "MySchematic".

         ' Add a schematic
     Set schem = Project.Schematics.Add("MySchematic")


Next we place an initial element with its first node at the location x = 0, y = 0.

' Add horizontal lead-in elementSet elem1 = schem.Elements.Add("MLIN", 0, 0)


Since no angle is specified this element will placed with a rotation angle of 0 degrees which is horizontal for a MLIN element. Next we add a vertical MLIN element to node 3 of the first horizontal element. Note we use the reference elem1 obtained when we placed the first element to get the coordinates of the 2nd node on this element and then use this as the placement coordinates for the verticle element.

       ' Add vertical element at node 2 of the horizontal segment
     Set elem2 = schem.Elements.Add("MLIN", elem1.Nodes(2).x, elem1.Nodes(2).y, -90)

     ' Ground end
     schem.Elements.Add("GND", elem2.Nodes(2).x, elem2.Nodes(2).y)


Likewise when we add the round to the vertical MLIN element we use the reference elem2 to get the coordinates for the second node of the vertical element to ensure the GND element will be correctly connected.

Next we add an center horizontal element to the second node of the original element we placed using the elem1 reference to get the coordinates of the second node again.

       ' Add horizontal element
     Set elem3 = schem.Elements.Add("MLIN", elem1.Nodes(2).x, elem1.Nodes(2).y)


Following this, we add a second verticle segment and gound the end.

       ' Add verticle element
     Set elem4 = schem.Elements.Add("MLIN", elem3.Nodes(2).x, elem3.Nodes(2).y, -90)

     ' Ground end
     schem.Elements.Add("GND", elem4.Nodes(2).x, elem4.Nodes(2).y) 


And then a lead-out MLIN element.

       ' Add lead-out element
     Set elem5 = schem.Elements.Add("MLIN", elem3.Nodes(2).x, elem3.Nodes(2).y) 


Finally to make this a complete 2-port circuit we add input and output ports to the 1st node of the lead-in element and the 2nd node of the lead-out element.

       ' Add input/output port
     schem.Elements.Add("PORT", elem1.Nodes(1).x, elem1.Nodes(1).y)
     schem.Elements.Add("PORT", elem5.Nodes(2).x, elem5.Nodes(2).y, 180) 


The resulting circuit is shown here:

Notice how the green squares or circles appear at all the element nodes indicating connected elements. The key to getting the connections is to use the node coordinates for an existing element to place the next connecting element.