Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reload only Loaded Xrefs?

28 REPLIES 28
Reply
Message 1 of 29
Anonymous
715 Views, 28 Replies

Reload only Loaded Xrefs?

How would i reload all xrefs that are currently loaded? Frequently we
unload xrefs for whatever reason though they are still there. I now have a
command that reloads all xrefs (like after a change has been made), but also
reloads the ones that are unloaded. I want to skip the ones that are
unloaded. Any ideas?

--
Thanks in advance
Andy

"Are You A Good Person?"
take the test -> www.GoodPersonTest.com
28 REPLIES 28
Message 2 of 29
Anonymous
in reply to: Anonymous

Here is what I use.

(defun c:ReloadLoadedXrefs (/ EntData)

(vlax-for i (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(if
(and
(= (vla-get-IsXref i) :vlax-true)
(setq EntData (entget (tblobjname "block" (vla-get-Name i))))
(= (logand 32 (cdr (assoc 70 EntData))) 32)
)
(vla-Reload i)
)
)
(princ)
)

--

Tim
"A blind man lets nothing block his vision."



"A. Lawniczak" wrote in message
news:5083551@discussion.autodesk.com...
How would i reload all xrefs that are currently loaded? Frequently we
unload xrefs for whatever reason though they are still there. I now have a
command that reloads all xrefs (like after a change has been made), but also
reloads the ones that are unloaded. I want to skip the ones that are
unloaded. Any ideas?

--
Thanks in advance
Andy

"Are You A Good Person?"
take the test -> www.GoodPersonTest.com
Message 3 of 29
Anonymous
in reply to: Anonymous

thanks a bunch - works great!

--
Thanks in advance
Andy

"Are You A Good Person?"
take the test -> www.GoodPersonTest.com

"T.Willey" wrote in message
news:5083561@discussion.autodesk.com...
Here is what I use.

(defun c:ReloadLoadedXrefs (/ EntData)

(vlax-for i (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(if
(and
(= (vla-get-IsXref i) :vlax-true)
(setq EntData (entget (tblobjname "block" (vla-get-Name i))))
(= (logand 32 (cdr (assoc 70 EntData))) 32)
)
(vla-Reload i)
)
)
(princ)
)

--

Tim
"A blind man lets nothing block his vision."



"A. Lawniczak" wrote in message
news:5083551@discussion.autodesk.com...
How would i reload all xrefs that are currently loaded? Frequently we
unload xrefs for whatever reason though they are still there. I now have a
command that reloads all xrefs (like after a change has been made), but also
reloads the ones that are unloaded. I want to skip the ones that are
unloaded. Any ideas?

--
Thanks in advance
Andy

"Are You A Good Person?"
take the test -> www.GoodPersonTest.com
Message 4 of 29
Anonymous
in reply to: Anonymous

You're welcome.

--

Tim
"A blind man lets nothing block his vision."



"A. Lawniczak" wrote in message
news:5083596@discussion.autodesk.com...
thanks a bunch - works great!

--
Thanks in advance
Andy

"Are You A Good Person?"
take the test -> www.GoodPersonTest.com

"T.Willey" wrote in message
news:5083561@discussion.autodesk.com...
Here is what I use.

(defun c:ReloadLoadedXrefs (/ EntData)

(vlax-for i (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(if
(and
(= (vla-get-IsXref i) :vlax-true)
(setq EntData (entget (tblobjname "block" (vla-get-Name i))))
(= (logand 32 (cdr (assoc 70 EntData))) 32)
)
(vla-Reload i)
)
)
(princ)
)

--

Tim
"A blind man lets nothing block his vision."



"A. Lawniczak" wrote in message
news:5083551@discussion.autodesk.com...
How would i reload all xrefs that are currently loaded? Frequently we
unload xrefs for whatever reason though they are still there. I now have a
command that reloads all xrefs (like after a change has been made), but also
reloads the ones that are unloaded. I want to skip the ones that are
unloaded. Any ideas?

--
Thanks in advance
Andy

"Are You A Good Person?"
take the test -> www.GoodPersonTest.com
Message 5 of 29
mgreist
in reply to: Anonymous

Tim:

This works pretty well but I get a fatal error whenever one of the xrefs is a nested file that recently had an xref reloaded.

For example:

X_grid.dwg is attached to X_plan.dwg which is then attached to my output sheet A1-1.dwg. For whatever reason, someone changed the attributes (lineweights, colors) of X_grid.dwg inside the X_plan.dwg file so in order to fix this, I detach and reattach X_grid.dwg. I then Save X_Plan.dwg and try reloading all loaded xrefs in A1-1.dwg which causes a Fatal Error.

Have you ever had this problem?
Message 6 of 29
Anonymous
in reply to: Anonymous

I'm going to assume you are talking to me (I can only see your post in my
reader). I don't nest xrefs, so I wouldn't have come across this issue. I
will see if I have some time to look into it, right now it will have to
wait, sorry.

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5386746@discussion.autodesk.com...
Tim:

This works pretty well but I get a fatal error whenever one of the xrefs is
a nested file that recently had an xref reloaded.

For example:

X_grid.dwg is attached to X_plan.dwg which is then attached to my output
sheet A1-1.dwg. For whatever reason, someone changed the attributes
(lineweights, colors) of X_grid.dwg inside the X_plan.dwg file so in order
to fix this, I detach and reattach X_grid.dwg. I then Save X_Plan.dwg and
try reloading all loaded xrefs in A1-1.dwg which causes a Fatal Error.

Have you ever had this problem?
Message 7 of 29
scgham
in reply to: Anonymous

Did you worked it out Tim?
I am having the same problem with the code, it works fine in some dwgs, but other times it crashes the dwg with an error just before the crash saying:
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on unknown exception
Message 8 of 29
Anonymous
in reply to: Anonymous

I haven't had any time. I'm a drafter by day, and a coder by night. Will
see if I can.

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5406492@discussion.autodesk.com...
Did you worked it out Tim?
I am having the same problem with the code, it works fine in some dwgs, but
other times it crashes the dwg with an error just before the crash saying:
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on unknown exception
Message 9 of 29
MSBryan
in reply to: Anonymous

I made a simple macro that appears to work fine... not sure if it will help in this case but it reloads my xrefs just fine and I know we've had nested xrefs as well...

I just made a new button using the (omg) cui editor and placed this macro in the approprite field.

^C^C-xref;r;*;

hope it helps
Message 10 of 29
Anonymous
in reply to: Anonymous

See if this one works for you. It did on my little test drawing here.

(defun c:ReloadXrefsLoaded (/ ActDoc BlkCol XrefList BlkEntData)

(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(setq BlkCol (vla-get-Blocks ActDoc))
(vlax-for Blk BlkCol
(if (= (vla-get-IsXref Blk) :vlax-true)
(setq XrefList (cons (cons (vla-get-Name Blk) Blk) XrefList))
)
)
(vlax-for Lo (vla-get-Layouts ActDoc)
(vlax-for Obj (vla-get-Block Lo)
(if
(and
(= (vla-get-ObjectName Obj) "AcDbBlockReference")
(setq tempList (assoc (vla-get-Name Obj) XrefList))
)
(progn
(setq EntData (entget (tblobjname "block" (vla-get-Name Obj))))
(if (equal (logand (cdr (assoc 70 EntData)) 32) 32)
(vla-Reload (cdr tempList))
)
)
)
)
)
(princ)
)

--

Tim
"A blind man lets nothing block his vision."


"T.Willey" wrote in message
news:5407135@discussion.autodesk.com...
I haven't had any time. I'm a drafter by day, and a coder by night. Will
see if I can.

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5406492@discussion.autodesk.com...
Did you worked it out Tim?
I am having the same problem with the code, it works fine in some dwgs, but
other times it crashes the dwg with an error just before the crash saying:
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on unknown exception
Message 11 of 29
scgham
in reply to: Anonymous

😞

Unfortunately, it still crashes Autocad, but may be it's much closer, now it does not give the error message, and only crashes when used twice !!!

Thanks a lot for your input till now.
Message 12 of 29
scgham
in reply to: Anonymous

Thanks MBryan..
I'm sure your code would work fine, but we are talking about a code to reload only loaded xrefs, i.e: exclude unloaded xrefs which can't be done through the ordinary "-xref" command.
Message 13 of 29
Anonymous
in reply to: Anonymous

I have tried it on a drawing with only one xref loaded, and a couple nested,
and one that can't be found, and I get no errors. How is your drawing set
up? Can you post it (if big don't worry about it)?

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5407862@discussion.autodesk.com...
:-(

Unfortunately, it still crashes Autocad, but may be it's much closer, now it
does not give the error message, and only crashes when used twice !!!

Thanks a lot for your input till now.
Message 14 of 29
scgham
in reply to: Anonymous

here it is...
Do you need the xrefs?
Message 15 of 29
scgham
in reply to: Anonymous

and this is one xref...
Message 16 of 29
scgham
in reply to: Anonymous

the second...
Message 17 of 29
scgham
in reply to: Anonymous

the last...
Remember to change something in the xrefs layers before applying the code, when you apply the code twice autocad will crash if you try to save or exit.

thanks a lot...
Message 18 of 29
Anonymous
in reply to: Anonymous

There must be something different in your setup then. I changed some layers
to a different color, then I ran the code twice, worked nicely. Then I ran
one of my routines which changes all layers for the xref selected, ran the
reload code twice, and acad is still open and working. Sorry I can
reproduce your error, so I don't know how to fix the code. Here is my
command line to show what I'm talking about.

Command: '_layer

Command: RELOADXREFSLOADED

Command:
Command: RELOADXREFSLOADED

Command:
Command:
Command:
Command: _xr-c
Initializing...
Select xref to change color of all layers:

Command: RELOADXREFSLOADED

Command:
Command: RELOADXREFSLOADED

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5409119@discussion.autodesk.com...
the last...
Remember to change something in the xrefs layers before applying the code,
when you apply the code twice autocad will crash if you try to save or exi
Message 19 of 29
scgham
in reply to: Anonymous

Thanks a lot Tim,
But did you load all the xrefs that i posted?
Did you unload one of them before using the code?
Did you try to save the dwg after applying the code multiple times, the problem occurs when saving, and some of the xrefs begin to disappear
Here is my command line, plz notice the lines with the asterix:

-----------------------------------------------
ap APPLOAD upd5.lsp successfully loaded.


Command:
Command:
Command: xrc
type the color number:1
Select xref to change color of all layers-layer
Current layer: "E-POWR-FEED-EMB"
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
c
New color [Truecolor/COlorbook] : 1
Enter name list of layer(s) for color 1 (red) :
05042-XAP02+0.20|* Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
Command:
Done by HANY.

Command: upd5

All LOADED Xrefs have been updated by SCG

Command:
Command:
Command:
Command: _saveas
Grid too dense to display

Command: xr XREF
Command: XREF
Xref "05042-XAF02+0.20": \\scgserv3\05042$\BLDG 02\02-Xrefs\05042-XAF02+0.20.dwg
"05042-XAF02+0.20" is unloaded.

Command: vr VISRETAIN
Enter new value for VISRETAIN <1>: 0***************************
Command: upd5

All LOADED Xrefs have been updated by SCG

Command:
Command:
Command:
Command: _qsave
Grid too dense to display

Command:
Command: XRC
type the color number:2
Select xref to change color of all layers-layer
Current layer: "E-POWR-FEED-EMB"
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
c
New color [Truecolor/COlorbook] : 2
Enter name list of layer(s) for color 2 (yellow) :
05042-XAP02+0.20|* Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
Command:
Done by HANY.

Command: *Cancel*

Command:
Grid too dense to display
upd5

All LOADED Xrefs have been updated by SCG

Command:
Command:
Command:
Command: _qsave
Grid too dense to display

Command:

Command: XRC
type the color number:2
Select xref to change color of all layers
Done by HANY.

Command: upd5 ; error: Exception occurred: 0xC0000005 ****(Access Violation)***************************************************
; warning: unwind skipped on unknown exception*************

Command: _qsave
.
Command: upd5 ; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on unknown exception

Command:
Command: UPD5 Automation Error. Multiple readers exist******
Command:
Command: UPD5 Automation Error. Multiple readers exist******
Command:
Command: UPD5 Automation Error. Multiple readers exist*****
---------------------------------------------------------
Message 20 of 29
Anonymous
in reply to: Anonymous

I did load all the xrefs that you posted.
No I didn't unload one before issusing the command.
I did not try and save it.

I can try this stuff when I get a chance today.

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5410435@discussion.autodesk.com...
Thanks a lot Tim,
But did you load all the xrefs that i posted?
Did you unload one of them before using the code?
Did you try to save the dwg after applying the code multiple times, the
problem occurs when saving, and some of the xrefs begin to disappear
Here is my command line, plz notice the lines with the asterix:

-----------------------------------------------
ap APPLOAD upd5.lsp successfully loaded.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost