Wednesday, November 14, 2012

Convert Exploded Attributes to Text

It doesn't happen often that I need this LISP, but when I have, it has been a life saver. 

In today's situation, we are linking a CAD file into a Revit project and the text would not come through. Looking at the CAD file we received, the text is all attributes that have been exploded.

This little gem saved the day. One other thing we end up doing is changing the font for the text in AutoCAD to Zurich LT BT. It looks like Simplex, but plots way better out of Revit.

I don't remember where this lisp came from and it isn't documented, but thank you so much stranger.


;;;
;;; Convert Attribute definitions to text
;;;

(defun c:A2T (/ eset1 blkcnt en enlist vl space)
  (setq eset1  (ssget (list (cons 0 "ATTDEF")))
blkcnt 0
  )

  (if eset1
    (while (<= blkcnt (- (sslength eset1) 1))
      (setq en   (ssname eset1 blkcnt)
   enlist (entget en)
   space  (cdr (assoc 67 enlist))
      )
      (setq vl (list
(cons 0 "TEXT")
(cons 100 "AcDbEntity")
(cons 100 "AcDbText")
(assoc 7 enlist)
(assoc 8 enlist)
(assoc 10 enlist)
(assoc 40 enlist)
(cond ((assoc 62 enlist))
      ((cons 62 256))
)
(cons 1 (cdr (assoc 2 enlist)))
(if (= space nil)
  (cons 67 0)
  (cons 67 space)
)
      )
      )
      (entdel en)
      (entmake vl)
      (setq blkcnt (1+ blkcnt))
    )
  )
)

1 comment:

Anonymous said...

Lazy Drafter- Thank you so much for this A2T!!! I've been trying to find something like this for years! Works so great! Les

(les.cherry@yahoo.com)