
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm looking for a lisp that determines if lines/curves/polylines start end end on other lines. Most my drawings should never have a gap, all lines should start at the end of, or on another line/arc/polyline. I found a lisp that does this, but its old (1998) and no longer appears to be working right. The lisp flows fine but its giving me false positives. I was hoping someone could look at the code and repair it or point me to a current lisp that does this.
http://autocadtips1.com/2011/10/28/autolisp-find-and-mark-gaps/
" If you suspect that someone has been drafting and not using osnaps to snap to the endpoints of geometry, this routine will find these gaps and mark them with a red circle. It will even make a layer called “GAP” and put these red circles on that layer for you."
;| GAP.LSP locates and marks the ends of arcs, lines, and plines that are close but not exactly coincident. Gaps are marked by drawing circles on the GAP layer. You can select part of a drawing to check or press ENTER to check the whole drawing. These are the distances to control how the gaps are located Gap Limit = Gaps less than this, but more than fluff are marked Fluff = Gaps less than this are not marked Circle Size = Size of circle to mark gaps with Original routine by McNeel & Associates ----------------------------------------------------------------------- ----------------------------------------------------------------------- Modified by J. Tippit, SPAUG President 12/29/98 E-mail: cadpres@spaug.org Web Site: http://www.spaug.org ----------------------------------------------------------------------- ----------------------------------------------------------------------- Revisions: 12/29/98 Added ability to change Gap Limit, Fluff, & Circle Size Added CMDECHO, UNDO, OSMODE, & CURLAY Added a counter for the number of cicles that are drawn and other misc. prompts Changed the Gap layer to be RED ----------------------------------------------------------------------- |; (defun dxf (x e) (cdr (assoc x e))) ; Removes entities other than line, pline, arc from a selection set (defun checkss (ss / i) (setq i (sslength ss)) (while (> i 0) (setq i (1- i)) (setq ent (entget (ssname ss i))) (or (= "LINE" (dxf 0 ent)) (= "POLYLINE" (dxf 0 ent)) (= "ARC" (dxf 0 ent)) (ssdel (ssname ss i) ss) ) ) (if (> (sslength ss) 0) ss ) ) ; Returns the endpoints of lines, arcs and pines (defun endsofent (ent / v e1 e2) (cond ((= "LINE" (dxf 0 ent)) (list (dxf 10 ent) (dxf 11 ent)) ) ((= "ARC" (dxf 0 ent)) (list (polar (dxf 10 ent) (dxf 50 ent) (dxf 40 ent)) (polar (dxf 10 ent) (dxf 51 ent) (dxf 40 ent)) ) ) ((= "POLYLINE" (dxf 0 ent)) (setq v (entget (entnext (dxf -1 ent)))) (setq e1 (dxf 10 v)) (while (/= "SEQEND" (dxf 0 v)) (setq e2 (dxf 10 v)) (setq v (entget (entnext (dxf -1 v)))) ) (list e1 e2) ) ) ) ; gets a selection set of all entities near a point (defun ssat (pt dist) (ssget "c" (list (- (car pt) dist) (- (cadr pt) dist)) (list (+ (car pt) dist) (+ (cadr pt) dist)) ) ) ; Looks through a selection set and finds ends near but not at ends ; of other entities (defun markgaps (ss / i ends) (setq i (sslength ss)) (while (> i 0) (setq i (1- i)) (setq ent (entget (ssname ss i))) (setq ends (endsofent ent)) (princ ".") ; (princ "\n") ; (princ (car ends)) ; (princ " -- ") ; (princ (cadr ends)) (endsnear (car ends) gaplimit) (endsnear (cadr ends) gaplimit) ) ) (defun circle (pt r) (command "circle" pt r) (if (= CNT nil) (setq CNT 1) (setq CNT (1+ CNT)) ) ) ; Finds the entities near a point and marks their ends if they ; are also near the point (defun endsnear ( pt dist / ent ends) (if (setq sse (ssat pt dist)) (progn (setq j (sslength sse)) (while (> j 0) (setq j (1- j)) (setq ent (entget (ssname sse j))) (if (setq ends (endsofent ent)) (progn (setq d (distance (car ends) pt)) (if (< 0.0 d gaplimit) (circle pt circlesize) ) (setq d (distance (cadr ends) pt)) (if (< 0.0 d gaplimit) (circle pt circlesize) ) ) ) ) ) ) ) ; Main control function (defun c:GAP ( / ss ) (setvar "cmdecho" 0) (command "._undo" "be") (setq #OSMOD (getvar "osmode")) (setvar "osmode" 0) (setq #CURLA (getvar "clayer")) (setq CNT nil) (if (= gaplimit nil) (or (setq gaplimit (getdist "\nSet Gap Limit <1.0>: ")) (setq gaplimit 1.0) ) (progn (setq gaplimit2 gaplimit) (or (setq gaplimit (getdist (strcat "\nSet Gap Limit <" (rtos gaplimit 2 1) ">: "))) (setq gaplimit gaplimit2) ) ) ) (if (= fluff nil) (or (setq fluff (getdist "\nSet Fluff <0.0001>: ")) (setq fluff 0.0001) ) (progn (setq fluff2 fluff) (or (setq fluff (getdist (strcat "\nSet Fluff <" (rtos fluff 2 4) ">: "))) (setq fluff fluff2) ) ) ) (if (= circlesize nil) (or (setq circlesize (getdist "\nSet Circle Size <2.0>: ")) (setq circlesize 2.0) ) (progn (setq circlesize2 circlesize) (or (setq circlesize (getdist (strcat "\nSet Circle Size <" (rtos circlesize 2 1) ">: "))) (setq circlesize circlesize2) ) ) ) (command "._layer" "m" "GAP" "c" "1" "GAP" "") (princ "\nSelect objects or <ENTER> for all: ") (or (and (setq ss (ssget)) (setq ss (checkss ss)) ) (setq ss (ssget "x" '((-4 . "<OR") (0 . "LINE") (0 . "ARC") (0 . "POLYLINE") (-4 . "OR>") ) ) ) ) (princ "\nChecking for Gaps - please wait") (markgaps ss) (princ "done!") (if (/= CNT nil) (princ (strcat "\n" (itoa CNT) " Circles drawn.")) (princ "\nNo Gaps found.") ) (setvar "clayer" #CURLA) (setvar "osmode" #OSMOD) (command "._undo" "e") (setvar "cmdecho" 1) (princ) ) (prompt "\nLOCATE GAPS is loaded... type GAP to start!") (princ)
Here is a file that I have been testing it on. White lines it gives the correct gaps, but for green lines its giving me false positives.
Solved! Go to Solution.