Code Red > AutoLISP (Vanilla / Visual)
Unloaded/Unresolved xRefs
MP:
I believe this should work - detaching xrefs that are unloaded or unresolvable - including drawings where the xrefs sport multiple instances which usually bombs the detach method and is not addressed in the other thread.
--- Code: ---(defun c:dump-xref-shat ( / e )
(vl-load-com)
(vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
(and
(eq :vlax-true (vla-get-isxref b))
(zerop (logand 32 (cdr (assoc 70 (entget (cdr (assoc 360 (entget (vlax-vla-object->ename b)))))))))
(progn
(foreach p (entget (vlax-vla-object->ename b))
(if (eq 331 (car p))
(progn
(vl-catch-all-apply 'vla-put-lock
(list
(vla-item
(vla-get-layers (vla-get-document b))
(cdr (assoc 8 (entget (setq e (cdr p)))))
)
:vlax-false
)
)
(vl-catch-all-apply 'entdel (list e))
)
)
)
(vl-catch-all-apply 'vla-detach (list b))
)
)
)
(princ)
)
--- End code ---
Cheers.
cmwade77:
Thank you, that will be great for backwards compatibility, in AutoCAD 2020 they did fix the issue with multiple instances (finally). Although I did just realize something major, the one routine that I am working on uses AcCoreConsole, so anything that relies on vl-load-com won't work.....grr.
But this will help when I have problem files to deal with.
MP:
You’re most welcome. Do let me know if you find issue with it. Thanks + cheers.
cmwade77:
--- Quote from: MP on May 17, 2019, 05:09:05 PM ---You’re most welcome. Do let me know if you find issue with it. Thanks + cheers.
--- End quote ---
As I said, my only issue is it won't run in AcCoreConsole, otherwise it seems like it should do the trick, will need a bit of testing though.
MP:
Could be eadily re-written using old school dxf type coding which will should work in AcCoreConsole.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version