@АлексЮстасу
For correct results in coordinates in millions, I suggest that you temporarilly scale whole DWG from base WCS point 0,0 using scale factor 1e-8... Then when you get point(s), just multiply each point(s) coordinates with 1e+8 with using this syntax :
(mapcar (function (lambda ( x ) (mapcar (function (lambda ( y ) (* y 1e+8))) x))) pts), where pts is list of point(s) obtained from routine result... To make routine work faster, I removed all those zooms for which you stated as unneccessary, but I can't for sure guarantee that picking selection sets would perform correct - catching precisely only things crossing those start/end points of exploded entities, without selecting nearby other exploded things... So, here is my code - with just removed (zooms)...
(defun c:self-inters-overls ( / *error* unique isoobjs unisoobjs *lst* selfintlst ape ent cad obj1 el ss i e obj2 ellst ell sl lst )
(or
(not
(vl-catch-all-error-p
(vl-catch-all-apply
(function vlax-get-acad-object) nil
)
)
)
(vl-load-com)
)
(defun *error* ( m )
(if ape
(setvar (quote aperture) ape)
)
(if (and m (wcmatch (strcase m) "*EXIT*"))
(princ)
(if m
(progn
(prompt m)
(princ)
)
(if lst
(progn
(prompt "\nSelf-intersecting-overlapping points in WCS are : ")
(prompt "\n")
(read (vl-princ-to-string (unique lst 1e-6)))
)
(princ)
)
)
)
)
(defun unique ( lst fuzz / a ll )
(while (setq a (car lst))
(if (vl-some (function (lambda ( x ) (equal x a fuzz))) (cdr lst))
(setq ll (cons a ll) lst (vl-remove-if (function (lambda ( x ) (equal x a fuzz))) (cdr lst)))
(setq ll (cons a ll) lst (cdr lst))
)
)
(reverse ll)
)
(defun isoobjs ( s / ss i e enx rtn )
(setq ss (ssget "_X"))
(repeat (setq i (sslength ss))
(setq e (ssname ss (setq i (1- i))))
(if (and (not (ssmemb e s)) (not (vl-position (cons 60 1) (setq enx (entget e)))))
(progn
(entupd (cdr (assoc -1 (entmod (append enx (list (cons 60 1)))))))
(setq rtn (cons e rtn))
)
)
)
rtn
)
(defun unisoobjs ( *lst* )
(if *lst*
(foreach e *lst*
(entupd (cdr (assoc -1 (entmod (subst (cons 60 0) (cons 60 1) (entget e))))))
)
)
)
(defun selfintlst ( obj1 obj2 / lst rtn )
(setq lst
(vlax-invoke
(if (= (type obj1) (quote ename))
(vlax-ename->vla-object obj1)
obj1
)
(quote intersectwith)
(if (= (type obj2) (quote ename))
(vlax-ename->vla-object obj2)
obj2
)
acextendnone
)
)
(repeat (/ (length lst) 3)
(setq rtn
(cons
(list (car lst) (cadr lst) (caddr lst))
rtn
)
)
(setq lst (cdddr lst))
)
(reverse rtn)
)
(setq ape (getvar (quote aperture)))
(setvar (quote aperture) 1)
(if
(and
(setq ent (car (entsel "\nPick POLYLINE entity to get its self-intersecting-overlapping points...")))
(wcmatch (cdr (assoc 0 (entget ent))) "*POLYLINE")
)
(if
(not
(vl-catch-all-error-p
(vl-catch-all-apply
(function vlax-curve-getstartpoint)
(list ent)
)
)
)
(progn
(setq *lst* (isoobjs (ssadd ent)))
(vla-zoomextents (setq cad (vlax-get-acad-object)))
(setq obj1 (vlax-ename->vla-object ent))
(setq el (entlast))
(vla-explode obj1)
(while (wcmatch (cdr (assoc 0 (entget (entnext el)))) "VERTEX,SEQEND")
(setq el (entnext el))
)
(while (setq el (entnext el))
(if (setq ss (ssget "_C" (trans (vlax-curve-getstartpoint el) 0 1) (trans (vlax-curve-getstartpoint el) 0 1)))
(repeat (setq i (sslength ss))
(setq e (ssname ss (setq i (1- i))))
(if (= (cdr (assoc 0 (entget e))) "VERTEX")
(ssdel e ss)
(if (not (eq e (vlax-vla-object->ename obj1)))
(setq ell (cons e ell))
)
)
)
)
(if
(and
ss
(or
(> (sslength ss) 3)
(and
(= (sslength ss) 3)
(vl-some
(function
(lambda ( x )
(and
(not (equal (vlax-curve-getstartpoint x) (vlax-curve-getstartpoint el) 1e-6))
(not (equal (vlax-curve-getendpoint x) (vlax-curve-getstartpoint el) 1e-6))
)
)
)
ell
)
)
)
)
(setq lst (cons (vlax-curve-getstartpoint el) lst))
)
(setq ell nil)
(if (setq ss (ssget "_C" (trans (vlax-curve-getendpoint el) 0 1) (trans (vlax-curve-getendpoint el) 0 1)))
(repeat (setq i (sslength ss))
(setq e (ssname ss (setq i (1- i))))
(if (= (cdr (assoc 0 (entget e))) "VERTEX")
(ssdel e ss)
(if (not (eq e (vlax-vla-object->ename obj1)))
(setq ell (cons e ell))
)
)
)
)
(if
(and
ss
(or
(> (sslength ss) 3)
(and
(= (sslength ss) 3)
(vl-some
(function
(lambda ( x )
(and
(not (equal (vlax-curve-getstartpoint x) (vlax-curve-getendpoint el) 1e-6))
(not (equal (vlax-curve-getendpoint x) (vlax-curve-getendpoint el) 1e-6))
)
)
)
ell
)
)
)
)
(setq lst (cons (vlax-curve-getendpoint el) lst))
)
(setq ell nil)
(setq obj2 (vlax-ename->vla-object el))
(setq sl (vl-catch-all-apply (function selfintlst) (list obj1 obj2)))
(if (and sl (not (vl-catch-all-error-p sl)))
(progn
(setq sl (vl-remove-if (function (lambda ( x ) (equal x (vlax-curve-getstartpoint el) 1e-6))) sl)
sl (vl-remove-if (function (lambda ( x ) (equal x (vlax-curve-getendpoint el) 1e-6))) sl)
)
(if sl
(setq lst (append sl lst))
)
(setq sl nil)
)
)
(setq ellst (cons el ellst))
)
(foreach el ellst
(if (and el (not (vlax-erased-p el)))
(entdel el)
)
)
(vla-zoomprevious cad)
(unisoobjs *lst*)
)
(progn
(prompt "\nInvalid entity pick... Picked entity must be POLYLINE... Better luck next time...")
(exit)
)
)
(prompt "\nMissed... or invalid entity pick... Picked entity must be POLYLINE... Better luck next time...")
)
(*error* nil)
)
HTH.
M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)