TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: RGUS on November 17, 2012, 03:37:56 PM

Title: Automatically Update XREF
Post by: RGUS on November 17, 2012, 03:37:56 PM
Hi...
I was just wondering...
When I have an XREF drawing and a drawing containing that XREF opened ... if I were to change something on the XREF drawing, save it, and then change to the drawing containing the XREF, also opened, AutoCAD pops up a notification that I need to reload the XREF.

This is annoying, "of course I want to reload the XREF" I just changed it didn't I.
Is there a way to bypass this notification and automatically reload the XREF when I switch drawings.
AutoCAD must store somewhere, somehow that the XREF has changed, otherwise the notification bubble wouldn't pop up.
Why can't they have provided an option to update automatically.

Thanks
Deane

Title: Re: Automatically Update XREF
Post by: BlackBox on November 17, 2012, 09:53:29 PM
If a built-in solution exists, then I am unaware of it.

I agree that a system variable should exist (XrefReloadAuto?), which hooks the existing FileSystemWatcher that is instantiated for the parent directory of each external reference that exists within the Document Collection.

While much is unknown (or at least undocumented) about the code-behind that supports the external reference mechanism(s), as I understand it, they (Autodesk) need only hook the DocumentaBecameCurrent event in order to evaluate the value of the pseudo XrefReloadAuto system variable (thus effectively reloading external references automagically).

In order to do this via LISP, you'd need to implement your own DocManager reactor, in order to monitor the same DocumentBecameCurrent event, but rather than employ a FileSystemWatcher at drawing open you would instead possibly store each external reference's vl-File-Systime in a grouped pair (with the reference).

When the DocumentBecameCurrent event fires, test for updates to the stored list of external references and associated systimes. Also be sure to implement the necessary Command, or AcDb reactors in order to update your list of grouped pairs as needed.

My $0.02
Title: Re: Automatically Update XREF
Post by: RGUS on November 17, 2012, 11:15:20 PM
LOL Renderman... so why aren't you working for AutoDESK... if I understood what you said, then I wouldn't suggest it.
But... reading it over and over again... it seems to rely on some sort of internal reactor mechanism.
Bugger... and I thought it would be easy.
Thanks mate.
Title: Re: Automatically Update XREF
Post by: BlackBox on November 18, 2012, 01:14:51 AM
LOL Renderman... so why aren't you working for AutoDESK... if I understood what you said, then I wouldn't suggest it.
But... reading it over and over again... it seems to rely on some sort of internal reactor mechanism.
Bugger... and I thought it would be easy.
Thanks mate.

That is kind of you to say; not sure what the future has in store.  :-)

Sorry if my previous post was not clear... This can be done (even with LISP, with some help from a  .NET LispFunction), but there are trade offs.

Most notably the unexpected lag time when the application becomes unresponsive due to reloading one or more external references.

Another issue that could easily present itself, especially in a muti-user environment, is for you to be laying out some line work based upon the external reference, and another user modifies said reference drawing, and unexpectedly the line work you needed to reference goes missing.

Title: Re: Automatically Update XREF
Post by: irneb on November 18, 2012, 03:05:43 AM
I swear I've seen this exact same question before ... just cannot find the thread.
Title: Re: Automatically Update XREF
Post by: CAB on November 18, 2012, 11:32:07 AM
Did you look here?
http://goo.gl/gMpR9
Title: Re: Automatically Update XREF
Post by: irneb on November 18, 2012, 12:40:13 PM
Did you look here?
http://goo.gl/gMpR9

Yep, and used other keywords too. Even omitting the site specific modifier to see if it was on another forum. Still can't find it. Must've been named something I cannot think of just now.
Title: Re: Automatically Update XREF
Post by: BlackBox on November 18, 2012, 01:25:41 PM
In any event, just wanted to say "thanks, CAB!" For sharing that link - being relatively new to .NET I usually focus on self-teaching. Your suggestion pointed me toward one of the library threads which I could stand to learn a lot from.

Cheers! :beer:
Title: Re: Automatically Update XREF
Post by: RGUS on November 18, 2012, 05:39:37 PM
Thanks guys... looks like it ain't gonna be possible from my humble understand of coding... looking forward to the new release of the ACAD wishlist.