Jump to content

Align Text


SurveyCAD85

Recommended Posts

Hi

 

We use this lisp to align single line text to a line, by sellecting the line, then the text.

 

It works perfectly for our needs however we would like to add to the Lisp to allow it to select multiple text items not just one.

 

Is anyone able to assist

 

;--------------------------------------------------------

;lisp program...............................aligntxt.lsp

;

; aligns text to a line

;

;---------------------------------------------------------

(defun c:at (/ LINE ED SP EP A2 TEXT ED2)

 

(setq LINE (entsel "\n Choose line: \n")

ED (entget (car LINE))

SP (cdr (assoc 10 ED))

EP (cdr (assoc 11 ED))

A2 (angle SP EP)

TEXT (entsel "\n Choose text: \n")

ED2 (entget (car TEXT))

AT (cdr (assoc 50 ED2))

ED2 (subst

(cons 50 A2)

(assoc 50 ED2)

ED2)

)

(entmod ED2)

 

(prompt "\n \n")

(princ)

)

 

Link to comment
Share on other sites

You just need a ssget for the text and a repeat, added the pline option.

 

;--------------------------------------------------------
;lisp program...............................aligntxt.lsp
;
; aligns text to a line
;
;---------------------------------------------------------
; modified by Alan H to allow plines 

(defun c:at (/ ent pt1 pt2 ang ss tobj 

(setq ent (entsel "Select line or pline section"))
(setq objname (cdr (assoc 0 (entget (car ent)))))
(if (=  objname  "LWPOLYLINE")
(progn
(setq pr (vlax-curve-getparamatpoint (car ent) (setq p (vlax-curve-getclosestpointto (car ent) (cadr ent)))))
(setq pt1 (vlax-curve-getpointatparam (car ent) (fix pr)))
(setq pt2 (vlax-curve-getpointatparam (car ent) (1+ (fix pr))))
)
)
(if (=  objname  "LINE")
(progn
(setq pt1 (cdr (assoc 10 (entget (car ent)))))
(setq pt2 (cdr (assoc 11 (entget (car ent)))))
)
)
(setq ang (angle pt1 pt2))
(setq ss (ssget (list (cons 0 "*text"))))
(repeat (setq x (sslength ss))
(setq tobj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(vla-put-rotation tobj ang)
)

(prompt "\n \n")
(princ)
)

Link to comment
Share on other sites

You just need a ssget for the text and a repeat, added the pline option.

 

;--------------------------------------------------------
;lisp program...............................aligntxt.lsp
;
; aligns text to a line
;
;---------------------------------------------------------
; modified by Alan H to allow plines 

(defun c:at (/ ent pt1 pt2 ang ss tobj 

(setq ent (entsel "Select line or pline section"))
(setq objname (cdr (assoc 0 (entget (car ent)))))
(if (=  objname  "LWPOLYLINE")
(progn
(setq pr (vlax-curve-getparamatpoint (car ent) (setq p (vlax-curve-getclosestpointto (car ent) (cadr ent)))))
(setq pt1 (vlax-curve-getpointatparam (car ent) (fix pr)))
(setq pt2 (vlax-curve-getpointatparam (car ent) (1+ (fix pr))))
)
)
(if (=  objname  "LINE")
(progn
(setq pt1 (cdr (assoc 10 (entget (car ent)))))
(setq pt2 (cdr (assoc 11 (entget (car ent)))))
)
)
(setq ang (angle pt1 pt2))
(setq ss (ssget (list (cons 0 "*text"))))
(repeat (setq x (sslength ss))
(setq tobj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(vla-put-rotation tobj ang)
)

(prompt "\n \n")
(princ)
)

 

Thank you!!!

Link to comment
Share on other sites

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