ObjectARX

Reply
Member
Posts: 3
Registered: ‎08-16-2012
Message 1 of 6 (202 Views)

Executing code in document context from other document

202 Views, 5 Replies
08-16-2012 06:53 PM

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

ADN Support Specialist
Balaji_Ram
Posts: 609
Registered: ‎03-21-2011
Message 2 of 6 (182 Views)

Re: Executing code in document context from other document

08-20-2012 04:08 AM in reply to: Kari.Heinola

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.

 



Balaji
Developer Technical Services
Autodesk Developer Network

Member
Posts: 3
Registered: ‎08-16-2012
Message 3 of 6 (173 Views)

Re: Executing code in document context from other document

08-20-2012 11:13 AM in reply to: Balaji_Ram

I need reverse of executeInApplicationContext, like executeInDocumentContext, for synchronously running various code using acadCommand.

ADN Support Specialist
Balaji_Ram
Posts: 609
Registered: ‎03-21-2011
Message 4 of 6 (158 Views)

Re: Executing code in document context from other document

08-21-2012 07:04 AM in reply to: Kari.Heinola

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.



Balaji
Developer Technical Services
Autodesk Developer Network

Member
Posts: 3
Registered: ‎08-16-2012
Message 5 of 6 (152 Views)

Re: Executing code in document context from other document

08-21-2012 05:01 PM in reply to: Balaji_Ram

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

 

ADN Support Specialist
Balaji_Ram
Posts: 609
Registered: ‎03-21-2011
Message 6 of 6 (137 Views)

Re: Executing code in document context from other document

08-24-2012 05:52 AM in reply to: Kari.Heinola

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.

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community