Help please!
I need to modify the code below.
When I run the command and write the scale, I need to change the name of the scale and the ratio automatically.
The ratio should always be in the format "1: #", also the name of the scale.
Maybe assigning more varibales with "setq", I do not know.
Any suggestions?
(defun c:test () (setvar "cmdecho" 0) (setq name (getint "\nType the scale you need:")) (setq ratio (strcat "1:" "0.1")) (command "-SCALELISTEDIT" "Add" name ratio "Exit") (setvar "cmdecho" 1) (princ) )
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Like this ?
(defun c:test () (setvar "cmdecho" 0) (setq name (getint "\nType the scale you need:")) (setq ratio (strcat "1:" (itoa name))) (command "-SCALELISTEDIT" "Add" ratio ratio "Exit") (setvar "cmdecho" 1) (princ) )
It works well, but my work units are in meters.
For example, if I write the scale of 1:100, the ratio should be 1:0.1 (name/1000)
I can not find the correct function to do this.
Thanks for responding.
maybe something like this
(defun c:test ( / name) (setq name (getint "\nType the scale you need >>> 1:")) (if name (progn (setvar "cmdecho" 0) (command "-SCALELISTEDIT" "Add" (strcat "1:"(itoa name)) (strcat "1:" (rtos (/ name 1000.))) "Exit") (setvar "cmdecho" 1) );; progn );; if (princ) )
HTH
Henrique
Excellent. Two days trying to make the lisp. Still much to learn.
At the end I included the variable CANNOSCALE to set the new scale.
Thank you very much
(defun c:test ( / name) (setq name (getint "\nType the scale you need >>> 1:")) (if name (progn (setvar "cmdecho" 0) (command "-SCALELISTEDIT" "Add" (strcat "1:"(itoa name)) (strcat "1:" (rtos (/ name 1000.))) "Exit") (setvar "cmdecho" 1) );; progn );; if (setvar "CANNOSCALE" (strcat "1:"(itoa name))) (princ) )
setting the CANNOSCALE outside from the if, may generate an error if name is nil
this way will be better
(defun c:test ( / name) (setq name (getint "\nType the scale you need >>> 1:")) (if name (progn (setvar "cmdecho" 0) (command "-SCALELISTEDIT" "Add" (strcat "1:"(itoa name)) (strcat "1:" (rtos (/ name 1000.))) "Exit") (setvar "CANNOSCALE" (strcat "1:"(itoa name))) (setvar "cmdecho" 1) );; progn );; if (princ) )
Henrique