Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Measuring Distance 2

Status
Not open for further replies.

corvette63

Civil/Environmental
Sep 28, 2004
71
I am running CAD 2005 and have a need to measure distance / length of portions of a line segment. I can use Tools Inquiry Distance but can't measure more than between two points. Is there another technique to measure along more points?
 
Replies continue below

Recommended for you

If it's a polyline, the LIST command will print everything you might want to know about it.



Mike Halloran
Pembroke Pines, FL, USA
 
Try this routine- it will cumulatate distances
Code:
(defun c:cd ()
 (setvar "cmdecho" 0)
 (graphscr)
 (setq 
  p1 (getpoint "\nPick start point ")
  p2 (getpoint p1 "\nPick next point ")
  d1 (distance p1 p2)
  prdist (strcat "\nDistance: " (rtos d1))
 )
 (princ prdist)
 (setq p3 (getpoint p2 "\nPick next point or RETURN if done "))
 (while p3
  (setq
   d0 (distance p2 p3)
   d1 (+ (distance p2 p3) d1)
   p2 p3
   prdist (strcat "\nDistance: " (rtos d0) ", Cumulative distance: " (rtos d1))
  )
  (princ prdist)
  (setq p3 (getpoint p2 "\nPick Next Point "))
 )
 (setq cumd (strcat "Cumulative distance --> " (rtos d1)))
 (prompt cumd)
 (princ)
)

Thanks to an unknown author

____________________
Acad2005, Terramodel
 
If it is a line segment, just click on it with the Properties display opened. It will give the length, but you can't copy it. As MikeHalloran said about the pline, LIST will also give a copy-able .txt display with length, like this:
Command: list 1 found

LINE Layer: "0"
Space: Model space
Handle = 8b
from point, X= 35.5496 Y= 17.8966 Z= 0.0000
to point, X= 15.9339 Y= 19.0093 Z= 0.0000
Length = 19.6472, Angle in XY Plane = 177
Delta X = -19.6157, Delta Y = 1.1127, Delta Z = 0.0000

Remember, amateurs designed and built the ark...professionals designed and built the Titanic. - Steve
 
lpseifert,

nice tool...[thumbsup2]

Lothar

ADT 2004
ACAD 2002
 
Here's one that totals multiple line lengths all selected at once. The author is unknown but is not me. I have used this and modified it many times to solve various problems over the years.

(DEFUN c:GEL ( / attr elength ss dst cnt) ; Adds the lengths of selected lines, arcs, circles, polylines, or splines
(setq dst 0 cnt 0)(setvar "cmdecho" 0)
(princ "= Get length... Adds the lengths of selected lines, arcs, circles, polylines, or splines ")
;
(DEFUN attr (ent indx)(cdr (assoc indx ent)))
;
(DEFUN elength (ent / sa ea)
(cond
((= (attr ent 0) "LINE")(distance (attr ent 10)(attr ent 11)))
((= (attr ent 0) "ARC")(setq sa (attr ent 50) ea (attr ent 51))
(* (if (> ea sa)(- ea sa)(+ (- ea sa)(* 2 pi)))(attr ent 40)))
((= (attr ent 0) "CIRCLE")(* 2 pi (attr ent 40)))
((= (attr ent 0) "POLYLINE")(command "area" "e" (attr ent
-1))(getvar "perimeter"))
((= (attr ent 0) "SPLINE")(command "area" "e" (attr ent
-1))(getvar "perimeter"))
)
)
(if (setq ss (ssget '((-4 . "<or")(0 . "LINE")(0 . "ARC")(0 .
"CIRCLE")
(0 . "POLYLINE")(0 . "SPLINE")(-4 .
"or>"))))
(progn
(repeat (sslength ss)
(setq dst (+ dst (elength (entget (ssname ss cnt)))) cnt (+ cnt
1))
)
(princ (strcat "\n The length of the entity or entities selected
is "(rtos dst 2 8)" "))
)
(princ "\n Input error... ")
)
(princ)
)
 
I am new to LISP routines. I was able to get the post by lpseifert to work but not the one by IFRs? Any ideas why that could be?
 
Perhaps you could describe the fashion in which IFR's code fails to function for you.

Does it produce incorrect results?
Does it fail to run at all with no feedback?
Does it give an error of some sort?
How are you executing it?

You get the idea...

--------------------
How much do YOU owe?
--------------------
 
I dont know why the fuss about LISP because ACAD can do the job quicker. Turn all line segments into a polyline by doing a PEDIT and then do a LI command and check out the results in the history box.
 
I agree with Chicopee, but why bother converting to Plines? List works on any object, including Lines.

Women and cats will do as they please; men and dogs should just learn to live with that - Steve
 
Actually, it looks like my post was off subject. corvette63 needed to find the lengths of line segments that make up a line. If this is a polyline then all he will get is the total length. My apologies. My routine totals the lengths of lines, arcs, circles, polylines and splines.
 
Thank you for all of the input. Corvette63.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor