How can I calculate the total length of all these lines

How can I calculate the total length of all these lines

Anonymous
Not applicable
1,609 Views
3 Replies
Message 1 of 4

How can I calculate the total length of all these lines

Anonymous
Not applicable

How can I calculate the total length of all these lines as attached, by only one command?

 

Regarding solution, i put the dim linear command and manually calculate all the lines and add to calculate total length.

 

 

 

 

 

0 Likes
Accepted solutions (1)
1,610 Views
3 Replies
Replies (3)
Message 2 of 4

Ranjit_Singh
Advisor
Advisor
Accepted solution

Here's one way

(defun c:somefunc ()
 (apply '+ (vl-remove-if-not 'numberp
                 (mapcar '(lambda (x) (vl-catch-all-apply 'vla-get-length (list (vlax-ename->vla-object x))))
                          (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget))))))))
Message 3 of 4

SeeMSixty7
Advisor
Advisor

@Ranjit_Singh puts the LISt Processing in AutoLISP!

 

Ranjit hats off to your never ending supply of Lamda's and Mapcars as well as the occasional apply function.

 

Your aversion to using Variables has made you a master of these functions.

 

 

0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant

There are a variety of routines out there to do that.  For instance, several here.  If you ever need to do it with a variety of entity types, you may find one of those better than @Ranjit_Singh's suggestion, since it will work only on objects with a 'Length VLA Property, which not all entities have [for Circles, it's the 'Circumference Property, for Arcs, it's 'ArcLength, for Ellipses it isn't in VLA Properties at all].

Kent Cooper, AIA