Results 1 to 5 of 5

Thread: Comparing two polylines and marking differences

  1. #1
    Member
    Join Date
    2015-11
    Posts
    8
    Login to Give a bone
    0

    Default Comparing two polylines and marking differences

    Hello all,

    I am hoping someone has crossed this bridge before. I have some pipeline alignments (not Civil 3d, just polylines) that are many miles long. I want to be able to compare an existing polyline to a rerouted polyline alignment that would have dozens of areas that have been revised. I want to highlight those areas so I can readily see where changes have occurred in the alignment.

    Thanks for any help.

    John

  2. #2
    Active Member
    Join Date
    2009-03
    Posts
    63
    Login to Give a bone
    0

    Default Re: Comparing two polylines and marking differences

    I think is completely possible. Especially if they are "overlapping", kinda like it sounds like yours are. Basically you can iterate through each vertex on each polyline, if the point of a vertex has a matching point on the other polyline it gets skipped, if it doesn't, a marker gets created highlighting the deviation. What kind of marker are you wanting? for a really long polyline, personally I'd want something I could see from a zoomed out distance so I would suggest a ray starting at the point of deviation and extending out perpendicular to the next segment (if'n ya wanna get fancy) or just straight horizontal or vertical (if'n ya don't) Lemme know what you want for a marker and I'll see if I can caveman something together.

  3. #3
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    561
    Login to Give a bone
    0

    Default Re: Comparing two polylines and marking differences

    This will help if you dont have a pline -> co-ords lsp, just run twice for each pline then compare the (nth x lst1)(nth x lst2)

    Code:
    ; pline co-ords example
    ; By Alan H
    (defun getcoords (ent)
      (vlax-safearray->list
        (vlax-variant-value
          (vlax-get-property
        (vlax-ename->vla-object ent)
        "Coordinates"
          )
        )
      )
    )
     
    (defun co-ords2xy ()
    ; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
    (setq len (length co-ords))
    (setq numb (/ len 2)) ; even and odd check required
    (setq I 0)
    (repeat numb
    (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
    ; odd (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) ))
    (setq co-ordsxy (cons xy co-ordsxy))
    (setq I (+ I 2))
    )
    )
    
    ; program starts here
    (setq co-ords (getcoords (car (entsel "\nplease pick pline"))))
    (co-ords2xy) ; list of 2d points making pline
    
    ; returns a list named co-ordsxy
    (princ co-ordsxy)

  4. #4
    Active Member
    Join Date
    2009-03
    Posts
    63
    Login to Give a bone
    0

    Default Re: Comparing two polylines and marking differences

    This appears to work. Haven't tested extensively, let me know if it doesn't work as expected.
    This compares 2 LWPolylines (will not work for 2DPolylines or 3DPolylines, but can be made to do so if necessary).
    Makes 2 set of marks, if the routine finds a vertex without a matching vertex in the second polyline it draws a ray.
    The 2 polylines are selected arbitrarily from the selection set, so each marked point will need manually inspected for your purposes.
    The red ortho left rays are for the first polyline checked, the green ortho right rays are for the second.
    From here you can modify as you need to get whatever marks you want.

    Code:
    (vl-load-com)
    
    (defun c:CPL () (c:ComparePolylines))
    (defun c:ComparePolylines ( / ss pl1 pl2 pl:lst1 pl:lst2 a cnt chk)
     (setq ss (ssadd))
     (While (not (= (sslength ss) 2))
      (princ "\nSelect 2 LwPolylines: ")
      (setq ss (ssget (list (cons 0 "LWPOLYLINE"))))
      (if (not (= (sslength ss) 2)) (princ "\nMust Select 2 LWPolylines to compare"))
     )
     (setq pl1 (ssname ss 0) pl2 (ssname ss 1))
     (setq pl:lst1 (getcoords pl1) pl:lst2 (getcoords pl2))
    
     (foreach a pl:lst1
      (progn
       (setq cnt 0)
       (setq chk nil)
       (repeat (length pl:lst2)
        (if (and (= (car a) (car (nth cnt pl:lst2))) (= (cadr a) (cadr (nth cnt pl:lst2))))
         (setq chk T)
        )
        (setq cnt (1+ cnt))
       )
       (if (not chk)
        (entmakex (list (cons 0 "RAY") (cons 100 "AcDbEntity") (cons 100 "AcDbRay") (cons 62 1) (cons 10 a) '(11 -1.0 0.0 0.0)))
       )
      )
     )
    
     (foreach a pl:lst2
      (progn
       (setq cnt 0)
       (setq chk nil)
       (repeat (length pl:lst1)
        (if (and (= (car a) (car (nth cnt pl:lst1))) (= (cadr a) (cadr (nth cnt pl:lst1))))
         (setq chk T)
        )
        (setq cnt (1+ cnt))
       )
       (if (not chk)
        (entmakex (list (cons 0 "RAY") (cons 100 "AcDbEntity") (cons 100 "AcDbRay") (cons 62 3) (cons 10 a) '(11 1.0 0.0 0.0)))
       )
      )
     )
    
     (princ)
    )
    
    (defun getcoords (ent / lst1 lst2)
     (setq lst1 (vlax-safearray->list (vlax-variant-value (vlax-get-property (vlax-ename->vla-object ent) "Coordinates"))))
     (setq lst2 (list))
     (While lst1
      (setq lst2 (append lst2 (list (list (car lst1) (cadr lst1)) )))
      (setq lst1 (cddr lst1))
     )
     (if lst2 lst2 (princ))
    )
    
    (princ "\nComparePolylines Loaded, enter \"ComparePolylines\" or \"CPL\" to run.")
    (princ)

  5. #5
    Woo! Hoo! my 1st post
    Join Date
    2017-05
    Posts
    1
    Login to Give a bone
    0

    Default Re: Comparing two polylines and marking differences

    Is it possible to change "Ray" to circle?

Similar Threads

  1. Marking Menu for AutoCAD
    By Wish List System in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2016-11-28, 08:46 PM
  2. Replies: 0
    Last Post: 2016-11-21, 05:02 AM
  3. marking as I go
    By lucas in forum Design Review - General
    Replies: 1
    Last Post: 2007-10-01, 08:05 PM
  4. Replies: 3
    Last Post: 2006-07-28, 01:02 PM
  5. Marking forum read
    By kimheaver in forum Suggestions
    Replies: 0
    Last Post: 2004-03-26, 10:15 PM

Posting Permissions

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