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

Bail out of while

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
314 Views, 8 Replies

Bail out of while

I hafta say, this code really works well -- up to a point. (defun c:mr (/ pnt obj) ;MR.LSP - Move and Rotate at will (setq obj(entsel "\nSelect an object at the working point: ")) (setq pnt(cadr obj)) (while (princ "\nMOVE: ") (command "move" obj "" pnt pause) (setq pnt(cadr(grread 1 1))) (princ "\nRotate: ") (command "rotate" obj "" pnt pause) ) (princ)) My problem is, While what? What can I set up except that will terminate the sequence? If I hit at the MOVE: prompt the object disappears. But I don't want to have to answer a question at each cycle. rs --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.600 / Virus Database: 381 - Release Date: 2/28/2004
8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: Anonymous

(defun c:mr (/ pnt obj) ;MR.LSP - Move and Rotate at will (while (setq obj(entsel "\nSelect an object at the working point: ")) (princ "\nMOVE: ") (setq pnt(cadr obj)) (command "move" obj "" pnt pause) (setq pnt(cadr(grread 1 1))) (princ "\nRotate: ") (command "rotate" obj "" pnt pause) ) (princ)) "TCEBob" wrote in message news:405f35d3$1_1@newsprd01... > I hafta say, this code really works well -- up to a point. > > (defun c:mr (/ pnt obj) ;MR.LSP - Move and Rotate at will > (setq obj(entsel "\nSelect an object at the working point: ")) > (setq pnt(cadr obj)) > (while > (princ "\nMOVE: ") > (command "move" obj "" pnt pause) > (setq pnt(cadr(grread 1 1))) > (princ "\nRotate: ") > (command "rotate" obj "" pnt pause) > ) > (princ)) > > My problem is, While what? What can I set up except that will > terminate the sequence? If I hit at the MOVE: prompt the > object disappears. But I don't want to have to answer a question at each > cycle. > > rs > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.600 / Virus Database: 381 - Release Date: 2/28/2004 > >
Message 3 of 9
Anonymous
in reply to: Anonymous

Not exactly, Josh. I want to move and rotate until I am happy with the location. So the while belongs where it is. What I need is a method of getting out of the while without hitting or . Maybe I'd better read up on reactors? rs --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.600 / Virus Database: 381 - Release Date: 2/28/2004
Message 4 of 9
Anonymous
in reply to: Anonymous

"Maybe I'd better read up on reactors?" rs, your code is certainly cleaner, but I think this gets what you want. I can use this too. Thanks for the spark. BTW, I noticed the insertion point wandering with grread, so I switched it to getvar "lastpoint". I've not used grread for anything, so I'm not sure if it might have served some other purpose I'm missing. Thanks, -- James Allen Malicoat-Winslow Engineers, P.C. Columbia, MO (defun c:mr (/ obj pnt StopCurrentCommand) ;MR.LSP - Move and Rotate at will (command "undo" "begin") (setq obj (entsel "\nSelect an object at the working point: ")) (setq pnt (cadr obj)) (vl-load-com) ;; MR:RtClkNotify is the MouseRxr callback function (defun MR:RtClkNotify (calling-reactor commandInfo /) (setq StopCurrentCommand t) ) ;; Set a mouse reactor (setq MouseRxr (vlr-mouse-reactor nil (list '(:vlr-beginRightClick . MR:RtClkNotify)) ) ) ;; Basic loop (while (not StopCurrentCommand) (princ "\nMOVE: ") (command "move" obj "" pnt pause) (if (not StopCurrentCommand) (progn (setq pnt (getvar "lastpoint")) (princ "\nRotate: ") (command "rotate" obj "" pnt pause) ) ) ) ;; Abort and undo current Move command (command) (command "undo" "") ;; Remove reactor (vlr-remove MouseRxr) (command "undo" "end") (princ) )
Message 5 of 9
Anonymous
in reply to: Anonymous

