MatthewDS Posted May 4, 2010 Share Posted May 4, 2010 I was having some trouble with a very simple setvar command in a lisp script, as such: (setvar "FIELDEVAL" "31"); which was giving me this error: AutoCADvariable setting rejected: "CMDECHO" nil It turns out that you cannot have quotes around the 31, and that it should have read: (setvar "FIELDEVAL" 31); This is fixed now I looked through my code and found places where I had used quotes to enclose variables, so maybe you can do it with some variables and not others? Does anybody have any input on this? For example, this seemed to work: (setvar "TEXTSTYLE" "Some-Style"); Hopefully this helps somebody in the future. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 4, 2010 Share Posted May 4, 2010 System Variables are of different data types whether it be Double, Integer, String, etc. A reference for these can be found using the System variable editor (Sysvdlg) in AutoCAD, or another reference such as this. As for the error you are receiving, that is due to an unlocalised error handler within a routine loaded on your system. Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 4, 2010 Share Posted May 4, 2010 The best policy for you error handler (after making sure it's localized) would be to check and make sure the the variable has a value before trying to set a variable with said value. eg. At some point in time in the routine. (setq OldCmdecho (getvar 'cmdecho)) In your error handler, you would check before trying to set with: (if OldCmdecho (setvar 'cmdecho OldCmdecho)) or (and OldCmdecho (setvar 'cmdecho OldCmdecho)) Both will check the variable before trying to set with it. There are other fancier ways, but these are the simplest. Quote Link to comment Share on other sites More sharing options...
MSasu Posted May 5, 2010 Share Posted May 5, 2010 To be able to ignore the data type of a system variable may use the below approach that will allow you to use only strings: [color=black](command "_SETVAR" "FIELDEVAL" "31")[/color] Regards, Quote Link to comment Share on other sites More sharing options...
jammie Posted May 5, 2010 Share Posted May 5, 2010 If you are unsure as to what type of value a system variable accepts you could use the TYPE function Command: (type (getvar "TEXTSTYLE")) STR Command: (type (getvar "filletrad")) REAL Command: (type (getvar "FIELDEVAL")) INT Command: (type (getvar "lastpoint")) LIST Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.