Collection Class

Topic

Detail

Link

General Usage

This is the main collection Class used by all elements within the Automation Interface. It contains methods to iterate through the collection, refresh the collection and delete an item from the collection. It is important to realize that when AddNew is called, the item is not automatically added to the current collection. The typical steps are:

  • Call AddNew to add a new item
  • Modify the item as required
  • Call Update on the item to save it to the database
  • Call Refresh on the collection to include it in the current set

Delete is much the same; until Refresh is called, the collection still contains a reference to the deleted item, which should not be called.

Each can be used to iterate through the collection for languages that support this type of construct.

 

Collection Attributes

Attribute

Type

Notes

Count

Short

Read only. The number of objects referenced by this list.

ObjectType

ObjectType

Read only. Distinguishes objects referenced through a Dispatch interface.

Collection Methods

Method

Type

Notes

See Also

AddNew (string Name, string Type)

Object

Adds a new item to the current collection.

Note that the interface is the same for all collections; you must provide a Name and Type argument. What these are used for depends on the actual collection member. Also note that you must call Update() on the returned object to complete the AddNew. If Update() is not called the object is left in an indeterminate state.

Parameters:

  • Name: String
  • Type: String (up to 30 characters long)

 

Delete (short index)

Void

Deletes the item at the selected reference.

Parameters:

  • index: Short

 

DeleteAt (short index, boolean Refresh)

Void

Deletes the item at the selected index. The second parameter is currently unused.

Parameters:

  • index: Short
  • Refresh: Boolean

 

GetAt (short index)

Object

Retrieves the array object using a numerical index. If the index is out of bounds, an error occurs.

Parameters:

  • index: Short

 

GetByName (string Name)

Object

Gets an item in the current collection by Name.

If the collection does not contain any items, the method returns a null value. If the collection contains items, but it was unable to find an object with the specified name, the method raises an exception.

Only supported for the following collections: Model, Package, Element, Diagram, and element TaggedValue.

Parameters:

  • Name: String

Package Class

Element Class

Diagram Class

TaggedValue Class

GetLastError ()

String

Returns a string value describing the most recent error that occurred in relation to this object.

This function is rarely used as an exception is thrown when an error occurs.

 

Refresh ()

Void

Refreshes the collection by re-querying the model and reloading the collection. Should be called after adding a new item or after deleting an item.