This is an old post, so I hope Ian (or someone else can help) I am looking to remove FIELD definitions from MTEXT within a TABLE... similar to the code listed above (as all the above works with DIMS, TEXT, MTEXT, ATTRIBUTES, but not TABLES. 😞
Thanks in advance. - Tracy Lincoln (yes, the one and only)
Hi,
not well tested,
and will not change tables on locked layers,
or change locked table cells.
Create a selection set of the table entities
and step through it applying the following function
to each ename in the set.
(defun do_table (ent / obj nr nc nc1 nr1 vv tstring)
(setq obj (vlax-ename->vla-object ent)
nr (vlax-get obj 'Rows)
nc (vlax-get obj 'Columns)
)
(setq nr1 0)
(while (< nr1 nr)
(setq nc1 0)
(while (< nc1 nc)
(if (and
(= (vla-GetCellType obj nr1 nc1) 1)
(setq tstring (vla-gettext obj nr1 nc1))
)
(progn
(vl-catch-all-apply 'vla-deletecellcontent
(list obj nr1 nc1)
)
(setq vv (vla-getcellvalue obj nr1 nc1))
(vl-catch-all-apply 'vla-SetTextString
(list obj nr1 nc1 vv tstring)
)
)
)
(setq nc1 (+ 1 nc1))
)
(setq nr1 (+ 1 nr1))
)
(princ)
)
Ian
Thank you for the code, but I cannot seem to get it to work after I load it?
@Ian_Bryant wrote:
Hi,
You also need to change
(setq ss1
(ssget "X"
(list (cons 0 "INSERT")
(cons 67 1)
(cons 66 1)
)
)
)
to
(setq ss1
(ssget "X"
(list (cons 0 "INSERT")
(cons 67 0)
(cons 66 1)
)
)
)
Regards Ian
Hi,
The code works great.
How to narrow the selection set to Fields with certain expression, %<\AcVar SaveDate \f "dd.MM.yyyy">% for instance?
Thank you
Robert
@Ian_Bryant wrote:
Hi,
you could try the attached lsp.
It coverts all fields in modelspace
text, mtext, mleaders and block attributes.
It does not convert text within
a block, or anything in a nested block.
Regards Ian
Hi,
Very interesting code!
I was looking for a code to converts all fields in layout space into MText.
In my drawing have 2 Mtext as a Field by layout.
Some drawing have about 50 layout space.
Thanks in advance
Fabricio
I've already get the answer.
http://forums.augi.com/showthread.php?162398-Converting-All-Fields-To-text
Thanks
Fabricio
Hi - Could you tell me how to alter this code to accommodate multiline attributes? Thanks!
(defun C:R-FIELDS-ALL ( / del-field ss1 index item)
(vl-load-com)
(defun del-field (ent / edic elist etype obj val)
(if
(and
(setq edic (cdr (assoc 360 (setq elist (entget ent)))))
(dictsearch edic "ACAD_FIELD")
)
(progn
(setq obj (vlax-ename->vla-object ent)
etype (cdr (assoc 0 elist))
)
(cond
((= etype "DIMENSION")
(setq val (vla-get-textoverride obj))
(dictremove edic "ACAD_FIELD")
(vla-put-textoverride obj val)
)
((= etype "MTEXT")
(setq val (vla-get-textstring obj))
(dictremove edic "ACAD_FIELD")
(vla-put-textstring obj val)
)
(T (dictremove edic "ACAD_FIELD"))
)
)
)
)
(if
(setq ss1
(ssget "X" '((0 . "TEXT,MTEXT,MULTILEADER,DIMENSION")))
)
(progn
(setq index 0)
(repeat (sslength ss1)
(setq item (ssname ss1 index))
(if (del-field item) (entupd item))
(setq index (+ 1 index))
)
)
)
(if
(setq ss1
(ssget "X" '((0 . "INSERT")))
)
(progn
(setq index 0)
(repeat (sslength ss1)
(setq item (ssname ss1 index))
(while (= (cdr (assoc 0 (entget (setq item (entnext item))))) "ATTRIB")
(if (del-field item) (entupd item))
)
(setq index (+ 1 index))
)
)
)
(princ)
)
Can't find what you're looking for? Ask the community or share your knowledge.