Determining How to Call a Function
 
 
 

Once you identify the VLISP function you need, you still must determine how to call the function. You need to know the arguments to specify and the data type of those arguments. The ActiveX and VBA Reference contains the information required for coding calls to ActiveX functions.

For example, from the reference page for the Circle object, choose the AddCircle hyperlink to view the definition of this method:

Note that you can also get to this page by choosing the Methods button near the top of the Help window, then choosing AddCircle from a list of methods.

The syntax definitions in the reference were designed for Visual Basic 6 users, so they may take some getting used to. For AddCircle, the syntax is defined as follows:

RetVal = object.AddCircle(Center, Radius)

Substituting the variable names used in this chapter's examples, the syntax is:

mycircle = mspace.AddCircle(Center, Radius)

The AutoLISP syntax required for the same operation is:

(setq myCircle (vla-addCircle mSpace 
   (vlax-3d-point '(3.0 3.0 0.0)) 2.0))

The return value (RetVal, in Visual Basic 6) is straightforward. The ActiveX and VBA Reference defines this as a Circle object. In VLISP, whenever an AutoCAD object is returned by an ActiveX function, it is stored as a VLA object data type.

The object referred to before the method name (object.AddCircle) is always the first argument in a vla function call. This is the AutoCAD object you are viewing or modifying. For example, add a circle to the drawing model space with the following:

(vla-addCircle  mSpace ...)

In this example, mspace refers to the ModelSpace object. Recall from the discussion on the AutoCAD object model (in Accessing AutoCAD Objects), that you use the properties of one AutoCAD object to access another object in a hierarchical manner. The ModelSpace object provides access to the model space of the current drawing.

The Center and Radius arguments refer to data types that may be unfamiliar to LISP users. The following section explains these data types.

Note that some ActiveX methods require arguments that are described as output only. See Using ActiveX Methods That Return Values in Arguments for information on how to code these arguments.