+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Full Member AJSmith's Avatar
    Discipline
    Civil
    AJSmith's Discipline Details
    Occupation
    CAD Technician
    Discipline
    Civil
    Using
    AutoCAD 2010
    Join Date
    Sep 2009
    Location
    Nottingham, UK
    Posts
    81

    Unhappy distance along a polyline?

    Registered forum members do not see this ad.

    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?
    CAD Technician
    A-one+ - PDT Design Structures

  2. #2
    Forum Deity
    Using
    Civil 3D 2008
    Join Date
    Sep 2006
    Location
    Pittsburgh, PA, USA
    Posts
    3,581

    Default

    Familiar with Vlisp? Explore vlax-curve-getDistAtPoint

    You could try this, still a work in progress
    Code:
    ;;;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
    Code:
    ;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
    Last edited by lpseifert; 19th Apr 2010 at 01:09 pm.

  3. #3
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2011
    Join Date
    Apr 2008
    Posts
    6,015

    Default

    Put this one together not long ago...

    http://www.theswamp.org/index.php?topic=32677.0


    DropBox | finding the light...
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  4. #4
    Forum Newbie
    Using
    AutoCAD 2009
    Join Date
    Oct 2010
    Posts
    1

    Default

    Quote Originally Posted by alanjt View Post
    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.

  5. #5
    Super Moderator Tiger's Avatar
    Computer Details
    Tiger's Computer Details
    Operating System:
    Windows 7 Enterprise 64 bit
    Computer:
    Dell Precision M4500
    CPU:
    Intel Core i5 2.40GHz
    RAM:
    8GB
    Graphics:
    NVIDIA Quadro FX 880M
    Primary Storage:
    280 GB
    Monitor:
    2 x Samsung SyncMaster 2443 24''
    Using
    AutoCAD 2012
    Join Date
    Nov 2006
    Location
    Sthlm, Sweden
    Posts
    4,595

    Default

    Quote Originally Posted by franksmaia View Post
    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).
    Life doesn't suck, although we all go through periods when it may be easier to think that, than to discern the solution to whatever problem is the most formidable
    at the moment in one's personal UCS.
    Go to PLAN view instead. - Dadgad

  6. #6
    Full Member
    Using
    AutoCAD 2012
    Join Date
    Aug 2010
    Location
    Richmond, Surrey, UK
    Posts
    51

    Default

    Registered forum members do not see this ad.

    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.

Similar Threads

  1. Identify a polyline by a point inside this polyline
    By wkplan in forum AutoLISP, Visual LISP & DCL
    Replies: 25
    Last Post: 18th Aug 2009, 07:09 pm
  2. Distance
    By fostertom in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 4
    Last Post: 8th Mar 2009, 08:32 pm
  3. Block Distance From Nearest Point on a Polyline
    By wannabe in forum AutoLISP, Visual LISP & DCL
    Replies: 65
    Last Post: 13th Jan 2009, 09:04 pm
  4. automatic distance
    By gazzalp in forum AutoLISP, Visual LISP & DCL
    Replies: 57
    Last Post: 19th Dec 2008, 12:49 am
  5. X distance
    By FazBear in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 1st Oct 2008, 08:46 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts