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"" ) " )
How can I call an external function (Arx, Lisp) in a command without to wait the end of the command ?
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" )
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"?
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.
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
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.