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

Repeat last command with sendStringToExecute in between.

3 REPLIES 3
Reply
Message 1 of 4
Nikome
990 Views, 3 Replies

Repeat last command with sendStringToExecute in between.

Greetings!

I use a net dll for some Macros. Problem is it also uses SendStringToExecute for some command chains. If you now repeat the last command with enter you will end up repeating the last command your programm sent instead of the programm itself.

Just some smal example:

Sub Makro_1()
Dim myDB As Database
Dim myDWG As ApplicationServices.Document
myDWG = ApplicationServices.Application.DocumentManager.MdiActiveDocument
myDB = myDWG.Database

myDWG.SendStringToExecute("_circle ", False, False, False)
myDWG.SendStringToExecute("3P ", False, False, False)
End Sub


Above random code also reminds me of the fact that if you put "^C^C_circle 3P " into a button, it won't be repeatable too.
Any clues?
3 REPLIES 3
Message 2 of 4
ranger4290
in reply to: Nikome

I know this is a very old thread, but I'll put the solution I know of here in case someone stumbles upon this post.

 

In the sendStringToExecute call, you need to set the commandEcho property (I think it's the last one) to true. That way it shows up on the commandline and will be there if enter is pushed (for repeating)

Message 3 of 4
Jeffrey_H
in reply to: ranger4290

Have you tried enclosing it in a transaction

You can also find your answers @ TheSwamp
Message 4 of 4
caddzone
in reply to: ranger4290

You mistunderstood the question.

 

The problem (one of many associated with using 'SendStringToExecute')

has always been that if a user presses ENTER afterwards, the command

that is started is not the last command the user entered, whcih is what the

user expects and what it should be. Instead, the command that runs is the

last command that was passed to SendStringToExecute(). Unfortunately

we have Autodesk people with blogs who actively promote and advocate

the use of these sorts of kludges (e.g., SendStringToExecute), and all that

ultimately does is lead to inferior solutions which those same advocates

seem to view as being 'good enough'.

 

The way to avoid the problem, is to avoid using SendStringToExecute()

to script AutoCAD commands.

 

For scripting AutoCAD commands from the application context, you can

define your own CommandMethod that P/Invokes acedCmd() (or use the

wrapper for it in my CommandLine.cs/vb files), and then you can use

SendStringToExecute() to run that CommandMethod.

 

That CommandMethod can be marked with the CommandFlags.NoHistory

bit, which prevents it from being re-issued if the user presses ENTER

after the call to SendStringToExecute(), and that will solve the probelm.

 

 



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


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