Ok,... more like decades... probably been 15 years at least since I've done ANY lisp and Autocad has changed a bit since then.
I've been up and down the forums looking for some direction or programming code for this to no avail.
What I'd like to do is edit a table where the cells are populated with fields. I'd like to copy the last row of the table to a new row (fields and all), then change the fields of the row I copied FROM to text, and lock those cells. See image....
So, in this image, I'd like to copy this row including the fields to a new row beneath it. Then edit the cells of the first row to change the fields to text, and then finally lock the cells of the first row so that only the new row would update when the field properties change. Eventually they will be populated with data from the Vault... but first things first.
Anyone have any ideas?
Solved! Go to Solution.
Why do this first? Wouldn't dataextraction or just the basic table command do with an external source? Use excel and populate your data. What are the fields for? Dataextraction can pull a table straight from the properties of objects.
The last thing I would do would be to try to programmatically build tables with LISP. Its a complex task. If you must, try googling "tables autolisp"
The fields in this table are populated from Vault. I want to populate the current row from Vault properties, copy the row including all of the fields, and then convert the original row's fields to text so they will not change when I modify the Vault properties later. Locking the cells may not be necessary, but it would be added security.
Yes... the Vault Revision table does this... but I need to create something that works just like to VRT... from the Item Master side of Vault.
Basically trying to get Vault and Autocad to do something they were never meant to do.
Try the following quick draft based on your image:
(defun c:tabmod ( / col obj ) (if (setq obj (ssget "_+.:E:S:L" '((0 . "ACAD_TABLE")))) (progn (setq obj (vlax-ename->vla-object (ssname obj 0))) (vla-insertrows obj 1 (vla-getrowheight obj 1) 1) (repeat (setq col (vla-get-columns obj)) (vla-settext obj 1 (setq col (1- col)) (vla-gettext obj 2 col)) ) ) ) (princ) ) (vl-load-com) (princ)
Or, try the following:
(defun c:tabmod ( / c i o r s ) (if (setq s (ssget "_:L" '((0 . "ACAD_TABLE")))) (repeat (setq i (sslength s)) (setq o (vlax-ename->vla-object (ssname s (setq i (1- i)))) r (1- (vla-get-rows o)) ) (vla-insertrows o r (vla-getrowheight o r) 1) (repeat (setq c (vla-get-columns o)) (vla-settext o r (setq c (1- c)) (vla-gettext o (1+ r) c)) (vla-setcellstate o r c accellstatecontentlocked) ) ) ) (princ) ) (vl-load-com) (princ)
The above will operate on the last row for multiple tables in a selection, and will also lock the cells as required.
Absolute genius my good man! This did exactly what I was looking for! If I could give more than one kudo, I would do it.
I swear, i need to get back into the programming side, this is just too much fun.
Thank you for your kind words Chris, I'm glad the program was helpful and I appreciate your gratitude for my time
Programming is indeed incredibly fun and highly addictive - be warned, you may get hooked!
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.