Bill_Myron Posted January 27, 2015 Posted January 27, 2015 Looking for a little help on this one. Everyone uses this lisp, but I need to change it slightly. I would like to change this lisp to display the current selected objects length, and then be able to select additional objects and add it to the original sum. Run Command Select Objects Display Length of Selected Objects Prompt to Select Additional Objects Select Objects Display Length of NEW Objects Display Length of ALL Objects I hope this makes sense! Here is the lisp code. ;| TLEN.LSP - Total LENgth of selected objects (c) 1998 Tee Square Graphics |; (defun C:TLEN (/ ss tl n ent itm obj l) (setq ss (ssget) tl 0 n (1- (sslength ss))) (while (>= n 0) (setq ent (entget (setq itm (ssname ss n))) obj (cdr (assoc 0 ent)) l (cond ((= obj "LINE") (distance (cdr (assoc 10 ent))(cdr (assoc 11 ent)))) ((= obj "ARC") (* (cdr (assoc 40 ent)) (if (minusp (setq l (- (cdr (assoc 51 ent)) (cdr (assoc 50 ent))))) (+ pi pi l) l))) ((or (= obj "CIRCLE")(= obj "SPLINE")(= obj "POLYLINE") (= obj "LWPOLYLINE")(= obj "ELLIPSE")) (command "_.area" "_o" itm) (getvar "perimeter")) (T 0)) tl (+ tl l) n (1- n))) (alert (strcat "Total length of selected objects is " (rtos tl))) (princ) ) Thanks in advance! Quote
Bill_Myron Posted January 27, 2015 Author Posted January 27, 2015 Did a lot of googling and found this code that Lee Mac modified for someone: ;;--------------------=={ Total Length }==--------------------;; ;; ;; ;; Displays the total length of selected objects at the ;; ;; command line. The units and precision format of the ;; ;; printed result is dependent upon the settings of the ;; ;; LUNITS & LUPREC system variables respectively. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2013 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Modified to include a running total - 2013-08-07 ;; ;;------------------------------------------------------------;; (defun c:tlen ( / e i l s tl ) (setq tl 0.0) (while (setq s (ssget '( (0 . "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE") (-4 . "<NOT") (-4 . "<AND") (0 . "POLYLINE") (-4 . "&") (70 . 80) (-4 . "AND>") (-4 . "NOT>") ) ) ) (progn (setq l 0.0) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) l (+ l (vlax-curve-getdistatparam e (vlax-curve-getendparam e))) ) ) (princ (strcat "\nLength: " (rtos l) "\tTotal: " (rtos (setq tl (+ tl l))))) ) ) (princ) ) (vl-load-com) (princ) Thanks again Lee Mac!! 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.