Hi All
I am seeking lisp to rotate text attribute.
In shortcut:
1) Run command
2) Click text (attribute)
3) Click ref object (line, 3d pline, text)
4) Text (attribute) rotates around text's insertion node for an angle defined by ref object
Thanks
Sorry I don't do lisp, but study the attached drawing you can do it easily without lisp
Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
I most of cases I have point (on line/polly) and text. Point and text are dynamic block, but I need to align text to line. Block definition can not be changed as it is should be compliant with drawing standards
@BB8x Use the alignment parameter ringed in the image below, then you can drag and the block will automatically align to whatever line you drag it to
Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
I have lisp to rotate whole block against insertion point, but I want to rotate only text.
There is a lisp for it, but it takes a while to align single text. I have loads of them
(vl-load-com)
(defun c:attro (/ break data_input attrib->text askangle Justify qang ; local functions
adoc ss ename1 elist1 attribs^ p0 p1 p2 p3 rot cod)
(defun break (msg)
(if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
(princ (strcat "\nError: " msg))
)
(if ss
(foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(entdel ent)
)
); if
(vla-endUndoMark adoc)
(vlax-release-object adoc)
(setvar "cmdecho" 1)
(setq *error* nil)
(princ)
); break
(defun data_input (/ n pick0 ename0 elist0)
(setq n 0)
(while (setq pick0 (nentsel "\nSelect text or attribute: "))
(cond
((and
(setq elist0 (entget (setq ename0 (car pick0))))
(wcmatch (cdr (assoc '0 elist0)) "TEXT,ATTRIB")
)
(redraw ename0 3)
(setq attribs^ (cons ename0 attribs^))
(prompt (strcat "\n" (itoa (setq n (1+ n))) " text object(s) selected."))
); case
( t
(vlr-beep-reaction)
(prompt "\nObject selected is not text nor attribute.")
); case
); cond
); while
attribs^
); data_input
; temporary convert attrib to text
(defun attrib->text (e)
(entmake
(append
(list '(0 . "TEXT"))
(vl-remove-if
'(lambda (dxf)
(member (car dxf) '(-1 0 2 3 5 70 72 74 100 102 280 330 347 360 370 440)) ; eliminate these dxf codes from elist
)
e
); vl-remove-if
); append
); entmake
); attdef->text
; pause for angle while draging
(defun askangle (def / ask)
(if (not (setq ask (acet-ss-drag-rotate ss p1 (strcat "\nRotation angle <" (angtos def 0) ">: ") t 0)))
(setq ask def)
(setq def ask)
)
); askangle
; return justification dxf code
(defun Justify (e / itm)
(if (and
(setq itm (assoc '11 e))
(not (equal (distance (cdr itm) '(0.0 0.0 0.0)) 0.0 1e-3))
)
11 10)
); Justify
; make sure text is in readable angle
(defun qang (a)
(if (and (> a (* pi 0.5)) (<= a (* pi 1.5)))
(+ a pi)
a)
); qang
; here start attro
(setq *error* break)
(setvar "cmdecho" 0)
(setq adoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-startUndoMark adoc)
(if (> (abs (getvar "userr5")) (* pi 2))
(setvar "userr5" 0.0)
)
(if (data_input)
(progn
(setq ss (ssadd))
(foreach ename1 attribs^
(setq elist1 (entget ename1))
(attrib->text elist1)
(ssadd (entlast) ss)
); foreach
(if (and
(> (sslength ss) 0)
(setq p0 (getpoint "\nSpecify base point: "))
(not (command "._move" "_si" ss p0 "'cmdecho" 1 pause))
(setq p1 (getvar "lastpoint"))
(setvar "userr5" (setq rot (askangle (getvar "userr5"))))
)
(progn
(foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(entdel ent)
)
(setq ss nil)
(foreach ename1 attribs^
(setq elist1 (entget ename1))
(setq p2 (cdr (assoc (setq cod (Justify elist1)) elist1)))
(setq p3 (polar p1 (+ rot (angle p0 p2)) (distance p0 p2)))
(setq elist1 (subst (cons cod p3) (assoc cod elist1) elist1))
(setq elist1 (subst (cons '50 (qang (+ rot (cdr (assoc '50 elist1))))) (assoc '50 elist1) elist1))
(entmod elist1)
(entupd ename1)
); foreach
); progn
); if
); progn
); if
(vla-endUndoMark adoc)
(vlax-release-object adoc)
(setvar "cmdecho" 1)
(setq *error* nil)
(princ)
); c:attro
Can't find what you're looking for? Ask the community or share your knowledge.