AJSmith Posted April 19, 2010 Share Posted April 19, 2010 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? Quote Link to comment Share on other sites More sharing options...
lpseifert Posted April 19, 2010 Share Posted April 19, 2010 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 Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 19, 2010 Share Posted April 19, 2010 Put this one together not long ago... http://www.theswamp.org/index.php?topic=32677.0 Quote Link to comment Share on other sites More sharing options...
franksmaia Posted October 24, 2010 Share Posted October 24, 2010 Put this one together not long ago... http://www.theswamp.org/index.php?topic=32677.0 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. Quote Link to comment Share on other sites More sharing options...
Tiger Posted October 25, 2010 Share Posted October 25, 2010 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). Quote Link to comment Share on other sites More sharing options...
bass_mark00 Posted October 25, 2010 Share Posted October 25, 2010 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.