Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Members of the collection can be accessed several ways. When you type "Project.Schematics(", Intellisense says it is looking for a Variant. Assuming the project has one schematic, called "Amp", the following code accesses the schematic:

...

Code Block
languagevb
 Project.Schematics(1)

...


Project.Schematics("Amp")

 

 

Using either method, we now have a handle on a specific member of the collection and the Intellisense reflects the methods/properties available at that level:

...

One very convenient feature offered by this arrangement is the ability to assign a shortcut to an object as it is created. The following code:

Code Block
languagevb
Dim el  as Element
 Dim sc  As Schematic
 
 Set sc = Project.Schematics.Add( "mySch")
 Set el = sc.Elements.Add( "RES",0,0,0, False)
el.Parameters( "R").ValueAsDouble = 10

 

As the new schematic is created, it's assigned to sc (which must be dimensioned as an appropriate object), eliminating the need to type "Project.Schematics("mySch") from that point forward. Similarly, el is assigned to the new element. Without these shortcuts, the last line of code would look like this:

...

Code Block
languagevb
 Project.Schematics("mySch").Elements( "RES.R1").Parameters( "R").ValueAsDouble = 10
 

Beyond the likelihood of a typo, the first method produces code that is much easier to read.