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

SendStringToExecute executed a the end of my command

9 REPLIES 9
Reply
Message 1 of 10
kaos73
658 Views, 9 Replies

SendStringToExecute executed a the end of my command

I would to like to call a function in Arx C++ that create entities
and just after I need to move them. For that, I created a command in .Net that call the Arx function with SendStringToExecute. The problem is, the function called by SendStringToExecute is executed when my command terminates, so I can not move the entities because does not exist yet.

Basically here is my code

[CommandMethod( "MyCommand")] _
Public Shared Function MyCommand()
acadDocument.SendStringToExecute( "(arx_function ""param1"" ""param2"" ) " )
MoveNewEntities()
End Function

How can I call an external function (Arx, Lisp) in a command without to wait the end of the command ?

Thank you
9 REPLIES 9
Message 2 of 10
kaos73
in reply to: kaos73

I found a solution of my problem. I use acedInvoke with a DllImport.
Message 3 of 10
mkravo
in reply to: kaos73

will you share with us how did you do that?
Message 4 of 10
kaos73
in reply to: kaos73

For sure, you will find an attached file with the c# class "aced" that call the "acedinvoke" method. I hope this will help you.
Message 5 of 10
mkravo
in reply to: kaos73

thank you very much for your help, is it possible that you attach also your usage of invoke?
Message 6 of 10
kaos73
in reply to: kaos73

I use invoke via vb.net. Here are some samples that call user defined arx function and autocad function.

' override with resultbuffer (user defined arx function)
Dim result as ResultBuffer
Dim args as New ResultBuffer()
args.Add( New TypedValue( Import.aced.valType.RTSTR, "my_arx_function" ) )
args.Add( New TypedValue( Import.aced.valType.RTSTR, "a string" ) )
args.Add( New TypedValue( Import.aced.valType.RTSHORT, 0 ) )
Dim ret as Integer = Import.aced.Invoke( args, result )

' override with string parameter array (autocad command "units")
Dim ret as Integer = Import.aced.Invoke( "command", "_.units", "2", "4", "1", "6", "0", "_N" )

Hope this help.
Message 7 of 10
mkravo
in reply to: kaos73

thank you very much one more time, but ai have one mor question: why is AcadApp.DocumentManager.IsApplicationContext condition always true and so always return just 0. What mean that is "IsApplicationContext"?

thank you for your time,
regards Mitja
Message 8 of 10
kaos73
in reply to: kaos73

All my invoked functions are in the document context. So I put this test to be sure that I never invoke them out of this context. But you, if you need to invoke functions in the application context you can remove this test.

regards,
Alex
Message 9 of 10
mkravo
in reply to: kaos73

tnx again, but i have one more question, im quite new in this things and i dont know when IsApplicationContext and when is documetn context, what should i do that IsApplicationContext will be false. Because if i delete this condition from your invoke function, still doesn not work. So i think that i have to switch to documetncontext or ... i dont know what .. help pleas

regards and thank you very munch again...
Message 10 of 10
kaos73
in reply to: kaos73

Me too, I am quite new in AutoCAD development and the only things I can say is :

registered command handlers run in the application context when they are registered with "CommandFlags.Session"
(see this post http://discussion.autodesk.com/thread.jspa?messageID=4881865 ).

My commands ARE NOT registered with the flag "Session" and works well.

But now, what kind of error occurs? Is it an exception ? What is the return value of the invoke method? What function are you invoking?

I encountered problems when I invoked some AutoCAD functions (for example: ssadd), and I needed to create an arx function to workaround this. I do not know, but it is possible that you can not invoke the function you want. Send me your code I could test it.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost