When an ObjectARX application receives a kLoadDwgMsg request from AutoCAD, it must define all of its external functions by calling acedDefun() once for each function. The acedDefun() call associates the external function's name (passed as a string value) with an integer code that is unique within the application. The integer code must not be negative, and it cannot be greater than 32,767 (in other words, the code is a short integer).
The following call to acedDefun() specifies that AutoLISP will recognize an external function called doit in AutoLISP, and that when AutoLISP invokes doit, it passes the function code zero (0) to the ObjectARX application:
acedDefun("doit", 0);
The string that specifies the name of the new external function can be any valid AutoLISP symbol name. AutoLISP converts it to all uppercase and saves it as a symbol of the type Exsubr.
External functions are defined separately for each open document in the MDI. The function gets defined when the document becomes active. For more information, see The Multiple Document Interface.
As in AutoLISP, the new function can be defined as an AutoCAD command by prefixing its name with “C:” or “c:”, as shown in the following example:
acedDefun("C:DOIT", 0);
In this case, DOIT can now be invoked from the AutoCAD Command prompt without enclosing its name in parentheses.
Functions defined as AutoCAD commands can still be called from AutoLISP expressions, provided that the “C:” prefix is included as a part of their names. For example, given the previous acedDefun() call, the AutoCAD user could also invoke the DOIT command as a function with arguments:
Command: (c:doit x y)