ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Starting an AutoCAD command from ObjectARX

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
bakerrl2
2509 Views, 2 Replies

Starting an AutoCAD command from ObjectARX

Is it possible in ObjectARX 2015 to start an AutoCAD command from an ARX program and then allow AutoCAD to finish it?

 

In the past I could use acedCommand to start the Insert command, provide the block name and scale and then exit the ARX command.  At that point AutoCAD would take over and prompt the user for the rest of the Insert command values and insert the block.

 

I could try to use the new acedCommandC function but I hate to create the necessary callback function when it isn't really going to do much.

 

Could I use the AcApDocManager::sendStringToExecute function instead?

 

If not, could you offer any other suggestions?

 

Here is an example of the function using ObjectARX 2010.  Note: BVGetInput is a wrapper class for the various Get functions.

int InsFig()

{   short status;

    TCHAR blockName[133];

    ads_real scale;

   ads_point pt1;

 

   BVGetInput input;

   input.setPrompt(_T("Block name"));

   do

   {

      status = input.getstring(blockName);

      if (status == RTERROR)

         return RSERR;

   } while (blockName[0] == 0);

 

   input.initialize();

   input.setPrompt(_T("Insertion point"));

   input.setInputOptions(RSG_NONULL);

   input.getpoint(pt1);

 

   input.initialize();

   input.setPrompt(_T("Scale"));

   input.setDefault(1.0);

   input.getreal(&scale);

 

   acedCommand(RTSTR, _T(".INSERT"), RTSTR, blockName, RT3DPOINT, pt1, RTREAL, scale, 0);

   if (blockName[0] != _T('*'))

      acedCommand(RTSTR, _T(""), 0);

 

   acedRetVoid();

   return RSRSLT;

}

2 REPLIES 2
Message 2 of 3
philippe.leefsma
in reply to: bakerrl2

There is no other way to handle it, that why acedCommandC is provided.

 

Check on our blog, we have several articles about it:

 

http://adndevblog.typepad.com/autocad/2014/04/migration-after-fiber-is-removed-in-autocad-2015.html

 

http://adndevblog.typepad.com/autocad/2014/05/recognising-cancel-when-using-acedcommandc.html

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
bakerrl2
in reply to: philippe.leefsma

I found a way to make it work.  If I change the calls to acedCommand to the following code I was able to start the Insert command and allow both AutoCAD and the user to finish the Insert command.

 

CString csCmdStr;

 

csCmdStr.Format(_T(".-INSERT %s\n%lf,%lf,%lf\n%lf\n"), blockName, pt1[X], pt1[Y], pt1[Z], scale);

  

if (blockName[0] != _T('*'))

      csCmdStr += _T("\n");

 

acDocManager->sendStringToExecute(acDocManager->curDocument(), csCmdStr, false, true);

 

Basically, this code built the command string, sent it to the current document and then exited the function.  At that point, AutoCAD executed the Insert command using the information I provided and prompted the user to supply the remaining information.

 

Note: I verified that the function (insfig) used to start the Insert command was only being called from a pull-down menu option.  As a result, it should function without any problems since no other functions are called after the InsFig function.  I imagine that if this function had been called from an AutoLisp program instead of a menu it probably would not have worked correctly.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost