Hi Ed Jobe, I understand that you are trying to help. I want to make very complicated filter test for overlap polylines. I am not in possition to explain full the idea because my English not allowed it. With few words the gov web page want to upload a dxf file for out topografic drawing . This drawing contains open and close overlap polylines , text , no blocks, and specific layer names. The problem is that we have a lot open close overlap polylines and for some reasong some times not overlap corectly and gives errors on the upload.
I have some ideas how the errors can be marked
1) with circles on the not overlap polyline (easy to see and fix the problem)
2) another way is to give me or in txt file or comand line a list o coordinates (x,y) of the not overlap vertex
3) Is the not overlap vertex is more than 2 (one next to other) can draw a polyline with red coloer and a global to mark the length with the problem.
This code is close. I dont want to draw the green circles, draw only the red and only to not overlap vertex. I did same test and this part need a little work because some times mark with red circle overlap vertex. The fuzz will be 0 all the times. We need to have 0 tolerance , we need 100% overlap polylines.
Code:
(defun c:ccmrk2 (/ askreal is_intersect double->lst _groupbyfuzz centrum ; local functions
CMRK-FUZZ ss data ename0 ename1 pline0 pline1 rgn1 rgnUnion doubles points cross NotCross grp)
(defun askreal (def)
(initget 4)
(if (not (setq ask (getreal (strcat "\ncmrk-fuzz <" (rtos def 2) ">: "))))
(setq ask def)
(setq def ask)
)
); askreal
(defun is_intersect (o0 o1 / r)
(if
(not
(vl-catch-all-error-p
(setq r (vl-catch-all-apply 'vlax-invoke (list o0 'IntersectWith o1 acExtendNone)))
)
)
r
)
); is_intersect
(defun double->lst (doubles / _index i lst)
(setq _index (lambda (b inc) (+ (* b 3) inc)))
(setq i -1)
(repeat (/ (length doubles) 3)
(setq i (1+ i))
(setq lst (cons (list (nth (_index i 0) doubles) (nth (_index i 1) doubles) (nth (_index i 2) doubles)) lst))
)
lst
); double->lst
; by jonronp
(defun _groupbyfuzz (l f / a b r)
(while (car l)
(setq a (car l))
(setq b (vl-remove-if-not '(lambda (x) (equal a x f)) l))
(foreach c (append (list a) b) (setq l (vl-remove c l)))
(setq r (cons b r))
)
r
); _groupbyfuzz
(defun centrum (g / l)
(mapcar
'(lambda (x y)
(/ (+ x y) 2)
)
(car
(setq l
(mapcar
'(lambda (f0)
(mapcar
'(lambda (f1)
(apply f0 (mapcar '(lambda (p) (f1 p)) g))
)
(list car cadr)
)
); lambda
(list 'min 'max)
)
); setq
); car
(cadr l)
); mapcar
); centrum
; here start c:cmrk2
(setvar "cmdecho" 0)
(command "._undo" "_begin")
(command "_layer" "_m" "Check_Mark" "_c" "90" "" "")
(setq cross nil)
(if (= (getvar "userr1") 0)
(setq def-fuzz (setvar "userr1" 1e-2))
(setq def-fuzz (getvar "userr1"))
)
(if (and
(setvar "userr1" (setq cmrk-fuzz (askreal def-fuzz)))
(setq ss (ssget '((0 . "lwpolyline") (70 . 1)))) ; select closed polylines
)
(progn
(setq data (mapcar '(lambda (ename) ename) (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))
(foreach ename0 (reverse (cdr (reverse data)))
(setq pline0 (vlax-ename->vla-object ename0))
(foreach ename1 (cdr (member ename0 data))
(setq pline1 (vlax-ename->vla-object ename1))
(if (setq doubles (is_intersect pline0 pline1))
(progn
(command ".region" "_si" (vlax-vla-object->ename (vla-copy pline0)))
(setq rgn0 (entlast))
(command ".region" "_si" (vlax-vla-object->ename (vla-copy pline1)))
(setq rgn1 (entlast))
(command "._union" rgn0 rgn1 "")
(setq rgnUnion (vlax-ename->vla-object (entlast)))
(if (and
(not (equal (vla-get-area rgnUnion) (+ (vlax-curve-getarea pline0) (vlax-curve-getarea pline1)) 0.0))
(setq points (double->lst doubles))
)
(setq cross (append cross points))
); if
;;------------------------- Jose L. G. G. Code -----------------------------------------------
(setq points (vlax-invoke rgnUnion 'IntersectWith rgnUnion acExtendNone))
(setq points (double->lst points))
(setq NotCross (append NotCross points))
(setq NotCross
(vl-remove-if
(function
(lambda (a)
(vl-some (function (lambda (b) (equal a b cmrk-fuzz))) cross)
)
)
NotCross
)
)
;;------------------------- Jose L. G. G. Code -----------------------------------------------
(vla-delete rgnUnion)
(vlax-release-object rgnUnion)
); progn
); if
(vlax-release-object pline1)
); foreach
(vlax-release-object pline0)
); foreach
(foreach grp (_groupbyfuzz cross cmrk-fuzz)
(entmake
(list
'(0 . "CIRCLE")
(cons '10 (centrum grp))
(cons '40 0.2)
)
); entmake
); foreach
;;------------------------- Jose L. G. G. Code -----------------------------------------------
(foreach grp NotCross
(entmake
(list
'(0 . "CIRCLE")
(cons '10 grp)
(cons '40 0.2)
(cons 62 1)
)
); entmake
)
;;------------------------- Jose L. G. G. Code -----------------------------------------------
); progn
); if
(command "._undo" "_end")
(setvar "cmdecho" 0)
(princ)
); c:ccmrk2
Reply With Quote Reply With Quote
I know that this is something very difficult.
Thanks