Hey all,
We want to quickly convert fields to text in any given drawing without prompts. Most of you have already seen the FLD2TXT routine floating around, I was looking into streamlining it a bit and this is what I've got thus far. My only issue with the original FL2TXT routine is that for some reason it doesn't process the MTEXT correctly and in some cases has deleted the whole block of text. Any suggestions? I was thinking of adding another few lines specifically to handle mtext instead of where it handles dimensions, text, and mtext the same way.
Also any suggestions for deploying this to a selection of drawings would be handy instead of opening, saving, & closing. I'm looking into 3rd party programs that can batch process lisps (unless you guys know of one that works well).
Thanks in Advance!
Dustin
(vl-load-com)
(defun c:FLD2TXT (/ ss n bn an ad s)
;;(prompt
;; "Select the objects you wish to remove the field links from: "
;; ) ;_ end of prompt
(setq ss (ssget "x" '((0 . "INSERT,MTEXT,DIMENSION,TEXT,MULTILEADER")))) ;Get selection set from user ;Modified to select all instances
(setq n 0) ;Initialize counter
;; Step through selection set one entity at a time
(while (< n (sslength ss))
(setq bn (ssname ss n)) ;Get the nth entity in the selection set
(setq ad (entget bn)) ;Get the entity's data
(cond
((= "INSERT" (cdr (assoc 0 ad))) ;Check if block
(setq an (entnext bn)) ;Get the next enity after bn
;; Step through each next entity until it is not an attribute
(while (and an ;Check if entity is found
(setq ad (entget an)) ;Get data
(= "ATTRIB" (cdr (assoc 0 ad))) ;Check if attribute
) ;_ end of and
(setq s (cdr (assoc 1 ad))) ;Get text value
(entmod (list (assoc -1 ad) (cons 1 ""))) ;Modify the entity
(entmod (list (assoc -1 ad) (cons 1 s))) ;Modify the entity
;; (entupd an) ;Update screen to show change
(setq an (entnext an)) ;Get next entity
) ;_ end of while
)
((= "MULTILEADER" (cdr (assoc 0 ad))) ;Check if block
(setq ad (vlax-ename->vla-object bn)
s (vla-get-TextString ad)
)
(vla-put-TextString ad "")
(vla-put-TextString ad s)
)
;; Anything else
(t
(setq s (cdr (assoc 1 ad))) ;Get text value
(entmod (list (assoc -1 ad) (cons 1 ""))) ;Modify the entity
(entmod (list (assoc -1 ad) (cons 1 s))) ;Modify the entity
;; (entupd an) ;Update screen to show change
)
)
(setq n (1+ n)) ;Increment counter
) ;_ end of while
(setq ss nil) ;Clear selection set
(gc) ;Clear unused memory
(princ)
) ;_ end of defun
Clik here to view.

Clik here to view.

Clik here to view.

Clik here to view.

Clik here to view.

Clik here to view.
