Lê Tuấn Anh Posted December 22, 2019 Posted December 22, 2019 How can i get the total length of polylines and express them by formula with text. Thanks Quote
Emmanuel Delay Posted January 6, 2020 Posted January 6, 2020 Command: PTL (for Polyline Total Length) (vl-load-com) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun drawText (pt hgt str) (entmakex (list (cons 0 "TEXT") (cons 10 pt) (cons 40 hgt) (cons 1 str))) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; length of polyline, or most other (curved) lines, spline, ... (defun length_curve (ent / ) (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; PTL for Polyline Total Length (defun c:PTL ( / ss len i pline hgt) ;; settings (setq hgt 2.5) ;; text height. Feel free to change this number (setq ss (ssget (list (cons 0 "POLYLINE,LWPOLYLINE")))) (setq len 0.0) (setq i 0) (repeat (sslength ss) (setq pline (ssname ss i)) (setq len (+ len (length_curve pline))) (setq i (+ i 1)) ) (drawText (getpoint "\nSet insert point for the text: ") hgt (rtos len 2 3) ;; this 3 is the number of decimals, feel free to change ) (princ) ) Quote
Lee Mac Posted January 6, 2020 Posted January 6, 2020 You could generate a field referencing the sum of the lengths of all objects within a selection using the commands offered by my Length & Area Field application, alternatively, you may want to consider my Total Length & Area program, or Length at Midpoint program. 1 Quote
Mike Shick Posted May 18, 2023 Posted May 18, 2023 LFM seems to output with wrong lengths. 10' line with lf shows 1/8" for LFM. Can this routine include another routine that automatically adds the text to the geocenter of the objects selected? Can it include length of splines? Can there be an option to create the multiline text on the fly rather than pick an existing mtext? Very awesome lsp.....thank you for your work! Quote
Mike Shick Posted May 18, 2023 Posted May 18, 2023 Quote LFM seems to output with wrong lengths. 10' line with lf shows 1/8" for LFM. Can this routine include another routine that automatically adds the text to the geocenter of the objects selected? Can it include length of splines? Can there be an option to create the multiline text on the fly rather than pick an existing mtext? Can units be provided at end of text? My units are set to inches in architecture. Can the area output be in SQ FT? Can area be rounded to nearest sqaure foot (no decimals)? Very awesome lsp.....thank you for your work! Quote
Mike Shick Posted May 18, 2023 Posted May 18, 2023 Quote LFM seems to output with wrong lengths. 10' line with lf shows 1/8" for LFM. Can this routine include another routine that automatically adds the text to the geocenter of the objects selected? Can it include length of splines? Can there be an option to create the multiline text on the fly rather than pick an existing mtext? Can units be provided at end of text? My units are set to inches in architecture. Can the area output be in SQ FT? Can area be rounded to nearest sqaure foot (no decimals)? Even crazier....is there a way to select the area field or lf text and have it select the objects they are computed from Could additional areas or lines be added to the text already existing without having to reselect all the lines? Very awesome lsp.....thank you for your work! Quote
Mike Shick Posted May 18, 2023 Posted May 18, 2023 sorry....must look like spam above. I solved the formatting concerns, and don't have a problem with lfm of different units. I've solved the prefix and suffix, conversion, and rounding issues. 1. I asked for multiline text above, but meant multi-leader creation on the fly. 2. I also meant to say above, is there a way to select the field text and see the selection of the objects it was created from? 3. and could items be added to an already computed field? 4. it there an easy way to reverse the lf with lfm and af with afm or to create a settings toggle that allows for last chosen setting or to allow subtraction option at the specify point or table cell prompt instead? I won't be using subtraction much, but wouldn't mind the two letters vs the 3 for commands. 5. Can background mask be added to the mtext in the routine automatically? Thanks again. Quote
Lee Mac Posted May 18, 2023 Posted May 18, 2023 2 hours ago, Mike Shick said: 1. I asked for multiline text above, but meant multi-leader creation on the fly. This is possible to implement, however, I don't intend to add this modification to the public version of the application, and so feel free to contact me through the contact form on my site and I can look to develop a custom version of the program for you. 2 hours ago, Mike Shick said: 2. I also meant to say above, is there a way to select the field text and see the selection of the objects it was created from? You could use my Field Objects program for this purpose. 2 hours ago, Mike Shick said: 3. and could items be added to an already computed field? This is also possible, but rather more complex - as above, feel free to contact me through my site and we can discuss what would be involved to achieve this. 2 hours ago, Mike Shick said: 4. it there an easy way to reverse the lf with lfm and af with afm or to create a settings toggle that allows for last chosen setting or to allow subtraction option at the specify point or table cell prompt instead? I won't be using subtraction much, but wouldn't mind the two letters vs the 3 for commands. Yes - you can simply rename the commands defined on line 5-6 and 12-13 to the following: ;;----------------------------------------------------------------------;; ;; Length Field Commands ;; ;;----------------------------------------------------------------------;; (defun c:lf ( ) (lengthfield nil nil "%lu6")) ;; Current units, no subtraction prompt (defun c:lfm ( ) (lengthfield nil t "%lu6%ct8[0.001]")) ;; Current units with 0.001 conversion factor (mm->m), subtraction prompt ;;----------------------------------------------------------------------;; ;; Area Field Commands ;; ;;----------------------------------------------------------------------;; (defun c:af ( ) (areafield nil nil "%lu6%qf1")) ;; Current units, no subtraction prompt (defun c:afm ( ) (areafield nil t "%lu6%qf1%ct8[1e-6]")) ;; Current units with 1e-6 (0.000001) conversion factor (mm2->m2), subtraction prompt ;;----------------------------------------------------------------------;; 2 hours ago, Mike Shick said: 5. Can background mask be added to the mtext in the routine automatically? Yes - but as above, I would implement this in a custom version. Quote
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.