Jump to content

Select multiple tables and get the sum of a certain cell?


elli0t

Recommended Posts

Hi, I'm looking to be able to select multiple tables in a drawing and return the sum of the values.

Each table has a value (formula displaying a number) in a cell that is in the last column and first row.

I'm completely new to AutoLISP as we've only ever had LT at my work (AutoLISP now supported in LT 2024). 

This seems like it wouldn't be too hard but I'm really not sure on where to start. Can't really find anything on retrieving the cell value from a table.

ChatGPT hasn't been much help either unfortunately.

If anyone can help it would be greatly appreciated. Thanks!

Link to comment
Share on other sites

11 hours ago, devitg said:

@elli0t please upload your sample dwg

Tables.dwg

Hi, dwg with various tables attached. I want to get the total sum of the number in green (last column) of all selected tables. Thanks!

Link to comment
Share on other sites

41 minutes ago, rlx said:

nice one devitg! 👍

 

@rlx, Thanks for your like

It  got me a huge time to notice that rows and columns has base 0, the same as NTH, ssname, and VLA-item, maybe some others, because there is not quoted at any help . 

 

 

Link to comment
Share on other sites

yeah, (lisp) help function hasn't improved over the years. In the good old days you would get printed books with each AutoCad license , full of examples to play with. That's why sometimes you have to beg , steal & borrow all over the place to get the info you want. And sometimes is just experimenting and make use of the debug functions in vlisp editor. Not sure you need entity or object?... just try it. If you get an error you know you needed the other one and sometimes you find you can use both.

Link to comment
Share on other sites

6 hours ago, devitg said:

@elli0t

Find attached lisp and result dwg 

 

the new command is 

 

LAST-CELL

  

 

 

sum table last cell.LSP 2.12 kB · 5 downloads sum Tables last cell.dwg 65.63 kB · 2 downloads

Thank you so much @devitg, that's great!

Would love to know how you went about solving this, or where to get started to learn how to write LISP code.

Link to comment
Share on other sites

Files like this help I did not make it. Look for a word that seems what you want then google it to see if it matches. 

 

To learn lisp, start here look at what has been done, its a question often asked, books, ebooks are cheap, Afralisp has tutorials, some tutorials like "down the garden path" is done by Autodesk. 

 

Just google "Your task Autocad lisp". I use Bricscad mostly but still look for "AutoCad lisp"

 

As mentioned here I have a R12 lisp paper book comes in handy at times as it has examples. Plus 4 ebooks.

 

 

list of methods for a table.txt

Edited by BIGAL
Link to comment
Share on other sites

9 hours ago, devitg said:

It  got me a huge time to notice that rows and columns has base 0, the same as NTH, ssname, and VLA-item, maybe some others, because there is not quoted at any help . 

They DID explain that clearly but very very few who read to understand but the majority copy and paste and blame the others if their posted codes did not work for them , so here are two snapshots with indications. 

image.png.b360d37759109a197b67bffd396169b2.png

image.png.aefcbde5402ba5da91fe6fcc152d7799.png

Link to comment
Share on other sites

@Tharwat  from the last Help I have 

 

Autodesk AutoCAD 2018: ActiveX Reference Guide > Methods > G Methods > 

GetCellValue Method (ActiveX)

 

 

 

Gets the cell value for the given row and column.

Supported platforms: Windows only

Signature

VBA:

RetVal = object.GetCellValue(row, col)

object

Type: Table

The object this method applies to.

row

Access: Input-only

Type: Long

The row number of the cell to set.

col

Access: Input-only

Type: Long

The column number of the cell to set.

 

There is no mention about 0 based order

 

 

 

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...