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

Running a command synchronously...

6 REPLIES 6
Reply
Message 1 of 7
Chumplybum
875 Views, 6 Replies

Running a command synchronously...

hi all,

after reading every post i could find about using sendstringtoexecute and also regarding the use of Tony T's 'CommandLine.cs' class (thanks Tony)... i'm still not able to run a command synchronously, i guess the first thing is am i using the word synchronously correctly???
i'm after a way to pause / hold / wait for a command to finish before continuing on with my code (clean up code generally).

Attached (it seems that attributes don't get displayed correctly in IE) is the basic code in question using 6 different ways to call a command, so far i've been unable to get the dtext command to finish before the dialog gets displayed.


any help would be great

Cheers

Mark
6 REPLIES 6
Message 2 of 7

There is no direct way (that I know of) to execute a command synchronously. But you could use a reactor to be fired when your command finishes.
Message 3 of 7
Anonymous
in reply to: Chumplybum

The DTEXT command is a bit of an odd duck with
regards to synchronous execution.

What it basically does is looks at the command list
that it gets, and executes all of the input before it
goes into the state where the i-beam cursor appears
and you are able to type directly in the drawing.

So, because of that you have to supply all of the
command input that it asks for, to reach the point
where it displays the I-beam cursor, and you must
give it that in a single call to Command().

Try this LISP to see what i mean:

(defun C:TEST ()
(command "._dtext" pause "" "")
(alert "done")
)

Issue the TEST command, type a few lines of text
and press enter to exit text input, and you should
see the alert box after that.

Using the CommandLine class (in C#):

CommandLine.Command("_.DTEXT", "\\" "" "");

Note that where PAUSE works in LISP, a left-slash
has the same effect in C#.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5772395@discussion.autodesk.com...
hi all,

after reading every post i could find about using sendstringtoexecute and also regarding the use of Tony T's 'CommandLine.cs' class (thanks Tony)... i'm still not able to run a command synchronously, i guess the first thing is am i using the word synchronously correctly???
i'm after a way to pause / hold / wait for a command to finish before continuing on with my code (clean up code generally).

Attached (it seems that attributes don't get displayed correctly in IE) is t
he basic code in question using 6 different ways to call a command, so far i've been unable to get the dtext command to finish before the dialog gets displayed.


any help would be great

Cheers

Mark
Message 4 of 7
Anonymous
in reply to: Chumplybum

Not exactly sure what you mean by 'no direct way', but
it's quite a simple matter to P/Invoke acedCmd(), which
always executes command input synchronously, with
consideration for unusual/special conditions that may be
in effect, as is the case with the DTEXT command.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5772415@discussion.autodesk.com...
There is no direct way (that I know of) to execute a command synchronously. But you could use a reactor to be fired when your command finishes.
Message 5 of 7

I had a strictly managed environment in my mind, but you're right, using p/invoke is more 'straightforward'.
Message 6 of 7
Anonymous
in reply to: Chumplybum

I've never seen any good purpose served by religiously
constrining one's self to only managed code, especially
since a good part of the AutoCAD managed APIs merely
delegate to native code anyhow. Most of the real-world
apps I've built depend on native components that I had
to write in mixed-mode C++/CLI, in order to use parts
of the native API that aren't exposed to managed code.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5772958@discussion.autodesk.com...
I had a strictly managed environment in my mind, but you're right, using p/invoke is more 'straightforward'.
Message 7 of 7
Chumplybum
in reply to: Chumplybum

thanks tony... it makes sense now, and it works

cheers

Mark

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