Here is another version (even dirtier) that IMO makes the rotation part more intuitive. An error handler to clean up the temp block, reactor, and undo group in escape or true error situations would also be a good idea. James (defun c:mr (/ pnt obj StopCurrentCommand MouseRxr) ;MR.LSP - Move and Rotate at will (command "._undo" "begin") (setq obj (entsel "\nSelect an object at the working point: ")) (setq pnt (cadr obj)) (command "._block" "MyTemporaryBlock" pnt obj "") (vl-load-com) ;; MR:RtClkNotify is the MouseRxr callback function (defun MR:RtClkNotify (calling-reactor commandInfo /) (setq StopCurrentCommand t) ) ;; Set a mouse reactor (setq MouseRxr (vlr-mouse-reactor nil (list '(:vlr-beginRightClick . MR:RtClkNotify)) ) ) (command "._insert" "MyTemporaryBlock" "Scale" 1 pnt 0) (setq obj (entlast)) ;; Basic loop (while (not StopCurrentCommand) (princ "\nMOVE: ") (command "move" obj "" pnt pause) (if (not StopCurrentCommand) (progn (setq pnt (getvar "lastpoint")) (princ "\nRotate: ") (command "._rotate" obj "" pnt "reference" (/ (* (cdr (assoc 50 (entget obj))) 180) pi) pause ) ) ) ) (command) (command "._undo" "") (command "._explode" obj) (command "._purge" "block" "MyTemporaryBlock" "no") ;; Remove reactor (vlr-remove MouseRxr) (command "._undo" "end") (princ) )
Message 6 of 9
Anonymous
in reply to: Anonymous

Thank you, James! As you can tell, I've been striving for intuitive and minimal pesky prompts and user input. This routine is principally for text and mtext on topo drawings, which can get unbelievably dense. But should be handy everywhere. Clean code is to be desired (as we learned in Fortran in the '70s) but not at the expense of functionality. Here's the dream (Autodesk, take note!): Pick the object and a little circle appears at the pick point. Now the user picks: if he picks the little circle he can drag the object. If he picks anywhere else a temporary line appears and he can rotate the object. For me, 2-d is fine. But wouldn't it be cool to do this in 3-d, with solids? I like lastpoint, too, but I forgot it. The grread is pretty slick; strange that it wanders. There's only milliseconds between the completion of the move and the grread; not much time to move the mouse. rs "JamesA" wrote in message news:405f7ec5$1_1@newsprd01... > "Maybe I'd better read up on reactors?" > > rs, your code is certainly cleaner, but I think this gets what you want. I > can use this too. Thanks for the spark. > > BTW, I noticed the insertion point wandering with grread, so I switched it > to getvar "lastpoint". I've not used grread for anything, so I'm not sure > if it might have served some other purpose I'm missing. > > Thanks, > > -- > James Allen > Malicoat-Winslow Engineers, P.C. > Columbia, MO > > > (defun c:mr (/ obj pnt StopCurrentCommand) > ;MR.LSP - Move and Rotate at will > (command "undo" "begin") > (setq obj (entsel "\nSelect an object at the working point: ")) > (setq pnt (cadr obj)) > (vl-load-com) > ;; MR:RtClkNotify is the MouseRxr callback function > (defun MR:RtClkNotify (calling-reactor commandInfo /) > (setq StopCurrentCommand t) > ) > ;; Set a mouse reactor > (setq MouseRxr (vlr-mouse-reactor > nil > (list '(:vlr-beginRightClick . MR:RtClkNotify)) > ) > ) > ;; Basic loop > (while (not StopCurrentCommand) > (princ "\nMOVE: ") > (command "move" obj "" pnt pause) > (if (not StopCurrentCommand) > (progn > (setq pnt (getvar "lastpoint")) > (princ "\nRotate: ") > (command "rotate" obj "" pnt pause) > ) > ) > ) > ;; Abort and undo current Move command > (command) > (command "undo" "") > ;; Remove reactor > (vlr-remove MouseRxr) > (command "undo" "end") > (princ) > ) > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.600 / Virus Database: 381 - Release Date: 2/28/2004
Message 7 of 9
Anonymous
in reply to: Anonymous

Wait! How about this: Forget the little circle. User can drag the object from anywhere to anywhere just like the Move command (but no prompts). If user the mode toggles between move and rotate. 2 rt clicks for exit. Think I'll try it tomorrow. rs --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.600 / Virus Database: 381 - Release Date: 2/28/2004
Message 8 of 9
Anonymous
in reply to: Anonymous

Gee... This sounds alot like the functionality of grips back in R13... Click on a grip & it defaults to "stretch", right click & it moves, rt click & it rotates, & rt click if scales... You can do something similar in 2000i...(Although not as easily...) - Click on a grip - Press enter to cycle through possible commands (as mentioned above) The only problem is once you put it down where you want it, you have to pick the grip again to continue... "TCEBob" wrote in message news:405fdc63_1@newsprd01... > Wait! How about this: Forget the little circle. User can drag the object > from anywhere to anywhere just like the Move command (but no prompts). > If user the mode toggles between move and rotate. 2 rt > clicks for exit. > > Think I'll try it tomorrow. > > rs > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.600 / Virus Database: 381 - Release Date: 2/28/2004 > >
Message 9 of 9
Anonymous
in reply to: Anonymous

Thomas, Every time I think I know everything someone comes along and proves me wrong! Works great in 2004, too, complete with popup menu. I can go to my rest happy. Even with its restrictions (you can only use the object grip) it has more functionality than I could build in without a lot of work. Thanks for the tip Now I really do know everything. rs --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.600 / Virus Database: 381 - Release Date: 2/29/2004

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report