SurveyCAD85 Posted October 5, 2017 Share Posted October 5, 2017 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) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 5, 2017 Share Posted October 5, 2017 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) ) Quote Link to comment Share on other sites More sharing options...
SurveyCAD85 Posted October 5, 2017 Author Share Posted October 5, 2017 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!!! Quote Link to comment Share on other sites More sharing options...
SLW210 Posted October 5, 2017 Share Posted October 5, 2017 Please read the Code Posting Guidelines and edit your Code to be included in Code Tags.[NOPARSE] Your Code Here[/NOPARSE] = Your Code Here Quote Link to comment Share on other sites More sharing options...
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.