Author Topic: Unloaded/Unresolved xRefs  (Read 632 times)

0 Members and 1 Guest are viewing this topic.

cmwade77

  • Swamp Rat
  • Posts: 1206
Unloaded/Unresolved xRefs
« on: May 16, 2019, 06:44:21 PM »
Ok, I will probably end up having to roll my own, but in the interest of not reinventing the wheel, does anyone have a routine that automatically detaches any xrefs that are either unloaded, unresolved or not found?

We find that we are getting more and more drawings with almost circular xRefs that have some unloaded and to try to get rid of those is complicated.

MSTG007

  • Water Moccasin
  • Posts: 2398
  • I can't remeber what I already asked! I need help!
Re: Unloaded/Unresolved xRefs
« Reply #1 on: May 17, 2019, 08:09:32 AM »
lol.... please let me know if you find something. that is all to common here.
Autodesk Infrastructure Design Suite 2019

ronjonp

  • Needs a day job
  • Posts: 7028
Re: Unloaded/Unresolved xRefs
« Reply #2 on: May 17, 2019, 09:47:52 AM »

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

MP

  • Seagull
  • Posts: 17454
Re: Unloaded/Unresolved xRefs
« Reply #3 on: May 17, 2019, 03:39:05 PM »
Pretty easy. If an xref is unloaded the xref block defís count property will be zero, if it canít be resolved (eg path nfg) the count will be 1. Before performing the detach method delete all instances (cdrs of 331 groups in the xref block defís DXF data) of the xref (the previously will find multiples as well as nested) lest the detach method fail. Cheers.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

roy_043

  • Water Moccasin
  • Posts: 1721
  • BricsCAD 18
Re: Unloaded/Unresolved xRefs
« Reply #4 on: May 17, 2019, 04:04:49 PM »
Regarding unloaded/unresolved:
Since a resolved xref may contain a single object, relying on the count property is risky.

BTW: In BricsCAD there are some dedicated functions for this purpose:
vla-get-isresolved
vla-get-isunloaded

MP

  • Seagull
  • Posts: 17454
Re: Unloaded/Unresolved xRefs
« Reply #5 on: May 17, 2019, 04:09:02 PM »
In 30+ years of AutoCAD use and support Iíve never encountered an xref with 1 object so I consider the risk inconsequential. Kudos to Bricscad.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

cmwade77

  • Swamp Rat
  • Posts: 1206
Re: Unloaded/Unresolved xRefs
« Reply #6 on: May 17, 2019, 04:10:50 PM »
In 30+ years of AutoCAD use and support Iíve never encountered an xref with 1 object so I consider the risk inconsequential. Kudos to bricscad tho.
Sadly, I have and these are files from other companies....yes, I know it doesn't make much sense to do that, but it does happen.

MP

  • Seagull
  • Posts: 17454
Re: Unloaded/Unresolved xRefs
« Reply #7 on: May 17, 2019, 04:13:10 PM »
Well then one has to verify the path (including relative paths) is unresolvable and / or determine a file is unreolsvable via group 70 states yada
« Last Edit: May 17, 2019, 04:21:18 PM by MP »
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

cmwade77

  • Swamp Rat
  • Posts: 1206
Re: Unloaded/Unresolved xRefs
« Reply #8 on: May 17, 2019, 04:22:39 PM »
Well then one has to verify the path (including relative paths) is unresolvable and / or determine a file is unreolsvable via group 70 states yada
In other words, the final code at the link ronjonp posted above?

MP

  • Seagull
  • Posts: 17454
Re: Unloaded/Unresolved xRefs
« Reply #9 on: May 17, 2019, 04:24:16 PM »
Sure
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

MP

  • Seagull
  • Posts: 17454
Re: Unloaded/Unresolved xRefs
« Reply #10 on: May 17, 2019, 05:01:43 PM »
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: [Select]
(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)
)

Cheers.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

cmwade77

  • Swamp Rat
  • Posts: 1206
Re: Unloaded/Unresolved xRefs
« Reply #11 on: May 17, 2019, 05:05:07 PM »
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.
« Last Edit: May 17, 2019, 05:08:43 PM by cmwade77 »

MP

  • Seagull
  • Posts: 17454
Re: Unloaded/Unresolved xRefs
« Reply #12 on: May 17, 2019, 05:09:05 PM »
Youíre most welcome. Do let me know if you find issue with it. Thanks + cheers.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

cmwade77

  • Swamp Rat
  • Posts: 1206
Re: Unloaded/Unresolved xRefs
« Reply #13 on: May 17, 2019, 05:10:51 PM »
Youíre most welcome. Do let me know if you find issue with it. Thanks + cheers.
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

  • Seagull
  • Posts: 17454
Re: Unloaded/Unresolved xRefs
« Reply #14 on: May 17, 2019, 05:11:31 PM »
Could be eadily re-written using old school dxf type coding which will should work in AcCoreConsole.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox