• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk ObjectARX

    Reply
    Member
    Posts: 3
    Registered: ‎08-16-2012

    Executing code in document context from other document

    159 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

    Please use plain text.
    ADN Support Specialist
    Balaji_Ram
    Posts: 358
    Registered: ‎03-21-2011

    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

    Please use plain text.
    Member
    Posts: 3
    Registered: ‎08-16-2012

    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.

    Please use plain text.
    ADN Support Specialist
    Balaji_Ram
    Posts: 358
    Registered: ‎03-21-2011

    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

    Please use plain text.
    Member
    Posts: 3
    Registered: ‎08-16-2012

    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

     

    Please use plain text.
    ADN Support Specialist
    Balaji_Ram
    Posts: 358
    Registered: ‎03-21-2011

    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

    Please use plain text.