commandline sendstringtoexecute

commandline sendstringtoexecute

Anonymous
Not applicable
1,805 Views
5 Replies
Message 1 of 6

commandline sendstringtoexecute

Anonymous
Not applicable

I have succesfully been using Tony Tanzillo's commandline class in AutoCAD 2010 projects for a while, mainly to purge a drawing, but I cannot get it to work in the following circumstances. It shows purge on the command line but nothing else:-

AutoCAD 2007

Comand run with and without CommandFlags.Session

Run from form modeless and modal

If the command is run from the command line it works and shows "No unreferenced blocks" etc.

I amguessing it is to do with teh form being "Active" so I have tried closing and disposing of the form befopre the conmmand and AppActivating the AutoCAD window.

If I debug it exits at "If Application.DocumentManager.IsApplicationContext Then  Return 0 End If".

Any ideas?

Regards

Dave

0 Likes
1,806 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

My first guess would be that you're missing a space after "purge" in the sendstringtoexecute command, without that the word will be on the commandline but it won't do anything. I'm not familiar with what PURGE does, but if you require additional input before something happens then you will need to specify that in the string as well.

I'm sure it would also be easier to see a bit more of your code, that'd help me/others understand whats going on better

Hope that helps a little!

~Andrew

0 Likes
Message 3 of 6

Anonymous
Not applicable

Thanks for the reply. This is true for SendStringToExecute but not the commandline class

 

0 Likes
Message 4 of 6

Anonymous
Not applicable

Command() can't be called from the application's execution context

(which is where code in modeless forms/palettes, and commands

that have the Session command flag run).

 

To solve the problem, define your own CommandMethod, that does

not include the CommandFlags.Session flag. In that method, you can

call CommandLine.Command() to do what you need.

 

From your modeless form, you can use SendStringToExecute()

to invoke your CommandMethod, but remember that no code that

follows the call to SendStrngToExecute() should depend on the

commands having already executed.

 

If you have code that must run after the command sequence

has finished, put that code in the same CommandMethod where

you call the Command() method, after calls to same.

 

0 Likes
Message 5 of 6

Anonymous
Not applicable

Many thanks cadzone, that fixed it.

At the end of purging and auditing I open a template and copy the contents of the original file into the new one and save it but I get a Drawing Busy error. I understand why so I have split the functions, 1 with sessionflags and 1 without and the user has to select both options from a form. I don't suppose there is a way around this?

0 Likes
Message 6 of 6

Anonymous
Not applicable

IT,s exactly what I'm experiencing ... trying to use commandline from a palette ..

 

How woul you define the CommandMethod that load the palette set ?

The palette set contains various functions entities edition and creation

 

note: the function that use commandline is within a button_click event

CommandMethod("DSPALXML")]

public static void DoIt()

{

....

 }

Thanks

---------------------------------------------------------------------------------

Command() can't be called from the application's execution context

(which is where code in modeless forms/palettes, and commands

that have the Session command flag run).

 

To solve the problem, define your own CommandMethod, that does

not include the CommandFlags.Session flag. In that method, you can

call CommandLine.Command() to do what you need.

----------------------------------------------------------------------------------

0 Likes