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

Mtext Rotate To Line

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
zootango
5989 Views, 5 Replies

Mtext Rotate To Line

Anyone have a lisp routine that will rotate Mtext to the same angle as the angle of a selected line and the allow you to place the mtext object where you wish.

 

I know there is an lisp out there called RTL that will allow you to do this with regular or Dtext, but I will not work with Mtext.

5 REPLIES 5
Message 2 of 6
Ajilal.Vijayan
in reply to: zootango

Try this.

 

I modified the code from here

http://www.cadtutor.net/forum/showthread.php?11844-rotate-text-to-align-line&s=15f9ebab58e8b768ffd9f...

 

;;  Text Rotated to the selected object angle
(defun c:TRA() (c:TextRotate2Angle))

(defun c:TextRotate2Angle (/ ss lst pt ang obj
                  get_pt_and_angle )
  (vl-load-com)


  ;;  User selection of curve object
  ;;  return pick point & average angle of curve at pick point
  (defun get_pt_and_angle (prmpt / ent p@pt parA parB pt ang)
    (if (and (setq ent (entsel prmpt))
             (not (vl-catch-all-error-p
                    (setq pt (vl-catch-all-apply
                               'vlax-curve-getClosestPointTo
                               (list (car ent) (cadr ent))
                             )
                    )
                  )
             )
        )
      (progn
        (setq ent  (car ent)
              p@pt (vlax-curve-getParamAtPoint ent pt)
              parA (max 0.0 (- p@pt 0.05))
              parB (min (+ p@pt 0.05) (vlax-curve-getEndParam ent))
              ang (angle (vlax-curve-getPointAtParam ent parA)
                         (vlax-curve-getPointAtParam ent ParB)
                  )
        )
        (list pt ang)
      )
    )
  )

  
  ;;  Get Text to align & object to alignment angle
  ;;  Text is not moved, just rotated to the alignment angle
  ;;  Object must have curve data
  (prompt "\nSelect text object to align.")
  (if (and (or (setq ss  (ssget "_+.:E:S" '((0 . "Text,Mtext"))))
               (prompt "\n**  No Text object selected.  **"))
           (or (setq lst (get_pt_and_angle "\nSelect point on object to label."))
               (prompt "\n**  Missed or no curve data for object."))
       )
    (progn
      (setq pt  (car lst)
            ;; ang (FixTextAngle (cadr lst))
            ang (cadr lst)
            obj (vlax-ename->vla-object (ssname ss 0))
      )
      (vla-put-rotation Obj ang)
	  (vla-put-InsertionPoint Obj (vlax-3D-point pt))
    )
    
  )
  (princ)
)

 

Message 3 of 6
zootango
in reply to: Ajilal.Vijayan

Thanks ajilal, just what I needed.

Message 4 of 6
bhull1985
in reply to: zootango

Please click the "Accept as solution" button if your issue was solved by the post.

Just lets the browsers know what needs to be worked on still and what's already been finished.

Plus it gives ajilal a little bit of recognition for producing the code for you to use.. 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 5 of 6
FSJ_Mo
in reply to: bhull1985

you can use the "TORIENT" command, I have an alias of rt (rotate text) set in my pgp file.

Message 6 of 6
dcasciano3
in reply to: FSJ_Mo

True solution right here. LISP for something so straightforward? come on!

Though, I must assume it didn't work with MTEXT as stated, back in 2013.

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

Post to forums  

Autodesk Design & Make Report

”Boost