tzframpton Posted September 8, 2016 Posted September 8, 2016 My code that I've had for a while (I wrote some of it, then someone else helped modify it on this forum years ago): (defun c:tst(/ varLst varVal *error*) ; **** ERROR HANDLER **** restore your variables in case of error or Esc (defun *error*(msg) ; restore your variables at once (mapcar 'setvar varLst varVal) ; print error message in command line (princ msg) ; silent exit (princ) ); end of *error* ; **** MAIN CODE **** ; store variables list (setq varLst(list "CLAYER" "CELTYPE" "CECOLOR" [color="red"]"CELWEIGHT"[/color]) ; get all variables at once varVal(mapcar 'getvar varLst) ); end setq ; set new variables values at once (mapcar 'setvar varLst (list "M-HVAC-TSTAT" "DASHDOT2" "3" [color="red"]"20"[/color])) ; invoke _spline command (command "_.spline") ; while command is active do pause for user input (while(= 1(getvar "CMDACTIVE")) (command pause) ); end while ; restore your variables at once (mapcar 'setvar varLst varVal) ; silent exit (princ) ); end of c:tst The code has always worked. I wanted to add a quick change to also include changing the object lineweight. The items I highlighted in Red is the only thing I added, then I receive this error: Command: TST AutoCAD variable setting rejected: "CELWEIGHT" "20" Any help would be appreciated, thanks! -TZ Quote
Lee Mac Posted September 8, 2016 Posted September 8, 2016 Hint: _$ (type (getvar 'celweight)) INT Quote
tzframpton Posted September 8, 2016 Author Posted September 8, 2016 Thanks for replying. What is INT? Is it returning as an Integer? Do I not have the right format? Sorry if this is a dumb question, just trying to follow. -TZ Quote
rkent Posted September 8, 2016 Posted September 8, 2016 Lee, are you saying the quotes should be left off because celweight is an integer? So 20 instead of "20" ? Quote
Dadgad Posted September 9, 2016 Posted September 9, 2016 Lee, are you saying the quotes should be left off because celweight is an integer? So 20 instead of "20" ? Tannar, I think rkent is on target there, lose the quotes and give it a try, what's to lose? Quote
tzframpton Posted September 9, 2016 Author Posted September 9, 2016 That worked!! Thanks for the tips gentlemen. Everything is working as expected. -TZ Quote
Lee Mac Posted September 9, 2016 Posted September 9, 2016 Sorry for the radio silence... What is INT? Is it returning as an Integer? Do I not have the right format? are you saying the quotes should be left off because celweight is an integer? So 20 instead of "20" ? lose the quotes and give it a try Bingo! That worked!! Thanks for the tips gentlemen. Everything is working as expected. -TZ Quote
BIGAL Posted September 10, 2016 Posted September 10, 2016 A quirky example set color "RED" is valid so is 1 in some situations. Quote
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.