Text to Attribute Text - Quick
Does anyone know a way to convert text or mtext into an attribute instead of creating an attribute and placing the text in the same location? Is there a way to code this through VL, or DXF? If there is any tips on how or a way to start, please point me in the right direction.Thank you,
Matthew No dice.
You would have to take all info. from the text object and create an attribute. Give this a shot:
;; Txt2Att( Lee Mac );; Converts Single-line Text to Attribute Definition(defun c:txt2att ( / StringSubst RemovePairs ss ent eLst str dx73 ) (vl-load-com) ;; Lee Mac~27.04.10 (defun StringSubst ( new pat str ) (while (vl-string-search pat str) (setq str (vl-string-subst new pat str)) ) str ) (defun RemovePairs ( lst pairs ) (vl-remove-if (function (lambda ( pair ) (vl-position (car pair) pairs) ) ) lst ) ) (if (setq ss (ssget "_:L" '((0 . "TEXT")))) ( (lambda ( i ) (while (setq ent (ssname ss (setq i (1+ i)))) (setq eLst (entget ent) str(StringSubst "_" " " (cdr (assoc 1 eLst))) dx73 (cdr (assoc 73 eLst))) (setq eLst (RemovePairs eLst '( 0 100 1 73 ))) (if (entmake (append '( (0 . "ATTDEF") ) eLst (list (cons 70 0) (cons 74 dx73) (cons 1 str) (cons 2 str) (cons 3 str)))) (entdel ent) ) ) ) -1 ) ) (princ)) There you go. Text replaced with attributes.
Nice coding Lee.
Cheers Alan - its actually come up in the past, so I refined some old code - its amazing how your coding standard changes over time... HaHa no kidding.
I find myself apologizing for posting older code.
Slick thinking on RemovePairs.A nice inverse of what I was thinking in that thread at the Swamp last week, when Hangman (I think) was trying to edit dxf codes. Thanks mate - that approach works Ok to do it with Text, because Text and Attdefs share quite a lot of DXF codes, but MText might be more troublesome... Most definitely. Plus, you'd be forced to strip out all formatting. What a pain.
Arrgghhh the formatting.... I'm so sick of it LoL, I can imagine.
页:
[1]
2