Author Topic: Xref path help needed.  (Read 12146 times)

0 Members and 1 Guest are viewing this topic.

hudster

  • Gator
  • Posts: 2848
Xref path help needed.
« 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?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

MikePerry

  • Guest
Re: Xref path help needed.
« Reply #1 on: November 13, 2005, 06:51:50 AM »
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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Xref path help needed.
« Reply #2 on: November 13, 2005, 09:09:07 AM »
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

« Last Edit: November 29, 2005, 08:33:15 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

pmvliet

  • Guest
Re: Xref path help needed.
« Reply #3 on: November 14, 2005, 11:10:28 AM »
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

deegeecees

  • Guest
Re: Xref path help needed.
« Reply #4 on: November 14, 2005, 12:52:11 PM »
Id roll something like this (condensed):

Open dwg
Has xref
Replace old string w/ new string
Save path

Call this from acad2XXXdac.lsp

whdjr

  • Guest
Re: Xref path help needed.
« Reply #5 on: November 14, 2005, 01:23:14 PM »
...
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.

deegeecees

  • Guest
Re: Xref path help needed.
« Reply #6 on: November 14, 2005, 01:28:46 PM »
...
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.

Quote
Edit: Sorry D. I couldn't resist.

Ditto

 :evil:

hudster

  • Gator
  • Posts: 2848
Re: Xref path help needed.
« Reply #7 on: November 29, 2005, 06:03:19 AM »
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.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Xref path help needed.
« Reply #8 on: November 29, 2005, 08:39:52 AM »
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've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Bob Wahr

  • Guest
Re: Xref path help needed.
« Reply #9 on: November 29, 2005, 12:14:06 PM »
I think jjs wrote a VB app a couple of years back that would repath xrefs.  You might try contacting him.

deegeecees

  • Guest
Re: Xref path help needed.
« Reply #10 on: November 29, 2005, 12:21:10 PM »
I've got something that will repath to UNC, its a start if you'd like to pick it apart.

CTMill

  • Newt
  • Posts: 120
Re: Xref path help needed.
« Reply #11 on: November 29, 2005, 12:38:11 PM »
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.
Civ3d/A2K16

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Xref path help needed.
« Reply #12 on: November 29, 2005, 12:44:36 PM »
Have you looked into exploiting the projectname variable?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Xref path help needed.
« Reply #13 on: November 29, 2005, 12:49:50 PM »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: Xref path help needed.
« Reply #14 on: November 29, 2005, 01:46:10 PM »
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.
« Last Edit: November 29, 2005, 02:24:01 PM by Jeff_M »

hudster

  • Gator
  • Posts: 2848
Re: Xref path help needed.
« Reply #15 on: November 30, 2005, 03:22:09 AM »
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.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Xref path help needed.
« Reply #16 on: January 30, 2006, 04:56:43 AM »
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 :-)
Thanks for explaining the word "many" to me, it means a lot.

hudster

  • Gator
  • Posts: 2848
Re: Xref path help needed.
« Reply #17 on: January 30, 2006, 05:04:18 AM »
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.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Xref path help needed.
« Reply #18 on: January 30, 2006, 05:05:49 AM »
Please help!

We have had our migration  .............

migration to ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Xref path help needed.
« Reply #19 on: January 30, 2006, 05:21:57 AM »
...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 :-)
Thanks for explaining the word "many" to me, it means a lot.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Xref path help needed.
« Reply #20 on: January 30, 2006, 05:47:21 AM »
Are they attached ?

Hang about, I'll see what I can do ...
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Xref path help needed.
« Reply #21 on: January 30, 2006, 05:50:37 AM »
Yes, they are attached,

Thanks Kerry (once again)
Thanks for explaining the word "many" to me, it means a lot.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Xref path help needed.
« Reply #22 on: January 30, 2006, 05:55:38 AM »
Is it ONLY the Drive that changed ??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Xref path help needed.
« Reply #23 on: January 30, 2006, 05:58:16 AM »
I am just waiting for confirmation from the IT coordinator here, I'll let you know in a couple of minutes
Thanks for explaining the word "many" to me, it means a lot.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Xref path help needed.
« Reply #24 on: January 30, 2006, 06:00:39 AM »
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 >

Code: [Select]
(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)

)
« Last Edit: January 30, 2006, 06:18:01 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Xref path help needed.
« Reply #25 on: January 30, 2006, 06:02:44 AM »
Quote
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:
« Last Edit: January 30, 2006, 06:16:45 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Xref path help needed.
« Reply #26 on: January 30, 2006, 06:19:33 AM »
This MAY fall on it's head if you use nested XRefs though ...   :|
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Glenn R

  • Guest
Re: Xref path help needed.
« Reply #27 on: January 30, 2006, 06:23:45 AM »
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.

hudster

  • Gator
  • Posts: 2848
Re: Xref path help needed.
« Reply #28 on: January 30, 2006, 06:26:27 AM »
Be aware that project naming doesn't work with AutoCAD LT though.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Xref path help needed.
« Reply #29 on: January 30, 2006, 06:29:48 AM »
LT ?

crap, then, neither will Lisp .. , yes ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Xref path help needed.
« Reply #30 on: January 30, 2006, 06:35:51 AM »
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
Thanks for explaining the word "many" to me, it means a lot.

Glenn R

  • Guest
Re: Xref path help needed.
« Reply #31 on: January 30, 2006, 06:39:21 AM »
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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Xref path help needed.
« Reply #32 on: January 30, 2006, 06:40:42 AM »
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 ?

Quote
... but in a protected area
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Xref path help needed.
« Reply #33 on: January 30, 2006, 06:48:38 AM »
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 !.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Xref path help needed.
« Reply #34 on: January 30, 2006, 07:37:09 AM »
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 ?

Quote
... 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
Thanks for explaining the word "many" to me, it means a lot.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Xref path help needed.
« Reply #35 on: January 30, 2006, 09:06:47 AM »
Is there any way that this lisp can be set to run on a batch of drawings?
Thanks for explaining the word "many" to me, it means a lot.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Xref path help needed.
« Reply #36 on: January 30, 2006, 09:28:49 AM »
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  :-)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Xref path help needed.
« Reply #37 on: January 30, 2006, 11:23:47 AM »
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 thread.

Hope that is useful.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

hudster

  • Gator
  • Posts: 2848
Re: Xref path help needed.
« Reply #38 on: January 30, 2006, 11:38:55 AM »
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 >

Code: [Select]
(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?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Xref path help needed.
« Reply #39 on: January 30, 2006, 12:05:51 PM »
How would I change this so I could specify a new path, rather than just the drive letter?
Code: [Select]
(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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.