variable creation

variable creation

johnd
Contributor Contributor
366 Views
4 Replies
Message 1 of 5

variable creation

johnd
Contributor
Contributor

Not sure if my first post went through:

I"m looking for suggestions for the following:

I have a series of rectangles that I want to create variable name and assign an elevation value to it
as it passes through a loop.

Start loop:
Select rectangle 1, assign an elevation then create variable Rectang-1-elev.
Select rectangle 2, assign an elevation then create variable Rectang-2-elev.
etc, etc,

Then later in the routine use a loop to with those variables to do a computation.

Start loop:

Rectang-1-elev - a value from variable
Rectang-2-elev - a value from variable.
etc, etc,

I don't want to keep typing
(setq Rectang-1-elev 2500)
(setq Rectang-2-elev 2800)
etc. etc.
Since I don't know how many rectangles would be present when the routine is ran.

0 Likes
Accepted solutions (1)
367 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

[Yes, the first one went through -- see my Reply there.]

Kent Cooper, AIA
0 Likes
Message 3 of 5

john.uhden
Mentor
Mentor
Accepted solution

@johnd ,

Might I recommend using handles and a list?...

something like...

(while (setq e (car (entsel)))

  (setq Z (getreal "Enter Z value: "))

  (setq mylist (cons (list (cdr (assoc 5 (entget e))) Z) mylist))

)

So that mylist looks something like '(("abc123" 22.3)("abc124" 25.7) etc.) 

  (handle number)

Or ,if you prefer...

  (setq mylist (cons (cons (cdr (assoc 5 (entget e))) Z) mylist))

  (handle . number)

So that mylist looks something like '(("abc123" . 22.3)("abc124" . 25.7) etc.)

Then you can operate on the list whatever way you want.

Sorry, but I'm an old timer, so I often look at things decades past.

John F. Uhden

0 Likes
Message 4 of 5

Sea-Haven
Mentor
Mentor

John this is posted twice.

0 Likes
Message 5 of 5

john.uhden
Mentor
Mentor

@Sea-Haven ,

I hadn't noticed.  I have single vision.

John F. Uhden

0 Likes