View Full Version : distance along a polyline?
AJSmith
19th Apr 2010, 12:47 pm
i have a polyline runing down my site as a chainage line is there away or finding far down the line (what chainage) im at ?
currently i trim the line and use the lengh in the properties is there a better way?
lpseifert
19th Apr 2010, 12:53 pm
Familiar with Vlisp? Explore vlax-curve-getDistAtPoint
You could try this, still a work in progress
;;;Report Station and offset of an alignment LPS 2010-02-26
(defun j (/ temperror *error* varlst oldvar uicon ent ename sta on-pt ox-pt ox-di
ang ang-test stra dotpos statxt tot)
(vl-load-com)
;;;===Error Trap====
(setq temperr *error*
*error* errortrap
varlst '("OSMODE" "UCSICON" "CMDECHO" )
oldvar (mapcar 'getvar vlst)
)
;;;====Error Trap=====
(setq uicon (getvar "ucsicon" ))
(setvar "osmode" 0)
;(vl-cmdf "UCS" "w")
(setq ent (entsel "\nSelect alignment: ")
ename (car ent))
;;;====Check if entsel is valid====
(if (not ent)
(progn
(alert "Missed... try again!")
(j)
)
)
;;;====End check===================
(setq sta (vlax-curve-getDistAtPoint ename
(setq on-pt (vlax-curve-getClosestPointTo ename
(setq ox-pt (trans (getpoint "\nPick Station//Offset point: " ) 1 0))
);end grtClosestPointTo
)
)
)
(setq ox-di (abs (distance (list (car on-pt)(cadr on-pt))(list (car ox-pt)(cadr ox-pt))));no 3D
ang (angle '(0 0 0) (vlax-curve-getFirstDeriv ename (vlax-curve-getParamAtPoint ename on-pt)))
)
;;;=====Test Left or Right=========
(entmake
(list (cons 0 "LINE")
(cons 10 on-pt)
(cons 11 (polar on-pt (+ ang (* 1.5 pi))100.0))
)
)
(setvar "ucsicon" 0)
(vl-cmdf "ucs" "ob" "l")
(entdel (entlast))
(setq ang-test (angtof (angtos (angle (trans on-pt 0 1)(trans ox-pt 0 1))) 3))
(vl-cmdf "ucs" "p")
(setvar "ucsicon" uicon)
(cond
((equal 0.0 (fix ox-di) 0.01)(setq dir " Point on alignment"))
((<= 0.0 ang-test pi)(setq dir " Rt"))
((> ang-test pi)(setq dir " Lt"))
('T (setq dir " "))
)
;;;======End Test===================
(setq stra (rtos sta 2 2 ))
(if (not (= stra "0.00"))
(progn
(setq dotpos (1+ (vl-string-search "." stra)))
(substr stra (- dotpos 2))
(if (>= (strlen stra) 6)
(setq statxt (strcat (substr stra 1 (- dotpos 3)) "+"(substr stra (- dotpos 2))))
(setq statxt (strcat (chr 48)"+" (substr stra (- dotpos 2))))
)
);progn
(setq statxt "0+00")
);if
(setq tot (vlax-curve-getDistAtPoint ename (vlax-curve-getEndPoint ename)))
(if
(or (= sta 0.0)(= sta tot))
(alert
(strcat "\nStation: " statxt
"\nOffset: "(rtos ox-di 2 2) dir
"\n\n Alert!\nThe offset point may be beyond the\nendpoints of the alignment;\nIf so, the reported data is incorrect"
)
)
(alert
(strcat "\nStation: " statxt
"\nOffset: "(rtos ox-di 2 2) dir
)
)
);if
(mapcar 'setvar varlst oldvar)
(princ)
);defun
(defun c:idox ()(j))
;;;====Error Trap====
(defun errortrap (msg)
(if oldvar (mapcar 'setvar varlst oldvar))
(setq *error* temperr)
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n<< Error: " msg " >>"))
)
(princ)
)
;;;====Error Trap====
(princ "Application loaded... Type IDOX to run.")
(princ)
or this, an oldie
;reports distance from beginning of a polyline LPS 8-8-08
(defun c:ids ()
(vl-load-com)
(command "ucs" "w")
(setq ename-pline (car (entsel "\nPick a Polyline:"))
vlaobject-pline (vlax-ename->vla-object ename-pline) ;make vla-object from entity name
pt1 (vlax-curve-getClosestPointTo vlaobject-pline (getpoint "\nPick point on Polyline: "))
;pt1 (getpoint "Pick point on Polyline: ")
sta (vlax-curve-getDistatPoint vlaobject-pline pt1)
sta-str (strcat "The distance from the start of the Polyline is " (rtos sta 2 2) "'")
);setq
(command "ucs" "p")
(alert Sta-str)
);defun
alanjt
19th Apr 2010, 02:43 pm
Put this one together not long ago...
http://www.theswamp.org/index.php?topic=32677.0
http://www.theswamp.org/screens/alanjt/dbp.gif
franksmaia
24th Oct 2010, 11:33 pm
Put this one together not long ago...
http://www.theswamp.org/index.php?topic=32677.0
http://www.theswamp.org/screens/alanjt/dbp.gif
Hello alanjt,
Could you please send another link to the lisp routine or send it to me? I really need this routine but the link points to a dead page.
Thank you very much.
Tiger
25th Oct 2010, 08:30 am
Hello alanjt,
Could you please send another link to the lisp routine or send it to me? I really need this routine but the link points to a dead page.
Thank you very much.
Franksmaia - the link is not dead, you just need to sign up for a Swamp-membership (free).
bass_mark00
25th Oct 2010, 09:42 am
Adam, you could also use the standard DIST command. You'll see after you've selected your first point that there's an option of MULTIPLE POINTS. This will allow you to click your way down the line to your destination and it will give you the length. It's not as slick as the lisp but it might be a quick solution in simple situations and curves can be included.
Powered by vBulletin™ Version 4.1.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.