Need to end while loop on enter key/user input or other condition

Need to end while loop on enter key/user input or other condition

Anonymous
Not applicable
2,023 Views
5 Replies
Message 1 of 6

Need to end while loop on enter key/user input or other condition

Anonymous
Not applicable

Hi,

 

I'm currently working on a lisp routine (see below) that selects objects in order and saves the coordinates and rotation to the blackboard. So for object # you get xx#, yy# and r#. What happens at the moment is it goes through the loop fine (as far as I can tell), but then loops back to an entsel function, so if enter is pressed it crashes the routine. How do I format this code so I can select objects in order and press enter to end the while loop? Even better would be to avoid having to seperately select and hit enter for each object but I'm not sure how I'd structure that. Apologies in advance I'm really new to lisp.

Thanks

 

(vl-load-com)
(defun C:VPP (/ sx xv yv vv vvl)
	(setq sx 0)
	(while
		(setq sx (1+ sx))
		(setq vv (car (entsel)))
		(setq vvl (entget vv))
		(setq xv (rtos (car (cdr (assoc 10 vvl)))))
		(setq yv (rtos (car (cdr (cdr (assoc 10 vvl))))))
		(set (read (strcat "r" " (rtos sx)")) (rtos (cdr (assoc 50 vvl))))
		(set (read (strcat "xx" " (rtos sx)")) xv)
		(set (read (strcat "yy" " (rtos sx)")) yv)
	)
(princ)
)
0 Likes
Accepted solutions (1)
2,024 Views
5 Replies
Replies (5)
Message 2 of 6

cadffm
Consultant
Consultant
Accepted solution
(while (setq vv (car (entsel)))
(setq sx (1+ sx))
..
..
)

?

Sebastian

0 Likes
Message 3 of 6

Anonymous
Not applicable

That worked, thank you so much 🙂

0 Likes
Message 4 of 6

Anonymous
Not applicable

If anyone else sees this, I was also wondering how I could define the xx#, yy# and r# globally? I was using vl-bb-set (see below) but it seems it doesn't accept a function. So I'm not really sure how I could pass it a variable name without evaluating the strcat part within the vl-bb-set function. I could be totally misunderstanding this though.

Can make a new thread but I wasn't sure if it was bad etiquette or not

 

(vl-load-com)
(defun C:VPP (/ sx xv yv vv vvl)
	(setq sx 0)
	(while (setq vv (car (entsel)))
		(setq sx (1+ sx))
		(setq vvl (entget vv))
		(setq xv (rtos (car (cdr (assoc 10 vvl)))))
		(setq yv (rtos (car (cdr (cdr (assoc 10 vvl))))))
		(vl-bb-set '(read (strcat "r" " (rtos sx)")) (rtos (cdr (assoc 50 vvl))))
		(vl-bb-set '(read (strcat "xx" " (rtos sx)")) xv)
		(vl-bb-set '(read (strcat "yy" " (rtos sx)")) yv)
	)
(princ)
)

 

0 Likes
Message 5 of 6

scot-65
Advisor
Advisor
Blackboard is primarily used to transfer information from one DWG file
to another given the SDI = 0.
You are not stating if this is what you are trying to do?
If not, look into LIST to store the information.
If needed, and after creating the LIST, dump into the blackboard...

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 6 of 6

Anonymous
Not applicable

Hi,

Yeah the information this pulls needs to be accessed in other dwg files. Essentially to create a new set of drawings I have an xref with the placement of my viewports in model space. This routine will get the placement data of the viewport boundaries in order, then my other routine will take that info and use it to create a viewport on each page looking at the same spot.

0 Likes