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

Wait for SendStringToExecute to complete

35 REPLIES 35
Reply
Message 1 of 36
timbot
5917 Views, 35 Replies

Wait for SendStringToExecute to complete

I figured out a method to wait for the SendStringToExecute to complete. It's similar to using a WebService, i send my command and subscribe to an event and complete my function when the command completes.



What i did was make a command that raises an event so i can just append that command onto any of my SendStringToExecute's

{color:#0000ff}

Public Event{color} eCommandComplete {color:#0000ff}As{color} EventHandler

<CommandMethod({color:#ff0000}"CommandComplete"{color})> _

{color:#0000ff}Sub{color} CommandComplete()

{color:#0000ff}RaiseEvent{color} eCommandComplete({color:#0000ff}Nothing{color}, {color:#0000ff}Nothing{color})

{color:#0000ff}End Sub



{color}Then my other command goes like



<CommandMethod({color:#ff0000}"SomeCommand"{color}> _

{color:#0000ff}Sub{color} SomeCommand()

{color:#339966}'Do Some Work

{color}{color:#0000ff}AddHandler{color} eCommandComplete, {color:#0000ff}AddressOf{color} SomeCommand

SendStringToExecute({color:#ff0000}"Zoom E CommandComplete "{color}, {color:#0000ff}False{color}, {color:#0000ff}False{color}, {color:#0000ff}False{color})

{color:#000000}{color:#0000ff}End Sub

{color}{color}{color:#0000ff}

Sub{color} SomeCommand({color:#0000ff}ByVal{color} sender {color:#0000ff}As Object{color}, {color:#0000ff}ByVal{color} e {color:#0000ff}As EventArgs{color})

{color:#339966}'Do Some other Work

{color}{color:#0000ff}End Sub{color}
35 REPLIES 35
Message 21 of 36
Anonymous
in reply to: timbot

I believe COM's SendCommand will do what you want if you call it from an
application context command.
See:
http://discussion.autodesk.com/forums/message.jspa?messageID=6215733#6215733


--
James Allen
Malicoat-Winslow Engineers, P.C.
Columbia, MO



jta_albert wrote:
> 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?
>
Message 22 of 36
Anonymous
in reply to: timbot

http://www.caddzone.com/CommandLine.cs

--
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:6232893@discussion.autodesk.com...
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?
Message 23 of 36
Anonymous
in reply to: timbot

Oh yeah, I'd start with Tony's class/method unless you need application
context.

--
James Allen
Malicoat-Winslow Engineers, P.C.
Columbia, MO



James Allen wrote:
> I believe COM's SendCommand will do what you want if you call it from an
> application context command.
> See:
> http://discussion.autodesk.com/forums/message.jspa?messageID=6215733#6215733
>
>
> --
> James Allen
> Malicoat-Winslow Engineers, P.C.
> Columbia, MO
Message 24 of 36
timbot
in reply to: timbot

Ok, a few questions about the thing i found on your web site. I've been trying to get autocad to zoom to a specific point based on what item is selected in a palette i'm making. the problem is that when i send my command it's .IsApplicationContext = True and returns 0. when i remove that code the command goes thru but nothing happens... i'm confused, it's returning like -5001 or something. but i can't find much information on the .IsApplicationContext = True or the code -5001. any help would be greatly appreciated!
Message 25 of 36
Anonymous
in reply to: timbot

From what code are you calling it? A floating palette or modeless form?

--
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:6233264@discussion.autodesk.com...
Ok, a few questions about the thing i found on your web site. I've been
trying to get autocad to zoom to a specific point based on what item is
selected in a palette i'm making. the problem is that when i send my command
it's .IsApplicationContext = True and returns 0. when i remove that code the
command goes thru but nothing happens... i'm confused, it's returning
like -5001 or something. but i can't find much information on the
.IsApplicationContext = True or the code -5001. any help would be greatly
appreciated!
Message 26 of 36
jalbert300
in reply to: timbot

Thanks Tony, the CommandLine.cs was exactly what I needed.

Not sure I udnerstand how it works though...
Message 27 of 36
timbot
in reply to: timbot

floating palette
Message 28 of 36
jalbert300
in reply to: timbot

Turns out I do need application context(or "CommandFlags.Session") if thats what you mean.

Does this not work in "Session" mode?

If not is there another way in "Session"mode?

Jon
Message 29 of 36
jalbert300
in reply to: timbot

Hey Tony,

I ran into a problem using Commanline.cs in ApplicationContext.

Any help on using the command line in sync while in ApplicationContext(or "CommandFlags.Session" if I understand correctly)

Thanks,

Jon
Message 30 of 36
Anonymous
in reply to: timbot

Hi Jon,

Yes, that's what I meant, in which case COM's SendCommand should work.

See my first reply to you, one up from the one you replied to, and the
thread it links to for more details.

--
James Allen
Malicoat-Winslow Engineers, P.C.
Columbia, MO



jta_albert wrote:
> Turns out I do need application context(or "CommandFlags.Session") if thats what you mean.
>
> Does this not work in "Session" mode?
>
> If not is there another way in "Session"mode?
>
> Jon
>
Message 31 of 36
jalbert300
in reply to: timbot

Thanks, I did figure that out after more reading.

So everything is working how it should now and my commands are running in sync.
Message 32 of 36
Anonymous
in reply to: timbot

You're welcome. I'm glad you got it working.

Do keep Tony's suggestion from your other thread in mind for future
reference though, i.e. chaining document and application context
commands. It's a bit more work to do the sequencing like that, but
might be worth it if you develop a need to avoid COM or pass data which
is not sufficiently represented by strings.

--
James Allen
Malicoat-Winslow Engineers, P.C.
Columbia, MO



jta_albert wrote:
> Thanks, I did figure that out after more reading.
>
> So everything is working how it should now and my commands are running in sync.
>
Message 33 of 36
jalbert300
in reply to: timbot

Hey James,

Maybe off topic, but I am now getting this error at the end of a sub after using SendCommand.

"Could not load file or assembly 'VerticalTips, Culture=neutral' or one of its dependencies. The system cannot find the file specified."

Any help?
Message 34 of 36
jalbert300
in reply to: timbot

I am only getting this error 25% of the time at best...
Message 35 of 36
Anonymous
in reply to: timbot

I'm sorry, I don't know what that is.

--
James Allen
Malicoat-Winslow Engineers, P.C.
Columbia, MO



jta_albert wrote:
> Hey James,
>
> Maybe off topic, but I am now getting this error at the end of a sub after using SendCommand.
>
> "Could not load file or assembly 'VerticalTips, Culture=neutral' or one of its dependencies. The system cannot find the file specified."
>
> Any help?
>
Message 36 of 36
davidcpreston
in reply to: Anonymous

Hi Tony (or anybody else that knows),

 

I have been using your commandline class for some time and it has proved very useful thanks, but I am having trouble getting it to work for a poyline. I have read all of the information I can find but still struggling.

 

From a click event on a modeless form I want the user to be able to draw a polyline, then on completion update the form with it's area. I have tried commandline.command("_pline") from the event in the form, called a CommandMethod that calls commandline.command("_pline") both with and without CommandFlags.Session but it doesn't pause for input and continues to the following code.

 

Is this possible and if so, how should I do 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