LISP for automatic table summation at the botton cell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey everyone,
I'm trying to create a LISP routine for AutoCAD that will automatically add a sum row to the bottom of selected tables, but I'm a bit stuck. Here's what I'm aiming for:
Add a Row: The LISP should add a new row at the very bottom of whatever table I select. It may be locked as normally it will come from dataextraction commands.
Sum the Column: Specifically, I need it to automatically insert a SUM formula into the bottom-right cell of that new row. This formula should add up all the numbers directly above it in that column, starting from the third row of the table (skipping the header).
Dynamic Row Counting: This is the tricky part! I don't want to hardcode the number of rows in the formula (like SUM(B3:B9)). It needs to figure out how many rows are in the table and use that to build the SUM formula correctly. So, if there are 15 rows in a table, it should sum from row 3 up to row 14. If the next table has 20 rows it should sum from row 3 up to 19. I guess the way to do so is by asking for the total number of rows and remove 1 unit.
I'm familiar with basic LISP, but I'm struggling to get the dynamic row count and formula insertion working correctly.
Does anyone have a LISP routine that does something similar or could point me in the right direction? Any help would be greatly appreciated!
Thanks in advance