PDA

View Full Version : lwpolyline length between specific vertexes



!!GEORGE!!
18th May 2010, 09:14 am
Hello,
I am using Civil 3d 2008 and i am looking for a way to "dimension" a polyline between specific vertexes.
For example if i have a polyline with 50 vertexes and i need to write the length between vertex 1 to 5, then 5 to 12, then 12 to 24 etc. I don't need the dimensions between every vertex but the length of the polyline from vertex i give to another vertex i give. This length must be writen above (in the middle) the measured length. Until now i was doing it manually. Break the polyline==> list==> add text with the length. But it takes to much time to do that. Is there any way to do that quicker?
Thanks to you all,
George.

Lee Mac
18th May 2010, 10:22 am
This will label them all - you can remove the ones you don't want:



(defun c:LabelSegs ( / *error* spc doc ent flg )
(vl-load-com)
;; Lee Mac ~ 18.05.10

(defun *error* ( msg )
(and flg (vla-EndUndomark doc))
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(princ))

(setq spc
(if
(or
(eq AcModelSpace
(vla-get-ActiveSpace
(setq doc
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
)
)
(eq :vlax-true (vla-get-MSpace doc))
)
(vla-get-ModelSpace doc)
(vla-get-PaperSpace doc)
)
)

(if
(setq ent
(CurveifFoo
(lambda ( x )
(eq "LWPOLYLINE"
(cdr (assoc 0 (entget x)))
)
)
"\nSelect LWPolyline to Label: "
)
)
(
(lambda ( n / der )
(setq flg (not (vla-StartUndoMark doc)))
(repeat (fix (vlax-curve-getEndParam ent))
(vla-put-rotation
(AddText spc
(rtos
(-
(vlax-curve-getDistatParam ent (setq n (1+ n)))
(vlax-curve-getDistatParam ent (1- n))
)
)
(polar
(vlax-curve-getPointatParam ent (- n 0.5))
(+
(setq der
(angle '(0. 0. 0.)
(vlax-curve-getFirstDeriv ent (- n 0.5))
)
)
(/ pi 2.)
)
(/ (getvar 'TEXTSIZE) 2.)
)
(getvar 'TEXTSIZE)
)
(MakeReadable der)
)
)
(setq flg (vla-EndUndomark doc))
)
(vlax-curve-getStartParam ent)
)
)
(princ)
)

(defun MakeReadable ( a )
(cond
(
(and (> a (/ pi 2)) (<= a pi))

(- a pi)
)
(
(and (> a pi) (<= a (/ (* 3 pi) 2)))

(+ a pi)
)
(
a
)
)
)

(defun AddText ( block str point height / o )
(vla-put-Alignment
(setq o
(vla-AddText block str
(vlax-3D-point point) height
)
)
acAlignmentMiddleCenter
)
(vla-put-TextAlignmentPoint o (vlax-3D-point point))
o
)

(defun CurveifFoo ( foo str / sel ent )
(while
(progn
(setq sel (entsel str))

(cond
(
(vl-consp sel)

(if (not (foo (setq ent (car sel))))
(princ "\n** Invalid Object Selected **")
)
)
)
)
)
ent
)

alanjt
18th May 2010, 01:49 pm
This thread may be of some interest. (http://www.cadtutor.net/forum/showthread.php?t=47105)

!!GEORGE!!
18th May 2010, 05:11 pm
Lee Mac and Alanjt, thanks for your quick responce. Unfortunately those lisps doesn't work for what i need to do. Maybe i didn't make my self very clear (my english are not so good). I attach a foto to make it more clear. Let's suppose i have the red lwpoline, and the points A,B,C,D. What i need to do is write the length of the polyline between the points A and B (101.70m), B-C (91.35m), C-D (151.42m), D-A (77.86m), not the "dimaligned" between the vertexes. I hope you can help me.
George.

alanjt
18th May 2010, 05:17 pm
http://www.theswamp.org/index.php?topic=32677.0

!!GEORGE!!
18th May 2010, 07:25 pm
Alanjt, thank you very much for your help. That will save me much time.
Is it posible the distance between the two points to be writen above the polyline and in the middle of the points?