Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Add scales to list

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
jjorovi
485 Views, 6 Replies

Add scales to list

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)
)

 

6 REPLIES 6
Message 2 of 7
Ajilal.Vijayan
in reply to: jjorovi

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)
)

 

Message 3 of 7
jjorovi
in reply to: Ajilal.Vijayan

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.

Message 4 of 7
hmsilva
in reply to: jjorovi

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

EESignature

Message 5 of 7
jjorovi
in reply to: hmsilva

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)
)

 

Message 6 of 7
hmsilva
in reply to: jjorovi

You're welcome, jjorovi
Glad I could help

Henrique

EESignature

Message 7 of 7
hmsilva
in reply to: jjorovi

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

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost