- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I need to create a text from a propertie of the line (propertie name from OD group) and integrate it on a lsp file.
I've this lsp file that do half of the job:
(defun C:LTR (/ lin lindata txt txtdata end1 end2 ang mid)
(setvar 'cmdecho 0)
(while
(not
(and
(setq lin (car (entsel "\n Select LINE with Correct Angle: ")))
(if lin (setq lindata (entget lin)))
(= (cdr (assoc 0 lindata)) "LINE")
); end and
); end not
(prompt "\nNothing selected, or not a Line -- try again.")
); end while
(redraw lin 3)
(while
(not
(and
(setq txt (car (entsel "\n Select TEXT to center on and align with Line: ")))
(if txt (setq txtdata (entget txt)))
(= (cdr (assoc 0 txtdata)) "TEXT")
(= (cdr (assoc 70 (tblsearch "layer" (cdr (assoc 8 txtdata))))) 0); unlocked Layer
); end and
); end not
(prompt "\nNothing selected, or not Text, or on a locked Layer -- try again.")
); end while
(setq
end1 (cdr (assoc 10 lindata))
end2 (cdr (assoc 11 lindata))
ang (angle end1 end2)
mid (mapcar '/ (mapcar '+ end1 end2) '(2 2 2))
); end setq
(if (< (/ pi 2) ang (* pi 1.5)) (setq ang (+ ang pi))); Text in more upright direction
(setq
txtdata (subst (cons 50 ang) (assoc 50 txtdata) txtdata); rotation
txtdata (subst '(72 . 1) (assoc 72 txtdata) txtdata); justification Center
txtdata (subst '(73 . 0) (assoc 73 txtdata) txtdata); justification [0 for plain Center, 1 for Bottom Center]
); end setq
(entmod txtdata)
(command; avoids need to calculate (assoc 10) value for (subst)
"_.move" txt ""
(cdr (assoc 11 txtdata)); original insertion point
(polar mid (+ ang (/ pi 2)) (getvar 'dimscale)); new insertion point
); end command
(redraw lin 4)
(setvar 'cmdecho 1)
(princ)
); end defun
But I need that the text used was generated from the line.
Solved! Go to Solution.