Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Member
twlincoln2009
Posts: 3
Registered: ‎12-13-2012
Message 21 of 24 (471 Views)

Re: Convert Field to Text

12-13-2012 05:24 PM in reply to: Ian_Bryant

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)

Valued Mentor
Ian_Bryant
Posts: 362
Registered: ‎06-02-2005
Message 22 of 24 (451 Views)

Re: Convert Field to Text

12-14-2012 04:09 AM in reply to: twlincoln2009

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

Member
twlincoln2009
Posts: 3
Registered: ‎12-13-2012
Message 23 of 24 (369 Views)

Re: Convert Field to Text

01-16-2013 12:17 PM in reply to: Ian_Bryant

Thank you for the code, but I cannot seem to get it to work after I load it?

 

Valued Contributor
robert06
Posts: 72
Registered: ‎11-16-2006
Message 24 of 24 (64 Views)

Re: Convert Field to Text

09-04-2014 03:08 AM in reply to: Ian_Bryant

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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.