bobcad Posted September 25, 2018 Share Posted September 25, 2018 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. Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted September 25, 2018 Share Posted September 25, 2018 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..... Quote Link to comment Share on other sites More sharing options...
Jim Clayton Posted September 26, 2018 Share Posted September 26, 2018 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. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 26, 2018 Share Posted September 26, 2018 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. Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted September 26, 2018 Share Posted September 26, 2018 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 Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted September 28, 2018 Share Posted September 28, 2018 (edited) 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 September 28, 2018 by Roy_043 Quote Link to comment Share on other sites More sharing options...
Jim Clayton Posted October 3, 2018 Share Posted October 3, 2018 If you're still looking, you might be able to do something with this. (attached) TotalLengthPolylineV1-0.lsp 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.