Share

acedDefun

C++

int acedDefun(
    const ACHAR * pszName, 
    int nFuncNum
);

File

acedads.h

Description

Defines an ARX application function as an external AutoLISP function and clears any existing acedSetFunHelp() reference.

Once a function in an ARX application has been defined by a call to acedDefun(), it can be called from AutoLISP. When AutoLISP sends an kInvkSubrMsg message to the application, the funcno for the function can be retrieved by a call to acedGetFunCode(), and any arguments can be retrieved by a call to acedGetArgs(). As in AutoLISP, if the first characters of sname are C:, you can invoke the function as an AutoCAD command without enclosing its name in parentheses. You can invoke it also as a function, provided that the prefix C: is included as part of its name.

Warning If two or more external applications define functions that have the same name, AutoLISP can recognize only the most recently defined external function. The previously loaded function will be lost.

The acedSetFunHelp() function is usually called directly after acedDefun() to register command line help for the defined function.

AutoLISP saves function and command names in uppercase characters, but if pszName is lowercase, acedDefun() converts it before passing it to AutoLISP. AutoLISP binds functions defined by acedDefun() to the Exsubr symbol type.

Warning If the application defines a C:XXX command whose name conflicts with a built-in command or with a command name defined in the acad.pgp file, AutoCAD does not recognize the external function as a command (though it can still be invoked as an AutoLISP external function). For example, after the call to acedDefun("c:cp", 0), a user input of cp invokes the AutoCAD COPY command (this alias is defined in the sample acad.pgp), but the user could invoke the external function with (c:cp).

Function names defined by acedDefun() can be undefined by calling acedUndef(). This removes the function name from the AutoLISP atom list. After a function has been undefined, an attempt to invoke it causes an error.

If acedDefun() succeeds, it returns RTNORM; otherwise, it returns an error code.

Parameters

Parameters Description
pszName String that invokes the function from AutoLISP
nFuncNum Non-negative number used to identify the function in subsequent kInvkSubrMsg messages from AutoLISP

Previous Declaration

int acedDefun(

const ACHAR * pszName,

short nFuncNum

);

Was this information helpful?