acedCommand() problems

acedCommand() problems

Anonymous
Not applicable
634 Views
6 Replies
Message 1 of 7

acedCommand() problems

Anonymous
Not applicable
Why would something as simple as this crash AutoCAD
(all releases I've tried, 2000-2002):

void myfunc()
{
ads_point center;
acedGetPoint(NULL, "\nEnter a point: ", center);
acedCommand(RTSTR, "._CIRCLE", RT3DPOINT, center, RTNONE);
}

void InitApplication()
{
AddCommand("TEST_GROUP", "TEST", "TEST", ACRX_CMD_MODAL, myfunc);

}


The code starts the CIRCLE command, supplies the
center point, and then drops the user off at the
prompt for the radius and, KABOOM.
0 Likes
635 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
Tony,

Your command is wrong.
There are two options:

// Create a circle with a predefined radius
acedCommand(RTSTR, "._CIRCLE", RT3DPOINT, center,RTREAL , 1.0, RTNONE);

// Create a circle with user interaction
acedCommand(RTSTR, "._CIRCLE", RT3DPOINT, center,RTSTR, PAUSE, RTNONE);

You must PAUSE for user input.
To do this pass the two codes: (RTSTR,PAUSE)

Regards,
Fernando.

"Tony Tanzillo" wrote in message
news:[email protected]...
> Why would something as simple as this crash AutoCAD
> (all releases I've tried, 2000-2002):
>
> void myfunc()
> {
> ads_point center;
> acedGetPoint(NULL, "\nEnter a point: ", center);
> acedCommand(RTSTR, "._CIRCLE", RT3DPOINT, center, RTNONE);
> }
>
> void InitApplication()
> {
> AddCommand("TEST_GROUP", "TEST", "TEST", ACRX_CMD_MODAL, myfunc);
>
> }
>
>
> The code starts the CIRCLE command, supplies the
> center point, and then drops the user off at the
> prompt for the radius and, KABOOM.
>
>
>
>
>
>
0 Likes
Message 3 of 7

Anonymous
Not applicable
Using acedCommand() from within a command registered via addCommand() is
always risky. The problem in this case is that an entity creation operation
is is still in progress when acedCommand() returns. When acedCommand()
returns, it completes a cycle of AutoCAD's main command loop. Part of this
loop does cleanup to make sure AutoCAD is in a certain state. But, in your
case AutoCAD is still inside an active command ("TEST"), so the cleanup has
problems that cause a crash.

If your function was registered via acedDefun() rather than addCommand(),
then what you are doing should work because acedDefun'd functions are not
treated the same as built-in commands, so you don't have a true "command
nesting" situation.

"Tony Tanzillo" wrote in message
news:[email protected]...
> Why would something as simple as this crash AutoCAD
> (all releases I've tried, 2000-2002):
>
> void myfunc()
> {
> ads_point center;
> acedGetPoint(NULL, "\nEnter a point: ", center);
> acedCommand(RTSTR, "._CIRCLE", RT3DPOINT, center, RTNONE);
> }
>
> void InitApplication()
> {
> AddCommand("TEST_GROUP", "TEST", "TEST", ACRX_CMD_MODAL, myfunc);
>
> }
>
>
> The code starts the CIRCLE command, supplies the
> center point, and then drops the user off at the
> prompt for the radius and, KABOOM.
>
>
>
>
>
>
0 Likes
Message 4 of 7

Anonymous
Not applicable
Thanks.

The problem is that acedDefun()/acedRegFun() does not
seem to work when called from any place, other than
from within a call to acrxEntryPoint().

For that matter, getting addCommand() to work from the
application context (in a COM server) involves a mega
kludge.


"Art Cooney" wrote in message
news:[email protected]...
> Using acedCommand() from within a command registered via addCommand() is
> always risky. The problem in this case is that an entity creation
operation
> is is still in progress when acedCommand() returns. When acedCommand()
> returns, it completes a cycle of AutoCAD's main command loop. Part of
this
> loop does cleanup to make sure AutoCAD is in a certain state. But, in
your
> case AutoCAD is still inside an active command ("TEST"), so the cleanup
has
> problems that cause a crash.
>
> If your function was registered via acedDefun() rather than addCommand(),
> then what you are doing should work because acedDefun'd functions are not
> treated the same as built-in commands, so you don't have a true "command
> nesting" situation.
>
> "Tony Tanzillo" wrote in message
> news:[email protected]...
> > Why would something as simple as this crash AutoCAD
> > (all releases I've tried, 2000-2002):
> >
> > void myfunc()
> > {
> > ads_point center;
> > acedGetPoint(NULL, "\nEnter a point: ", center);
> > acedCommand(RTSTR, "._CIRCLE", RT3DPOINT, center, RTNONE);
> > }
> >
> > void InitApplication()
> > {
> > AddCommand("TEST_GROUP", "TEST", "TEST", ACRX_CMD_MODAL, myfunc);
> >
> > }
> >
> >
> > The code starts the CIRCLE command, supplies the
> > center point, and then drops the user off at the
> > prompt for the radius and, KABOOM.
> >
> >
> >
> >
> >
> >
>
>
0 Likes
Message 5 of 7

Anonymous
Not applicable
Would the ACRX_CMD_NONEWSTACK flag bit make a difference here?

Also, what is the ACRX_CMD_NOMADIC flag for?

"Art Cooney" wrote in message
news:[email protected]...
> The problem in this case is that an entity creation operation
> is is still in progress when acedCommand() returns. When acedCommand()
> returns, it completes a cycle of AutoCAD's main command loop. Part of
this
> loop does cleanup to make sure AutoCAD is in a certain state. But, in
your
> case AutoCAD is still inside an active command ("TEST"), so the cleanup
has
> problems that cause a crash.
0 Likes
Message 6 of 7

Anonymous
Not applicable
Commands registered with ACRX_CMD_NONEWSTACK cannot call acedCommand().

ACRX_CMD_NOMADIC was used during AutoCAD 2000 development, but its use was
removed from AutoCAD's code before AutoCAD 2000 shipped.

"Tony Tanzillo" wrote in message
news:[email protected]...
> Would the ACRX_CMD_NONEWSTACK flag bit make a difference here?
>
> Also, what is the ACRX_CMD_NOMADIC flag for?
>
> "Art Cooney" wrote in message
> news:[email protected]...
> > The problem in this case is that an entity creation operation
> > is is still in progress when acedCommand() returns. When acedCommand()
> > returns, it completes a cycle of AutoCAD's main command loop. Part of
> this
> > loop does cleanup to make sure AutoCAD is in a certain state. But, in
> your
> > case AutoCAD is still inside an active command ("TEST"), so the cleanup
> has
> > problems that cause a crash.
>
>
>
0 Likes
Message 7 of 7

Anonymous
Not applicable
...
0 Likes