.NET

Reply
Contributor
Chumplybum
Posts: 25
Registered: ‎12-15-2003
Message 1 of 7 (243 Views)

Running a command synchronously...

243 Views, 6 Replies
11-07-2007 09:26 PM
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
Valued Contributor
pavlos.katsonis
Posts: 67
Registered: ‎09-12-2006
Message 2 of 7 (243 Views)

Re: Running a command synchronously...

11-07-2007 11:02 PM in reply to: Chumplybum
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.
*Tony Tanzillo
Message 3 of 7 (243 Views)

Re: Running a command synchronously...

11-08-2007 07:10 AM 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
*Tony Tanzillo
Message 4 of 7 (243 Views)

Re: Running a command synchronously...

11-08-2007 07:10 AM 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.
Valued Contributor
pavlos.katsonis
Posts: 67
Registered: ‎09-12-2006
Message 5 of 7 (243 Views)

Re: Running a command synchronously...

11-08-2007 09:18 AM in reply to: Chumplybum
I had a strictly managed environment in my mind, but you're right, using p/invoke is more 'straightforward'.
*Tony Tanzillo
Message 6 of 7 (243 Views)

Re: Running a command synchronously...

11-08-2007 06:33 PM 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'.
Contributor
Chumplybum
Posts: 25
Registered: ‎12-15-2003
Message 7 of 7 (243 Views)

Re: Running a command synchronously...

11-08-2007 07:36 PM in reply to: Chumplybum
thanks tony... it makes sense now, and it works

cheers

Mark

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