+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
  1. #1
    Full Member
    Using
    Land Desktop 2009
    Join Date
    Sep 2011
    Posts
    55

    Default Find points pairs with distance tolerance

    Registered forum members do not see this ad.

    Hi lisp masters.I have searched here a lot but could'nt find a lisp which can identify
    almost duplicate points,what i found are duplicate finders.Say i need to know which points are closer by less than 5meters(or any number tolerance). We always receive drawings with many GPS XY coordinates with plenty multiple observations/coordinates which should count as one. We need exact counting.
    Thanks for help.

  2. #2
    Super Moderator SLW210's Avatar
    Computer Details
    SLW210's Computer Details
    Operating System:
    Windows 7 PRO
    Computer:
    IBM Lenovo
    Motherboard:
    ACPI x86
    CPU:
    Pentium(R) Dual-Core CPU E5500 @ 2.80GHz
    RAM:
    4 GB RAM
    Graphics:
    Nvidia Quadro 600 1GB
    Primary Storage:
    300 GB
    Secondary Storage:
    650GB
    Monitor:
    ThinkVision 24"
    Discipline
    Multi-disciplinary
    SLW210's Discipline Details
    Occupation
    Design Draftsman
    Discipline
    Multi-disciplinary
    Details
    Mostly do drafting related to manufacturing. From doing site layouts with proposed updates, additions and renovations to be budgeted and submitted for bid, to updating and changing existing drawings to reflect maintenance and repair/revision work done on site.
    Using
    AutoCAD 2011
    Join Date
    May 2007
    Location
    South Florida, USA
    Posts
    10,292

    Default

    I moved this to the AutoLISP, Visual LISP & DCL forum.
    “A narrow mind and a fat head invariably come on the same person” Zig Zigler



  3. #3
    Senior Member ketxu's Avatar
    Computer Details
    ketxu's Computer Details
    Operating System:
    Sorry, my English not well :(
    Computer:
    Sorry, my English not well :(
    Motherboard:
    Sorry, my English not well :(
    CPU:
    Sorry, my English not well :(
    RAM:
    Sorry, my English not well :(
    Graphics:
    Sorry, my English not well :(
    Primary Storage:
    Sorry, my English not well :(
    Secondary Storage:
    Sorry, my English not well :(
    Monitor:
    Sorry, my English not well :(
    Using
    AutoCAD 2007
    Join Date
    Sep 2010
    Location
    Sorry, my English not well :(
    Posts
    197

    Default

    Why don't you post your drawing, and what is the result that you want?

  4. #4
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,644

    Default

    <Limited testing> ------->Further testing resulted in FAILURE to give accurate count
    Code:
    (defun c:test  (/ seek fuzz cnt i plst)
    (vl-load-com)
    (defun seek  (pt fz lst / sk lst)
                (setq sk   (ssget "_C"
                                  (polar pt (* pi 0.25) (* fz (sqrt 2)))
                                  (polar pt (* pi 1.25) (* fz (sqrt 2)))
                                  '((0 . "POINT"))))
                (repeat (sslength sk)
                      (setq lst (cons (ssname sk 0) lst))
                      (ssdel (ssname sk 0) sk))
                lst
                )
          (if (and (setq fuzz (getdist "\nEmter Fuzz Value: "))
                   (setq plst nil
                         cnt  0
                         ss   (ssget "_X" (list '(0 . "POINT")(cons 410 (getvar 'Ctab))))))
                (progn (vla-zoomextents (vlax-get-acad-object))
                      (repeat (setq i (sslength ss))
                             (setq en (ssname ss (setq i (1- i))))
                             (if (not (member en plst))
                                   (setq plst (seek (cdr (assoc 10
                                                                (entget en)))
                                                    fuzz
                                                    plst)
                                         cnt  (1+ cnt))(entmod (subst (cons 8 "DuplicatePoints")
                                                                      (assoc 8 (entget en)) (entget en))))
                             )
                       (princ (strcat "\n"
                                      (itoa cnt)
                                      " Points Found")))
                )
          (princ)
          )
    UPDATED to include place duplicates on Layer "DuplicatePoints"
    :::::Code Failure: :::::
    Last edited by pBe; 17th Mar 2012 at 11:35 am. Reason: Seek again/Select All points on current tab

  5. #5
    Forum Deity David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    2,082

    Default

    I'd try:

    Code:
    (defun c:findpt (/ fuzz ss bp ps en pp) ; ts is global
      (initget 7)
      (setq fuzz (getdist "\nTolerance Distance:   "))
      (and (princ "\nSelect Base Point:   ")
           (setq ss (ssget '((0 . "POINT"))))
           (= (sslength ss) 1)
           (setq bp (cdr (assoc 10 (entget (ssname ss 0)))))
           (setq ps (ssget "_C" (list (- (car bp) fuzz) (- (cadr bp) fuzz))
                                (list (+ (car bp) fuzz) (+ (cadr bp) fuzz))
                               '((0 . "POINT"))))
           (setq ts (ssadd))
           (while (setq en (ssname ps 0))
                  (setq pp (cdr (assoc 10 (entget en))))
                  (and (not (equal bp pp))
                       (<= (distance bp pp) fuzz)
                       (ssadd en ts))
                  (ssdel en ps))
           (prin1 (sslength ts)))
      (prin1))

    I don't think that the "W" ssget filter will return correct results. -David

    Also, please remember that point values are calculated in 3D
    R12 (Dos) - A2K

  6. #6
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,644

    Default

    You may have a point there David...

    I'll have a look-see. tnx

  7. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    16,962

    Default

    Here is a 'Divide and Conquer' method:

    Code:
    (defun c:ptcount ( / a b d e f i s x y )
    
        (setq f  5.0 ;; Tolerance
              d '(8 . "$DUPLICATE-POINTS$") ;; Duplicate Points Layer
        )
        (if (setq s (ssget "_X" '((0 . "POINT") (410 . "Model"))))
            (progn
                (setq a
                    (vl-sort
                        (repeat (setq i (sslength s))
                            (setq e (entget (ssname s (setq i (1- i))))
                                  a (cons (cons (cdr (assoc 10 e)) e) a)
                            )
                        )
                       '(lambda ( a b ) (<= (caar a) (caar b)))
                    )
                )
                (while (setq x (car a))
                    (setq a (cdr a)
                          b a
                    )
                    (while (and (setq y (car b)) (<= (- (caar y) (caar x)) f))
                        (if (<= (distance (car x) (car y)) f)
                            (progn
                                (entmod (subst d (assoc 8 (cdr y)) (cdr y)))
                                (ssdel (cdr (assoc -1 (cdr y))) s)
                            )
                        )
                        (setq b (cdr b))
                    )
                )
                (princ (strcat "\n" (itoa (sslength s)) " Distinct Points to a Tolerance of " (rtos f 2 15)))
            )
        )
        (princ)
    )
    Duplicate points will be placed on a separate layer.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  8. #8
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,644

    Default

    Updated the code [post #4]


    Unlike Davids and LMs code that used distance function.I opted to use llist to control selection, that way i dont neet to take into account the Z value. but still osmode whould be set and current zoom will be a factor hee.

  9. #9
    Full Member
    Using
    Land Desktop 2009
    Join Date
    Sep 2011
    Posts
    55

    Default

    Tanks good guys pBe,David,LeeMac i'll try them.
    @ketxu here's my prob..
    http://www.4shared.com/photo/tTI3tUks/AcadDup.html

  10. #10
    Full Member
    Using
    Land Desktop 2009
    Join Date
    Sep 2011
    Posts
    55

    Default

    Registered forum members do not see this ad.

    @LM.Can we have a prompt for input of tolerance and color of the new layer?
    if not too much of asking .thanks
    Yours WORKED VERY FINE. I just change 'setq f 5' to other number for tolerance
    Last edited by ctdlc888; 18th Mar 2012 at 02:54 am.

Similar Threads

  1. REQ: Place points and cumulative distance (text) on polyline, every X distance
    By enthralled in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 7th Mar 2012, 11:28 am
  2. Measure distance between two intersection points
    By nguyenkaca in forum AutoLISP, Visual LISP & DCL
    Replies: 22
    Last Post: 19th Sep 2011, 12:46 pm
  3. distance between points in lines ?
    By yajis_narif in forum AutoLISP, Visual LISP & DCL
    Replies: 22
    Last Post: 22nd May 2011, 09:20 pm
  4. 2D distance between 3D points
    By Tyke in forum AutoCAD General
    Replies: 10
    Last Post: 1st Nov 2010, 05:42 pm
  5. distance between points
    By salman in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 17th Jun 2009, 04:42 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