Importing a Type Library
 
 
 

VLISP provides an AutoLISP function that allows you to import the type library of the ActiveX application you want to access. When you import a type library, AutoCAD creates a set of wrapper functions that provide access to the application's methods and properties. In fact, the vla- functions you have seen so far are wrapper functions created for the AutoCAD type library.

Use the vlax-import-type-library function to import a type library. When calling this function, identify the type library and tell AutoCAD what prefixes to use in naming the wrapper functions for the application's methods and properties. Also specify a prefix for the application's constants. The vlax-import-type-library function takes the following syntax:

(vlax-import-type-library :tlb-filename filename 
[ :methods-prefix mprefix:properties-prefix pprefix :constants-prefix cprefix])

The filename argument is a string that names the type library. If you do not specify a path, AutoCAD looks for the file in the support file search path.

The mprefix argument specifies the prefix to be used for method wrapper functions. For example, if the type library contains a Calculate method and the mprefix parameter is set to "cc-", AutoCAD generates a wrapper function named cc-Calculate. This parameter defaults to "".

The pprefix argument specifies the prefix to be used for property wrapper functions, and the cprefix argument defines the prefix to be used for constants contained in the type library. These parameters also default to "".

Note the required use of keywords when passing arguments to vlax-import-type-library. For example, the following code imports a Microsoft Word type library, assigning the prefix mswm- to methods, mswp- to properties, and mswc- to constants:

(if (equal nil mswc-wd100Words) ; check for a WinWord constant
  (vlax-import-type-library
	:tlb-filename "c:/Microsoft Office/Office/msword8.olb"
	:methods-prefix "mswm-"
	:properties-prefix "mswp-"
	:constants-prefix "mswc-"
  ) 
) 

After importing the type library, you can use the VLISP Apropos feature to list the ActiveX wrapper functions resulting from the import. For example, enter mswm in the Apropos Options dialog box and select the Match by Prefix option to list all Microsoft Word ActiveX methods.

Importing an application's type library enables you to use VLISP features such as Apropos on the application's properties and methods, but you can access the application even if you do not import its type library. See Using ActiveX without Importing a Type Library.