Hello,
I have some old code using acedCommand and was looking to see how I can use the code without modifying it. The code needs to be executed synchronously from application context or from other document context. Is there any other option besides doing something like: Package the input data, then put it into queue and then use sendStringToExecute to execute command that reads the data from queue the data and calls the needed functions?
KH
Hi KH,
Have you tried using the "acDocManagerPtr()->executeInApplicationContext" ?
This will allow you to run a piece of code in the application context.
If this does not help, I suggest providing more details about what you are trying.
I need reverse of executeInApplicationContext, like executeInDocumentContext, for synchronously running various code using acadCommand.
If your requirement is to work on multiple documents, you can Application context command that can switch the active document based on which document it need to work on. Sorry, I dont see any other way to do it.
I don't understand what your trying to are saying here, except that I don't work on multiple documents. The other document context in my email was because even if our app only works with one specified document at th time, user might work on other document and issue command that should work on my document. .
Anyway, So I have code like the pseudo code below
TCHAR * func1 (args,...) {
// do something
status = acedCommand(RTSTR, _T("_.LINE"),RT3DPOINT,startPoint,RT3DPOINT,endPoint,RTSTR, _T(""), 0);
// do something
}
This code works when executed in documen context, but acedCommand failes with -5001 when above code is executed in application context.
The question is how I can call the code like func1 synchronously from application context?
KH
No, I dont see any way to make that code work on another document.
Instead of using acedCommand, if you implement your own Application context command, you will have more control on which document you are working with.