TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: hudster on November 13, 2005, 06:32:50 AM
-
I really need a hand with an Xref problem.
We have installed new servers at work, and due to working practice changes the xref paths for all of our projects have changed and I need to be able to repath over 10 years of work to suit the new folder structures.
The system used to be "x:/dwg/05/ blah blah blah" but now it has changed to "x:/dwg/glasgow/05/ blah blah blah"
Is there an easy way to add the "/glasgow" part to the xref path without having to open thousands of drawings and browse to each one?
-
Hi
If using AutoCAD 2004 or greater, take a look at Reference Manager.
A stand-alone utility that is found in your AutoCAD installation area ie Start -> All Programs -> Autodesk -> AutoCAD...
Have a good one, Mike
-
I think Mike's recommendation if the way to go.
Have you have checked these out as well.
http://www.theswamp.org/forum/index.php?topic=1170.msg15055#msg15055
-
If you need to do it on 2000 file format, there is a reference manager for that as well. If you use the 2004/5/6 version, you will migrate all your files up to the new version when you do that.
It will work very well and do what you need, however it might take a little while if you have lots of files. Sometimes the program will hang up if you load in over 100 files at a time. it really doesn't hang up, it just seems like it does. If you just let it think and go get a donut or something it'll be there when you get back.
If you need help ask away as I use it all the time.
Pieter
-
Id roll something like this (condensed):
Open dwg
Has xref
Replace old string w/ new string
Save path
Call this from acad2XXXdac.lsp
-
...
Call this from acad2XXXdac.lsp
Is that a new lsp file name or just your hand rolled version of the acad2XXXdoc.lsp?
:lmao: :lmao:
Edit: Sorry D. I couldn't resist.
-
...
Call this from acad2XXXdac.lsp
Is that a new lsp file name or just your hand rolled version of the acad2XXXdoc.lsp?
:lmao: :lmao:
And I wrote my own AutoCad native language called AutoLasp.
Edit: Sorry D. I couldn't resist.
Ditto
:evil:
-
OK i've been using refernece manager, but it's way too time consuming to repath every project we have.
Is there any way using lisp I can Automaitically get the xref path, so I can alter to suit the new path?
You would think there would be a variable like DWGPREFIX, but I can't find anything.
-
Did you check out the link I provided?
I suspect you will have to use it in a Script as well to automate the process.
-
I think jjs (http://www.theswamp.org/forum/index.php?action=profile;u=620) wrote a VB app a couple of years back that would repath xrefs. You might try contacting him.
-
I've got something that will repath to UNC, its a start if you'd like to pick it apart.
-
Sounds good, but I've never found an easy way to do this. (we upgraded servers recently too)
Do you have Toolpac? Try their version of the Ref. Manager (Repath) in the Drawing menu. Its really easy to use.
OK i've been using refernece manager, but it's way too time consuming to repath every project we have.
Is there any way using lisp I can Automaitically get the xref path, so I can alter to suit the new path?
You would think there would be a variable like DWGPREFIX, but I can't find anything.
-
Have you looked into exploiting the projectname variable?
-
This might help.
http://discussion.autodesk.com/thread.jspa?messageID=4994095
Tim
-
Hudster, I have a VBA program I wrote that copies entire folders and repaths the xrefs to match their new locations. I have stripped it down to just the repath portion and I'm pretty sure it will do what you need. However, I have NOT tested it in it's current state! If you want to try it out, please do so on some test folders first. I have hard coded the old & new path prefixes as stated in your first post (just added glasgow\ to the path of x:\dwg\) If you select a parent folder that has many subfolders it may take a while to run as it will dig through all subfolders.
Anyway, it's attached for anyone to play with.......
Update.....I forgot to add the ObjectDBX type library reference. You must add it through the Tools/References menu in the VBAIDE prior to running.
-
Have you looked into exploiting the projectname variable?
I looked at it, but it doesn't work in LT and we have a few users on that.
-
Please help!
We have had our migration over the weekend and every drawing has lost its xrefs path 1000s of the darn things.
What would be the quickest way of updating the xrefs.
For example our project files used to be filed in the I drive, but are now in a P drive. The drawing frames and other protected data was on the G drive but they havent restored that yet, so I dont know what letter that will be.
I can see this is going to be a great week, with lots of posts!
Catch you later
T :-)
-
I was hoping to write a routine that looked for an xref, got the path as a string, altered the string with the new path, and then changed the path to suit.
but I haven't got round to it yet, way too busy. We have about 5000+ drawings with Xrefs detached though.
-
Please help!
We have had our migration .............
migration to ?
-
...to a new server, with a bigger hard drive. The problem is, when we changed server, head office told us that we had to use these drive letters with no exceptions. What was I:\ is now P:\ and as yet I dont know where our G:\ is going to be :realmad:
As you can understand, this is causing loads of problems as none of the drawings have their xrefs attached anymore.
So, I am looking for a quick way of re-pathing the drawings from I, to P, otherwise I am going to be doing this manually for weeks.(like the other offices did!)
T :-)
-
Are they attached ?
Hang about, I'll see what I can do ...
-
Yes, they are attached,
Thanks Kerry (once again)
-
Is it ONLY the Drive that changed ??
-
I am just waiting for confirmation from the IT coordinator here, I'll let you know in a couple of minutes
-
Try this on a COPY of one of your drawings ..
I don't use Xrefs, so testing was limited, but seems to not explode in my face :-)
(ChangeXrefDrive "P:") < or whichever drive is new >
(defun ChangeXrefDrive (newDrive / xrefEdata)
(mapcar
'(lambda (blockName)
(if
(eq
(logand
4
(cdr (assoc 70 (setq xrefEdata (entget (tblobjname "BLOCK" blockName))))
)
)
4
)
(command "._XREF"
"PATH"
(cdr (assoc 2 xrefEdata))
(strcat newDrive (substr (cdr (assoc 1 xrefEdata)) 3))
)
)
)
(ai_table "BLOCK" 0)
)
(princ)
)
-
Opening an AutoCAD 2004 format file.
Resolve Xref "CTT": C:\CTT.dwg
"CTT.dwg" cannot be found.
Resolve Xref "Drawing111": C:\Drawing111.dwg
"Drawing111.dwg" cannot be found.
Resolve Xref "rope-sheave-dog": C:\rope-sheave-dog.dwg
"rope-sheave-dog.dwg" cannot be found.
Regenerating model.
AutoCAD Express Tools Copyright © 2002-2004 Autodesk, Inc.
AutoCAD menu utilities loaded.
Command:
Command: (ChangeXrefDrive "D:")
; 32 forms loaded from #<file "C:/ACAD2006/support/ai_utils.lsp">
._XREF
Enter an option [?/Bind/Detach/Path/Unload/Reload/Overlay/Attach] <Attach>: PATH
Edit xref name(s) to edit path: rope-sheave-dog
xref name: "rope-sheave-dog"
Old path: C:\rope-sheave-dog.dwg
Enter new path: D:\rope-sheave-dog.dwg
Reload Xref "rope-sheave-dog": D:\rope-sheave-dog.dwg
"rope-sheave-dog" loaded.
Command: ._XREF
Enter an option [?/Bind/Detach/Path/Unload/Reload/Overlay/Attach] <Attach>: PATH
Edit xref name(s) to edit path: Drawing111
xref name: "Drawing111"
Old path: C:\Drawing111.dwg
Enter new path: D:\Drawing111.dwg
Reload Xref "Drawing111": D:\Drawing111.dwg
"Drawing111" loaded.
Command: ._XREF
Enter an option [?/Bind/Detach/Path/Unload/Reload/Overlay/Attach] <Attach>: PATH
Edit xref name(s) to edit path: CTT
xref name: "CTT"
Old path: C:\CTT.dwg
Enter new path: D:\CTT.dwg
Reload Xref "CTT": D:\CTT.dwg
"CTT" loaded.
Command:
-
This MAY fall on it's head if you use nested XRefs though ... :|
-
The use of PROJECTNAME neatly solves this issue. Previously I hated using it, but I've come to REALLY appreciate it.
I wrote a tool which would open up any number of drawings IN MEMORY, and change the PROJECTNAME setting, as well as strip any hard paths from XREFS.
This runs over several hundred drawings in literally a few minutes.
Unfortunately I can't give this out, however I do have a suggestion. Create a script that adds a certain PROJECTNAME into AutoCAD and add the paths to it. You could do this at AutoCAD startup with a bit of lisp/vba as well (vba is how I do it which reads from a master .xml file).
Then run a script over every drawing which changes the drawing's PROJECTNAME to the newly added one. Since the new PROJECTNAME has your NEW paths in it, your REFERENCE files should be found.
I hope this helps.
Cheers,
Glenn.
-
Be aware that project naming doesn't work with AutoCAD LT though.
-
LT ?
crap, then, neither will Lisp .. , yes ?
-
Kerry
This works a treat on the I to P versions (it even seems to find the nested ones)
Thanks a bunch.
The title blocks wont be as simple. They were on the G\read only\cad\drawing templates, and they will be on the P drive, but in a protected area, this doesnt seem to repath those. How can I get it to find and repath them
Many thanks
T
-
You can't permanently change the path of a nested xref. Code WILL change it in the host drawing, but as soon as the drawing is reloaded it will be back.
However, if you change the nested xrefs path in it's PARENT xref, that will work.
-
Hi Tracey,
What is the path:name unresoved ; ie :
Resolve Xref "Drawing111": C:\Drawing111.dwg
"Drawing111.dwg" cannot be found.
.. and what is the NEW path:name
?
added:
.. and WHA ?
... but in a protected area
-
You can't permanently change the path of a nested xref. Code WILL change it in the host drawing, but as soon as the drawing is reloaded it will be back.
However, if you change the nested xrefs path in it's PARENT xref, that will work.
good advice.
Sounds like a job for Tracey's IT or Management guy !.
-
Hi Tracey,
What is the path:name unresoved ; ie :
Resolve Xref "Drawing111": C:\Drawing111.dwg
"Drawing111.dwg" cannot be found.
.. and what is the NEW path:name
?
added:
.. and WHA ?
... but in a protected area
Dont worry for now Kerry. We need a protected (read only access) area to stop the engineers changing the titleblocks
-
Is there any way that this lisp can be set to run on a batch of drawings?
-
Yep, just needs one line to load it and one for the command.
It's past pumpkin time here, so I'll leave help with that to the others :-)
-
To have it run on multiple drawings, I would make a script. It would open then drawing, run the command, save the drawing, repeat on a list. I wrote a routine to make a script and run it in This (http://www.theswamp.org/forum/index.php?topic=8264.0) thread.
Hope that is useful.
-
Try this on a COPY of one of your drawings ..
I don't use Xrefs, so testing was limited, but seems to not explode in my face :-)
(ChangeXrefDrive "P:") < or whichever drive is new >
(defun ChangeXrefDrive (newDrive / xrefEdata)
(mapcar
'(lambda (blockName)
(if
(eq
(logand
4
(cdr (assoc 70 (setq xrefEdata (entget (tblobjname "BLOCK" blockName))))
)
)
4
)
(command "._XREF"
"PATH"
(cdr (assoc 2 xrefEdata))
(strcat newDrive (substr (cdr (assoc 1 xrefEdata)) 3))
)
)
)
(ai_table "BLOCK" 0)
)
(princ)
)
How would I change this so I could specify a new path, rather than just the drive letter?
-
How would I change this so I could specify a new path, rather than just the drive letter?
(defun ChangeXrefDrive (oldPath NewPath / xrefEdata tmpPath)
(mapcar
'(lambda (blockName)
(if
(eq
(logand
4
(cdr (assoc 70 (setq xrefEdata (entget (tblobjname "BLOCK" blockName))))
)
)
4
)
(if
(and
(/= (setq tmpPath (cdr (assoc 1 XrefEdata))) "")
(= (strcase (vl-filename-directory tmpPath)) (strcase oldPath))
)
(entmod (subst (cons 1 (strcase NewPath (vl-filename-base tmpPath) ".dwg") (assoc 1 XrefEdata) XrefEdata))
)
)
)
(ai_table "BLOCK" 0)
)
(princ)
)
This should work. The old path should not have the last slash, ie. c:\temp.