.NET

.NET

Reply
Valued Contributor
jta_albert
Posts: 75
Registered: ‎01-10-2006
Message 11 of 36 (1,033 Views)

Re: Wait for SendStringToExecute to complete

06-22-2009 12:37 PM in reply to: timbot
I do realize using the SendStringToExecute is not ideal, I am using it as a shortcut for now and hope to eventually do it the "right" way. I am also using SendStringToExecute with the Stretch and Copy commands for now. (Bascially trying to get the big picture of my project down before spending to much time on these things)

Either way, would be nice to see if this Event Handler method could work with my current situation.
*Tony Tanzillo
Message 12 of 36 (1,033 Views)

Re: Wait for SendStringToExecute to complete

06-22-2009 01:38 PM in reply to: timbot
While it's true that using the managed ObjectARX API does
require some learning, you are still able to use the same
ActiveX API you use in VBA, which means that you can do
the same things you do in VBA without much more difficulty.

Hence, what you call a 'shortcut' is really not that, because
you could have easily wrote ActiveX code to delete entities
in far less time than you've wasted on this very bad kludge,
that will only box you into a corner down the road.

Stretching is another matter, and it's not doable via ActiveX,
and is not easily scriptable via the command line because of
its dependence on the current view.

Well, if you insist on following the chief's bad advice, then
hopefully, you're doing this on your own dime, rather than
on company time. I don't think chief is going to compensate
you for losses that result from following his bad advice.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


wrote in message news:6206293@discussion.autodesk.com...
I do realize using the SendStringToExecute is not ideal, I am using it as a
shortcut for now and hope to eventually do it the "right" way. I am also
using SendStringToExecute with the Stretch and Copy commands for now.
(Bascially trying to get the big picture of my project down before spending
to much time on these things) Either way, would be nice to see if this Event
Handler method could work with my current situation.
Valued Contributor
jta_albert
Posts: 75
Registered: ‎01-10-2006
Message 13 of 36 (1,033 Views)

Re: Wait for SendStringToExecute to complete

06-22-2009 04:09 PM in reply to: timbot
Ok, I am pretty sure I understand how the EventHandler works, but not sure it will work for my situation as I need to pass an arraylist to the second command(not sure how you would do that...)

What do you think of this, kind of crazy but might work...

I will still have a "CommandComplete" command that is appeneded on to the SendStringToExecute, but have this command do something I can look for. Directly after my SendString command I will go into a loop and look for whatever "CommandComplete" does and proceed once I recognize it. (Probably just have it create a tmp file on disk)

What do you think?
Distinguished Contributor
NathTay
Posts: 1,691
Registered: ‎12-15-2003
Message 14 of 36 (1,033 Views)

Re: Wait for SendStringToExecute to complete

06-22-2009 04:33 PM in reply to: timbot
Are you saying the original solution posted by timbot is not a good one and if so can you explain why?
Valued Contributor
jta_albert
Posts: 75
Registered: ‎01-10-2006
Message 15 of 36 (1,033 Views)

Re: Wait for SendStringToExecute to complete

06-22-2009 06:02 PM in reply to: timbot
Ok, so I realize now that my SendString commands are not executed untill all my code is finished...

Hmm...
*Expert Elite*
chiefbraincloud
Posts: 753
Registered: ‎02-13-2008
Message 16 of 36 (1,032 Views)

Re: Wait for SendStringToExecute to complete

06-22-2009 06:02 PM in reply to: timbot
If the plan is to have one function like this:

Sub Whatever
'do stuff
SendStringToExecute()
Do
'nothing
Loop Until Commandcomplete
'do more stuff
End Sub

Then I think the SendStringToExecute will still be waiting to run. Essentially, your code must end, and return control back to the AutoCAD app, before the SendStringToExecute will fire.
Depending on what your arraylist contains, maybe you can temporarily store it in a dictionary for retrieval by the second command in the Event model.
Dave O.                                                                  Sig-Logos32.png
*Tony Tanzillo
Message 17 of 36 (1,034 Views)

Re: Wait for SendStringToExecute to complete

06-22-2009 07:18 PM in reply to: timbot
No, it's not a good solution, mainly because it attempts to solve
a problem that shouldn't exist in the first place, and only exists
as a result of not using the right tools for the job.

P/Invoking acedCommand() (as done by the CommandLine
class available from my website) eliminates the need to call
SendStringToExecute() to run AutoCAD commands, and with
that, eliminates the need to 'wait' for the commands to finish.

I've spoken at length about the problems associated with this
Autodesk-devised kludge, and you can read them here.

For example, what happens when a user presses enter to
repeat the last command *they* issued.

And then there's other issues like of undo grouping, and undoing
an entire command sequence as a whole; passing input that can't
be represented in string form (like objects) and so on.

Better yet, I'll just refer you to the assorted hacks/kludges that
you'll find on through-the-interface, which serve to demonstrate
what's wrong with automating AutoCAD by sending keystrokes
to the command line.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


wrote in message news:6206412@discussion.autodesk.com...
Are you saying the original solution posted by timbot is not a good one and
if so can you explain why?
Distinguished Contributor
NathTay
Posts: 1,691
Registered: ‎12-15-2003
Message 18 of 36 (1,034 Views)

Re: Wait for SendStringToExecute to complete

06-22-2009 07:29 PM in reply to: timbot
Thanks Tony. I have been fortunate with .NET (unlike VBA) not to be in the situation of having to send commands to the commandline. If I do get into that situation I will look into your CommandLine class.
Contributor
timbot
Posts: 15
Registered: ‎09-23-2008
Message 19 of 36 (1,034 Views)

Re: Wait for SendStringToExecute to complete

08-06-2009 12:51 PM in reply to: timbot
wow, didn't realize people were responding to my post, must have forgot to have it notify me or something... anyhow, the main reazon i made this was because of my horrible troubles i was having with zooming, and i didn't want to use the interop because i had problems when we upgraded... this was just a suggestion for people learning like me to get thru a problem... yeah, the big problem was with repeating the command or undoing... but, all my zooms work great! B) i'll have to read your post about the P/Invoking acedCommand thing, i just wish there was a better zoom function built into the .net api, then all of my problems would be solved, untill then perhaps i'll learn some better way... thanks for the rebuke!
Valued Contributor
jta_albert
Posts: 75
Registered: ‎01-10-2006
Message 20 of 36 (1,034 Views)

Re: Wait for SendStringToExecute to complete

08-06-2009 12:55 PM in reply to: timbot
Yep, thats bascially what I reliazed... (about the sendstring not executing untill later)

I would like to stay away from storing and jumping in and out of the code.

Do you know if there is any way to send to the command line and have it run in sync?
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.