VAC 0 Posted March 26 Hi, can anybody help me to do a lisp that will count total length of selected lines, polylines,....sorted by colour (0-256)? Output to MText/table like: 1 (color number - red) - calculated total length 2 - calculated total length 3 - not found......this line will not show in the list 4 - calculated total length .... Super should be, if this lisp should be run on just selected items (with for example selectsimilar command), (not to run this script and then select items) Lee Mac script is fine, but does not recognize colors and final value prints only into command line - I prefere to clipboard. How can I modify his lisp? http://www.lee-mac.com/totallengthandarea.html Many thanks Quote Share this post Link to post Share on other sites
BIGAL 590 Posted March 27 Did you google I think it exists. May be over at Forums/autodesk. Quote Share this post Link to post Share on other sites
VAC 0 Posted March 27 (edited) I googled, but found only byLayer or another, none by color: https://www.cadstudio.cz/en/download.asp?file=AddLen https://forums.autodesk.com/t5/forums/searchpage/tab/message?advanced=false&allow_punctuation=false&filter=location&location=category:AutoCADTopic1&q=total length Edited March 27 by VAC Quote Share this post Link to post Share on other sites
VAC 0 Posted March 27 Now I found one, but it calculate it from whole drawing. I need only selected items. Any idea how to modify it? Quote Share this post Link to post Share on other sites
devitg 15 Posted April 7 Hi VAC, please upload your sample dwg where to apply such lisp Quote Share this post Link to post Share on other sites
BIGAL 590 Posted April 8 Its a good idea to ask the Author 1st in this case Lee-mac who is very helpful and often repsonds with like change just this one line to suit your needs. Ok a big hint when using ssget you can have multiple filters ssget "object type" "is plines" "color is" eg (setq ss (ssget (list (cons 0 "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE")(cons 62 1)))) You home work, what is 62 Copy to clipboard example (defun testclip (str / pt dist ) (vlax-invoke (vlax-get (vlax-get (vlax-create-object "htmlfile") 'ParentWindow) 'ClipBoardData) 'setData "TEXT" str ) (princ) ) (testclip (rtos l 2 2)) Quote Share this post Link to post Share on other sites
VAC 0 Posted April 9 total_length_by_colour.dwg Quote Share this post Link to post Share on other sites
VAC 0 Posted April 9 I've uploaded sample file. Maybe 62 is ByLayer? 1 is red colour. I don't know lisp language. I don't know, how to ask Lee Mac directly. Quote Share this post Link to post Share on other sites
Tharwat 188 Posted April 9 Hi VAC, Try the following which compute lengths of selected Lines & Polylines based on your request from the first post and the program would ignore the colour ByLayer as long as you wanted to filter them from ( 0 - 256 ) and sort them by colour number for a better presentation. (defun c:Test ( / int sel ent clr len fnd new lst ins tbl row col) ;; Tharwat - Date: 9.April.2021 ;; (and (princ "\nSelect object to computer lengths into AutoCAD Table : ") (setq int -1 sel (ssget '((0 . "LINE,*POLYLINE")))) (while (setq int (1+ int) ent (ssname sel int)) (and (setq clr (cdr (assoc 62 (entget ent)))) (or (and (setq len (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent))) (setq fnd (assoc clr lst)) (setq new (list clr (+ (cadr fnd) len)) lst (vl-remove fnd lst) lst (cons new lst) ) ) (setq lst (cons (list clr len) lst)) ) ) ) (setq lst (vl-sort lst '(lambda (j k) (< (car j) (car k))))) (setq ins (getpoint "\nSpecify Table insertion point : ")) (setq tbl (vla-addtable (vlax-get (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))) 'BLOCK) (vlax-3d-point ins) (1+ (length lst)) 2 900 4125) ) (_write:data 0 0 "Length Calculation") (setq row 1 col -1) (foreach itm lst (foreach str (list (car itm) (rtos (cadr itm) 2 2)) (_write:data row (setq col (1+ col)) str) ) (setq row (1+ row) col -1 ) ) ) (princ) ) (vl-load-com) ;; ;; (defun _write:data (r c s) (vla-settext tbl r c s) (vla-setcelltextheight tbl r c 450) (vla-setrowheight tbl r 900) (vla-setcellalignment tbl r c acMiddleCenter) s ) Quote Share this post Link to post Share on other sites
VAC 0 Posted April 9 (edited) Hi, it works great. Many thanks. I will test it more later. Edited April 9 by VAC Quote Share this post Link to post Share on other sites
BIGAL 590 Posted April 10 (edited) A good idea you need to look into the DXF codes and what they mean for common variables like Layer, Color, Insertion point, name and so on. After a while just remember. DXF Reference (autodesk.com) Edited April 10 by BIGAL Quote Share this post Link to post Share on other sites
Tharwat 188 Posted April 10 18 hours ago, VAC said: Hi, it works great. Many thanks. I will test it more later. You're welcome anytime. Quote Share this post Link to post Share on other sites