SendStringToExecute method problem

SendStringToExecute method problem

Yonas89
Collaborator Collaborator
1,975 Views
2 Replies
Message 1 of 3

SendStringToExecute method problem

Yonas89
Collaborator
Collaborator

Hello, 

I'm trying to run a DIMLAYER command on AutoCAD. After I put a layer name it does not execute. 

I run this line: 

 Application.DocumentManager.MdiActiveDocument.SendStringToExecute("._DIMLAYER 0 ", True, False, False)

but I end up with this: 

Capture.PNG

 

 Also, I tried to use Editor.command method, bet all i get is einvalidInput error.

Application.DocumentManager.MdiActiveDocument.Editor.Command("DIMLAYER", "0", "")
0 Likes
Accepted solutions (1)
1,976 Views
2 Replies
Replies (2)
Message 2 of 3

_gile
Consultant
Consultant
Accepted solution

Hi,

 

DIMLAYER is a system variable, you should use the Application.SetSystemVariable() method insted.

Application.SetSystemVariable("DIMLAYER", "0");

 

With SendStringtoExecute, as the command line is a string and the last command options (the layer name) is a string which may contain spaces, you have to validate the option with a newline character.

doc.SendStringToExecute("_.DIMLAYER 0\n", false, false, true);

With Editor.Command, you do not need to validate the layer name option with "".

ed.Command("_.DIMLAYER", "0");

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 3

Yonas89
Collaborator
Collaborator

@_gile, thanks a lot for your reply. This was killing me... "\n" in sendStringtoExecute method did not help as I was still seeing "0\n" in the command line.  Ed.command method also still gives me einvalid input error. However using application.setsystemvariable method has worked!. Thank you so much! 

0 Likes