@Anonymous wrote:
Is there a command or an easy way ... to measure the lenth of SPLINES? We ... would like to click on multiple splines and find the total length of them. ....
Welcome to these Forums!
Here's one way:
(defun c:TSL (/ spliness n spl); = Total Spline(s) Length
(prompt "\nTo find the Total Length of Splines,")
(if (setq spliness (ssget '((0 . "SPLINE"))))
(progn
(setq totalLen 0.0)
(repeat (setq n (sslength spliness))
(setq totalLen
(+
totalLen
(vlax-curve-getDistAtParam
(setq spl (ssname spliness (setq n (1- n))))
(vlax-curve-getEndParam spl)
); ...getDist...
); +
); setq
); repeat
(prompt ; [or (alert if preferred]
(strcat
"\nTotal lengths of "
(itoa (sslength spliness))
" Spline(s) = "
(rtos totalLen); in current Units settings
;; [designate mode & precision if desired]
); strcat
); prompt
); progn
); if
(princ)
); defun
(vl-load-com); if needed
I left the 'totalLen' variable not localized, so it will still be around after the command finishes, in case you want to do something with it.
There's probably something equivalent out there to do this kind of thing for multiple object types. But many such routines are restricted to only certain types, such as this one, which accepts only Lines and LWPolylines [despite the summary on the web page that claims it accepts more].
BUT that one can't be simply altered to filter for Splines instead, because it uses the Length VLA Property, which for some reason Splines don't have. Neither do Arcs or Circles, though there are equivalents -- Arcs have an ArcLength Property and Circles have a Circumference Property.
But rather than ask for a different Property depending on each object's entity type, the above approach, using the Distance along the object at its End Parameter, works with all "curve"-class object types, open or closed. [Getting the Distance at the End Point gives a result of 0 for closed things such as Circles or full Ellipses or closed Polylines/Splines, but by Parameter it works right.] So if you want to use it to find the total length of any combination of different types, all you need to do is change the (ssget) filter to admit the others:
....
(if (setq spliness (ssget '((0 . "LINE,*POLYLINE,CIRCLE,ARC,ELLIPSE,SPLINE"))))
....
and, of course, change the command name and the wording of the prompt.
[You could shorten that filter this way, to make a collective for Lines, all kinds of Polylines, and Splines:
'((0 . "*LINE,CIRCLE,ARC,ELLIPSE"))
but since that would also accept XLINEs and MLINEs, which the rest of the code will not like, you would then have to check for the entity type of each before getting its length and adding it to the total.]
Kent Cooper, AIA