Jump to content

Recommended Posts

Posted

Hi,

 

I'm a production team leader in a data conversion company. Here we have a task to rotate a text perpendicular to an existing line..

 

I will admit myself as a newbie in autocad lisp programing, So I searched for a lisp in Cadtutor and found the below lisp.

 

This lisp work exactly what I want except that this aligns the text parallel to the selected line.. But actually I need to rotate the text perpendicular to the selected line...

 

Can anyone rewrite this lisp as I required.

 

--------------------------------------------------------

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

)

 

)

(princ)

)

--------------------------------------------------------

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