Jump to content

dynamically total line lengths


bobcad

Recommended Posts

Looking if there is a LISP to add the length of lines (on a layer) that would give a running total of the length of lines on a layer dynamically. ie...Get a total of all lines on a layer as you enter them. Already using a LISP to total lines by layer, but have to load LISP and select layer, & makes a table. Looking for something to make the process automatic.

Link to comment
Share on other sites

Well, if you only had lines on one layer, then the built-in command DATAEXTRACTION could do it. Unfortunately, I don't see a way to filter the table output.

You can get all the lines in the drawing, and the table can be updated as lines are added, modified, or removed, but no layer filtering.....

Link to comment
Share on other sites

Just curious, is this for BOM Totals? Because if so I'm fairly certain I have a Lisp lying around that I can provide in the morning when I'm back at the PC. Tks.

Link to comment
Share on other sites

If you want it real time then the simplest way is to add your "line" command this would duplicate the line command but do stuff like look at current layer is there a variable called "thatlayertot" if so add length after drawing line. It would though only really be current for a dwg session unless you write a data file every time command is run.

Link to comment
Share on other sites

 

You just need a reactor that fires <when you want it to> <<-- that is the key.

Perhaps the reactor would fire after a regen, or after any command, or before a save - it's up to you.

The reactor can call a function that forms a selection set of lines on layer "X", and totals their length, and pushes the result to a TEXT or MTEXT entity, or a TABLE.

 

A couple of routines that are close and may provide some insight:

http://cadtips.cadalyst.com/distance/calculate-total-area-perimeter-and-length

http://www.lee-mac.com/selectioncounter.html

 

 

Link to comment
Share on other sites

Instead of directly changing entities the reactor-based code can define and update a global Lisp variable which can then be referenced by fields. This greatly simplifies things.

See here for an example:

https://forum.bricsys.com/discussion/comment/34080/#Comment_34080

 

Note: the code was created for BricsCAD and will have to be modified for AutoCAD.

Edited by Roy_043
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...