.NET

Reply
Active Member
kaos73
Posts: 7
Registered: ‎10-01-2005
Message 1 of 10 (248 Views)

SendStringToExecute executed a the end of my command

248 Views, 9 Replies
12-09-2005 11:56 AM
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
Active Member
kaos73
Posts: 7
Registered: ‎10-01-2005
Message 2 of 10 (248 Views)

Re: SendStringToExecute executed a the end of my command

12-12-2005 06:54 AM in reply to: kaos73
I found a solution of my problem. I use acedInvoke with a DllImport.
Member
mkravo
Posts: 5
Registered: ‎12-19-2005
Message 3 of 10 (248 Views)

Re: SendStringToExecute executed a the end of my command

12-19-2005 05:58 AM in reply to: kaos73
will you share with us how did you do that?
Active Member
kaos73
Posts: 7
Registered: ‎10-01-2005
Message 4 of 10 (248 Views)

Re: SendStringToExecute executed a the end of my command

12-19-2005 06:02 AM 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.
Member
mkravo
Posts: 5
Registered: ‎12-19-2005
Message 5 of 10 (248 Views)

Re: SendStringToExecute executed a the end of my command

12-19-2005 06:24 AM in reply to: kaos73
thank you very much for your help, is it possible that you attach also your usage of invoke?
Active Member
kaos73
Posts: 7
Registered: ‎10-01-2005
Message 6 of 10 (248 Views)

Re: SendStringToExecute executed a the end of my command

12-19-2005 06:30 AM 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.
Member
mkravo
Posts: 5
Registered: ‎12-19-2005
Message 7 of 10 (248 Views)

Re: SendStringToExecute executed a the end of my command

12-19-2005 06:46 AM 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
Active Member
kaos73
Posts: 7
Registered: ‎10-01-2005
Message 8 of 10 (248 Views)

Re: SendStringToExecute executed a the end of my command

12-19-2005 07:08 AM 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
Member
mkravo
Posts: 5
Registered: ‎12-19-2005
Message 9 of 10 (248 Views)

Re: SendStringToExecute executed a the end of my command

12-19-2005 07:51 AM 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...
Active Member
kaos73
Posts: 7
Registered: ‎10-01-2005
Message 10 of 10 (248 Views)

Re: SendStringToExecute executed a the end of my command

12-19-2005 08:12 AM 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.

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
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

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

Ask the Community