Using Lists

A drawback of using automation is that calls between the applications are relatively slow. To ensure that your scripts run quickly it is important to reduce the number of calls between the applications. Maxsurf uses list objects, which provide a means of accessing and manipulating the properties of a number of objects in a single statement. List objects are similar to collections in that they store a number of objects in an array. However, list objects can store an arbitrary group of objects while collections store all the instances of a particular type of object. An example of this is the Surfaces collection, which provides a reference to all the Surfaces in a design. An arbitrary subset of these surfaces can be stored using the SurfaceList object.

 

Both the Markers and Surfaces collections in Maxsurf have corresponding list objects, MarkerList and SurfaceList. List objects have a number of common properties and methods for manipulating their content. These are summarised in the tables below.

 

Property

Type

Description

Count

Long

Read Only. Returns a number of items in list.

Name (surfaceList only)

Variant

Set/Get the Names of Surfaces in the list

Type (surfaceList only)

msSurfaceType

Set/Get the type of surface for surfaces in the list

 

Method

Returns

Description

Add

 

Add items to the list.

Clear

 

Remove all items from the list.

Item

Object

Returns item in list.

Remove

 

Remove items from the list.

 

The behaviour and use of these properties are described in detail in the following sections. Each list object also has a number of properties that it inherits from the objects it contains.

 

These properties are either accessed individually through the Item method of the List, or as a complete list, through properties native to that list, such as the Name property of SurfaceList. For example, the SurfaceList object can be used to access all the surface types using the Type property. Alternatively, the type of a single surface can be returned using the item(i) method.

    sList.Type

    sList.Item(1).Type

 

All the properties of a Surface or Marker can be accessed individually, using the Item method, through the SurfaceList or MarkerList objects respectively.

 

Further details regarding lists are included in the following sections of this chapter.

§   Declaring Lists

§   List Properties

§   List Methods