googly_glop Posted October 12, 2018 Share Posted October 12, 2018 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 Quote Link to comment Share on other sites More sharing options...
googly_glop Posted October 12, 2018 Author Share Posted October 12, 2018 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 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 12, 2018 Share Posted October 12, 2018 (edited) 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 October 12, 2018 by Lee Mac Quote Link to comment Share on other sites More sharing options...
googly_glop Posted October 12, 2018 Author Share Posted October 12, 2018 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) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 12, 2018 Share Posted October 12, 2018 You're welcome - I'm glad to see that you were able to solve it on your own Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.