sds_setcallbackfunc

int sds_setcallbackfunc (int [int flag, void *arg1, void *arg2, void *arg3]);


IntelliCAD... call me at this function.


This function intercepts callbacks from IntelliCAD® 2001 commands and sends them to a specified function. For example, IntelliCAD sends a callback that it is going to erase an entity before doing so. This callback could be sent to the function specified by sds_setcallbackfunc..

The sds_setcallbackfunc function is unique to the implementation of SDS™ for IntelliCAD.

Example

Suppose you need to know whenever the ERASE command is used in IntelliCAD so that application-specific data can be stripped from entities before they are erased. You create a function named cbfunc to monitor callbacks from IntelliCAD so you can trap all uses of the ERASE command.

First, you would issue the following when your SDS application is loaded:

sds_setcallbackfunc(cbfunc);

From then on, all callbacks from IntelliCAD will pass through cbfunc. When the ERASE command is used in IntelliCAD, cbfunc will detect it, as in the following section of code:

int cbfunc(int flag,void *arg1,void *arg2,void *arg3)

{

int res = RTNORM;

switch (flag) {

// Command Start/End.

case SDS_CBCMDBEGIN:

// arg1="command name" cast as (char *)

// Callback return RTERROR will cause command to not be called.

// Any processing needed for the erase command goes here.

// For example, if you wanted to disable the erase command to

// prevent users from erasing entities, you could use the

// following code:

if (!stricmp(arg1, "erase"))

res = RTERROR;

break;

case default:

break;

}

return res;

}

As the comment above indicates, the callback return of RTERROR will cause the command not to be issued. This is because IntelliCAD broadcasted the fact that it is about to run the ERASE command. The program intercepted ERASE so a different action could be taken. If you wanted to know when the ERASE command had been completed, you could add a case for SDS_CBCMDBEGIN and compare the argument sent by IntellCAD to see if it is what you are looking for.

Tell me about...

Programming Overview of SDS™ (Solutions Development System™)