Anuncios

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

How can I calculate the total length of all these lines

Anonymous

How can I calculate the total length of all these lines

Anonymous
No aplicable

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 Me gusta
Responder
Soluciones aceptadas (1)
1.381 Vistas
3 Respuestas
Respuestas (3)

Ranjit_Singh2
Advisor
Advisor
Solución aceptada

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
Advisor
Advisor

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

 

 

0 Me gusta

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_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