Create a list with 4 real numbers

Create a list with 4 real numbers

etilley327KA
Advocate Advocate
410 Views
6 Replies
Message 1 of 7

Create a list with 4 real numbers

etilley327KA
Advocate
Advocate

What am I doing wrong here? FC is a global variable from another lisp, with four blocks.

(defun c:wert (/ i e c cl)
(if (= (sslength fc) 4)
(progn
(repeat (setq i (sslength fc))
(setq e (ssname fc (setq i (1- i))))
(setq c (getpropertyvalue e "ELEV2"))
(setq cl (cons (rtos c 2 2) cl))
)
(print cl)
)
(prompt "\nMore than one form selected")
)
(princ)
);end

0 Likes
Accepted solutions (1)
411 Views
6 Replies
Replies (6)
Message 2 of 7

Kent1Cooper
Consultant
Consultant

Does an Attribute with the tag "ELEV2" exist in all the Blocks?

 

Is 'fc' a selection set, such as the code appears to be designed for, or perhaps a list of entity names instead?

 

Define "wrong."  What are you getting?  Are there any error messages?  Etc., etc.

Kent Cooper, AIA
0 Likes
Message 3 of 7

etilley327KA
Advocate
Advocate

FC is a selection set that all have the attribute "ELEV2". I get bad argument type: numberp: "156.20" : error#2. There are four strings "156.20" "156.18""156.16" "156.13".

0 Likes
Message 4 of 7

Kent1Cooper
Consultant
Consultant

If 'c' is an Attribute value, it's already a text string, so you can't apply (rtos) to it.  In your final 'cl' list, do you want them as text strings or as numbers?  Either way, if you want them to 2 decimal places, do they [or might they sometimes] have a different number of decimal places as Attribute values?

If, for example, you want them as strings without changing their number of decimal places, then this:

(setq cl (cons (rtos c 2 2) cl))

should be just:

(setq cl (cons c cl))

Kent Cooper, AIA
0 Likes
Message 5 of 7

etilley327KA
Advocate
Advocate

So how might I convert this selection set to real numbers?

0 Likes
Message 6 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

Read about the (atof) and possibly (distof) functions.

Kent Cooper, AIA
0 Likes
Message 7 of 7

etilley327KA
Advocate
Advocate

Didn't know about that, thanks.

0 Likes