Jump to content

Recommended Posts

Posted

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

Posted

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)
)

Posted

WOW, great Lee,

I really appreciate it!

Thanks!

Posted

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.

Posted
     ([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:

Posted (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! :sweat: The 1ST setq isn't necessary!

Edited by irneb
Posted

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!

Posted

You're welcome (even if you don't mean me). This is a great place aint it?

Posted
Edit: Sorry Lee ... I just realised what you meant! :sweat: 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 :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...