Jump to content

Changing Table Width Property


googly_glop

Recommended Posts

I am trying to create a routine which will change the total width of existing tables to a uniform value

 

Currently the quickest way I know how to do this is to manually highlight all tables I want to change, open autocad properties window and change the "table width" value (see attached screenshot)

 

I wanted to change properties using visual lisp, which I am very new to and wanted to know if anyone could point me in the right direction with this code

(vl-load-com)
(defun c:change_Width()
    (setq TABLE (ssget))
    (vla-put-width TABLE (/ width 48))
    (vla-Update TABLE)
)

 

Currently I set up the code to prompt me with a ssget call so I could select table and change width value

Autocad returns  error: bad argument type: VLA-OBJECT <Selection set: 107>

 

I would appreciate anyone pointing me in the right direction

 

Properties Window.PNG

Link to comment
Share on other sites

Ok so I did some more research and I found that I am to create a VLA-OBJECT from each entity first

 

I found some code which works now

(vl-load-com)
(defun c:change_Width()
    (setq 
        TABLE (ssget)
        i 0)
    (repeat (sslength TABLE)
        (setq 
            ent (ssname TABLE i)
            obj (vlax-ename->vla-object ent) 
        );setq
    )
(vla-put-width obj 168)
(vla-Update obj)
)

However, this code only works for the first object in a selectio set

 

I'm still troubleshooting on it, and will post progress, however any help is appreciated

Link to comment
Share on other sites

You will need to increment your variable 'i' for every iteration of the repeat loop (you may wish to refer to my Selection Set Processing tutorial in this regard), and the vla-put-width & vla-update expressions should reside within the repeat loop so that they are evaluated for every object processed.

Edited by Lee Mac
Link to comment
Share on other sites

Thank you very much Lee!

Took longer than I'd like to admit to wrap my mind around it

(vl-load-com)
(defun c:change_Width()
    (setq 
        TABLE (ssget)
        i 0)
    (repeat (sslength TABLE)
        (setq 
            ent (ssname TABLE i)
            obj (vlax-ename->vla-object ent) 
        );setq
	(vla-put-width obj 168)
	(vla-Update obj)
	(setq i (1+ i))
    )
    (princ)
)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...