Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Anonymous
1379 Vistas, 3 Respuestas

How can I calculate the total length of all these lines

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.

 

 

 

 

 

Ranjit_Singh2
en respuesta a: Anonymous

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))))))))
SeeMSixty7
en respuesta a: Ranjit_Singh2

@Ranjit_Singh2 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.

 

 

Kent1Cooper
en respuesta a: Anonymous

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_Singh2'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