seventy9mph Posted March 2, 2011 Posted March 2, 2011 Good day all, First post, please forgive me. I am looking for a LISP routine that will allow me to select text (and perhaps even better any objects), then ask if I want to rotate to an ABSOLUTE or RELATIVE angle. Currently the TORIENT is nice, but only does absolute rotation angle. I have looked and seen tons of lisps that rotate to either an absolute angle or exactly 180 degrees. Anything for user input relative angle? Thank you everyone for your time!!! I should have mentioned all rotation being around each text insertion point...thx Quote
Lee Mac Posted March 2, 2011 Posted March 2, 2011 Welcome to CADTutor Seventy9mph - I'm sure you'll like it here Give this a try: (defun c:trel ( / acdoc acsel ) (setq acdoc (vla-get-activedocument (vlax-get-acad-object))) (if (and (ssget "_:L" '((0 . "TEXT,MTEXT,INSERT"))) (setq *ang* (cond ( (getangle (strcat "\nSpecify Relative Angle" (if *ang* (strcat " <" (angtos *ang*) ">") "") ": " ) ) ) ( *ang* ) ) ) ) (progn (vlax-for obj (setq acsel (vla-get-ActiveSelectionSet acdoc)) (vla-put-rotation obj (+ (vla-get-rotation obj) *ang*)) ) (vla-delete acsel) ) ) (princ) ) Quote
seventy9mph Posted March 2, 2011 Author Posted March 2, 2011 WOW, great Lee, I really appreciate it! Thanks! Quote
Sittingbull Posted March 2, 2011 Posted March 2, 2011 Where there's a Lee, there's a way :wink:. Hello seventy9mph and welcome. Quote
irneb Posted March 5, 2011 Posted March 5, 2011 Or you could try mine: (defun c:Orient (/ ss ans obj) (or *ActiveDoc* (setq *ActiveDoc* (vla-get-activedocument (vlax-get-acad-object)))) (or *Orient:Angle* (setq *Orient:Angle* 0.0)) (while (and (progn (princ (strcat "\nRotating by " (if *Orient:Relative* "Relative" "Absolute" ) " angle.\n" ) ) (initget "Relative Absolute eXit") (setq ans (cond ((getangle (strcat "Specicy angle [Relative/Absolute/eXit] <" (angtos *Orient:Angle*) ">: "))) (*Orient:Angle*) ) ) ) (not (eq ans "eXit")) ) (cond ((eq ans "Relative") (setq *Orient:Relative* t)) ((eq ans "Absolute") (setq *Orient:Relative* nil)) ((setq ss (ssget "_:L" '((0 . "TEXT,MTEXT,INSERT")))) (setq *Orient:Angle* ans) (vlax-for obj (setq ss (vla-get-ActiveSelectionSet *ActiveDoc*)) (if *Orient:Relative* (vla-put-rotation obj (+ (vla-get-rotation obj) *Orient:Angle*)) (vla-put-rotation obj *Orient:Angle*) ) ) (vla-delete ss) (gc) ) ) ) (princ) ) Not much difference to Lee's. Only it allows Absolute (like TOrient) or Relative according to your choice. Quote
Lee Mac Posted March 5, 2011 Posted March 5, 2011 ([color=red](setq ss[/color] (ssget "_:L" '((0 . "TEXT,MTEXT,INSERT")))) (setq *Orient:Angle* ans) (vlax-for obj [color=red](setq ss[/color] (vla-get-ActiveSelectionSet *ActiveDoc*)) Apologies for nit-picking, but no need to 'setq' the 'ss' twice :wink: Quote
irneb Posted March 5, 2011 Posted March 5, 2011 (edited) I suppose it's not really necessary. I just wanted to get rid of the VLA ss version, since my code is inside a loop (note also the gc to get rid of the normal ss, so maybe the one negates the other's need). While it shouldn't matter, someone may use the code in a script, performing multiple repetitions one after another. And since there's a finite about of active selection sets available, this could cause errors. Given, it's a highly unlikely scenario in this case - it's always better to clean up selections when you've made them inside a loop. Edit: Sorry Lee ... I just realised what you meant! The 1ST setq isn't necessary! Edited March 5, 2011 by irneb Quote
seventy9mph Posted March 5, 2011 Author Posted March 5, 2011 Thank you Irneb, it will be nice to have the option for Relative or Absolute. Great Scott, these lisps are fantastic. Really appreciate it everyone! Quote
irneb Posted March 5, 2011 Posted March 5, 2011 You're welcome (even if you don't mean me). This is a great place aint it? Quote
Lee Mac Posted March 5, 2011 Posted March 5, 2011 Edit: Sorry Lee ... I just realised what you meant! The 1ST setq isn't necessary! No worries - I understand exactly how you first read my reply - many do question why the VL SelSet needs to be deleted Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.