Spline Length 2017

Spline Length 2017

Anonymous
Not applicable
2,206 Views
3 Replies
Message 1 of 4

Spline Length 2017

Anonymous
Not applicable

Is there a command or an easy way in 2017 to measure the lenth of SPLINES?  We lay circuits out and I would like to click on multiple splines and find the total length of them. I have searched but cant seem to find any information.

 

Thank you

0 Likes
2,207 Views
3 Replies
Replies (3)
Message 2 of 4

Kent1Cooper
Consultant
Consultant

@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
0 Likes
Message 3 of 4

imadHabash
Mentor
Mentor

Hi and Welcome to AutoDesk Forum,

 

it's worth to try this Lisp 

Imad Habash

EESignature

0 Likes
Message 4 of 4

john.vellek
Alumni
Alumni

Hi @Anonymous,

 

I see that you are visiting as a new member. Welcome to the Autodesk Community!

 

Did you find either of the LISP routines to work for you process? If so, please mark a post or poss as accepted solutions. If not, please describe what didn't work and I will see if I can help.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes