Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Updated XRef File Paths

10 REPLIES 10
Reply
Message 1 of 11
slidster
8508 Views, 10 Replies

Updated XRef File Paths

Hello,

 

I'll start by saying I'm not too confident that there is a solution to my problem. We recently updated our servers and with that the path to all of our drawings. For example what was once located at W:\Files\AutoCAD is now located at W:\Corporate\AutoCAD\Drawings. The problem is every time we open an old drawing for the first time we must redirect all of the xrefs to the new location. My question is, is there any way to do this automatically for all drawings when they are opened? Is there a way to tell the software to replace "Files\AutoCAD " with "Corporate\AutoCAD\Drawings"? I'm sure others have encountered this dilemma. Any help would be appreciated. Thanks

10 REPLIES 10
Message 2 of 11
gjrcmb
in reply to: slidster

Not sure what version of C3D you are running?

 

Look into Reference Manager.  Under Windows Programs >AutoCAD Civil 3D 2012 > Reference Manager.

 

Have not really used it, but sounds like it will do what you want.

 

Also seeing following discussion about same topic:

 

repath xrefs after moving servers

Message 3 of 11
Joe-Bouza
in reply to: gjrcmb

The reference manager will save your butt. Smiley Wink

Thank you

Joseph D. Bouza, P.E. (one of 'THOSE' People)

HP Z210 Workstation
Intel Xeon CPU E31240 @ 3.30 Hz
12 GB Ram


Note: Its all Resistentialism, so keep calm and carry on

64 Bit Win10 OS
Message 4 of 11
sboon
in reply to: Joe-Bouza

The reference manger will allow you to fix the dref paths but it won't do anything for xref's.  There is an old Express Tools command called Redir which allows you to batch edit paths for images, xrefs and styles.  You could probably write a script to run that command when you open a drawing, or maybe put it on a toolbar.

Steve
Expert Elite Alumnus
Message 5 of 11
Jeff_M
in reply to: sboon

The reference manager works great with Xrefs, Steve. You are thinking of the Data Shortcuts Editor.

 

An excerpt fromthe help for the Ref Manager:

The Autodesk Reference Manager provides tools to list referenced files in selected drawings and to modify the saved reference paths without opening the drawing files in AutoCAD. With Reference Manager, drawings with unresolved references can be easily identified and fixed.

Jeff_M, also a frequent Swamper
EESignature
Message 6 of 11
slidster
in reply to: slidster

Thanks for all the input guys. I had never heard of the reference manager, this will definately help me out. I tried it on a few drawings and it did the trick, much quicker than opening the drawing and doing it there. My only problem with it is that I still need to go through each drawing and redirect them (unless I am doing it wrong). Im sure we have thousands of drawings spread across our servers. I was hoping to find something that would change the path for all xrefs when the drawing was opened. We have some users who are not very proficient in the software and it would be nice if they did not have to worry about this. We have already had someone not realize an xref was no longer attached and send a file out.

 

Steve - I am going to look into the Redir function you mention, that sounds like it might be promising.

 

Thanks again for all of your help everyone.

 

Message 7 of 11
david.zavislan
in reply to: slidster

Another option is to use AutoLISP and have AutoCAD take care of this automatically when drawings are opened.  Modify your acaddoc.lsp file, adding the following code.  It will locate all xref blocks in the drawing and change their path.  The vl-string-subst function is case sensitive, so you may need to create several instances of that line to accommodate all the different ways users have created the original directory names.

 

(vl-load-com)
(princ "\nUpdating XREF paths....")
(setq acadObj (vlax-get-acad-object))
(setq activeDwgObj (vlax-get acadObj 'ActiveDocument))
(setq pathStr (vlax-get activeDwgObj 'Path))
(setq blocksObj (vlax-get activeDwgObj 'Blocks))
;;; loop through blocks searching for xrefs
(setq countInt (vlax-get blocksObj 'Count))
(setq I 0)
(while (< I countInt)
  (setq blockObj (vlax-invoke-method  blocksObj 'Item (vlax-make-variant I 2)))
  ;;; test to see if it is xref
  (if (= -1 (vlax-get blockObj 'IsXRef));; 0=False -1=True
    (progn
      (setq xrefPathStr (vlax-get blockObj 'Path))
      (princ (strcat "\n" xrefPathStr))
      ;;; subst function is case sensitive
      (setq newXrefPathStr (vl-string-subst "W:\\Corporate\\AutoCAD\\Drawings" W:\\Files\\AutoCAD" newXrefPathStr 0))
      (princ (strcat "   =>   " newXrefPathStr))
      (vlax-put blockObj 'Path newXrefPathStr)
    );;end progn
  );;end if
  (setq I (1+ I))
);; end while I < countInt
(princ)

David Zavislan, P.E. | Wood Rodgers, Inc.
Message 8 of 11
slidster
in reply to: david.zavislan

David,

 

Thanks for taking the time to put this together, it is exactly what I am looking for. It isnt working quite yet but I think that is because I left out some detail. A typical file path looked like this prior to the switch:

 

"W:\\Corporate\\AutoCAD\\Drawings\11-5515\Cad\Xref.dwg"

 

That same file now has this path:

 

"W:\\Files\\AutoCAD\11-5515\Cad\Xref.dwg"

 

I want to swap out only the folders in red but leave the folders after it as they have not changed. Is this possible? Also, if youre too busy to dig any deeper into this I understand. Thanks again for your help.

Message 9 of 11
david.zavislan
in reply to: slidster

The function  (vl-string-subst "W:\\Corporate\\AutoCAD\\Drawings" W:\\Files\\AutoCAD" newXrefPathStr 0) will do what you are asking.  It will replace the "W:\\Files\\AutoCAD" portion of the path with "W:\\Corporate\\AutoCAD\\Drawings".  I include the "W:\\" just to make sure that it only modifies the first part of the path.

 

Also make sure that you use double back slashes (\\) when entering path strings in AutoLISP functions.  A single backslash is an escape character.

David Zavislan, P.E. | Wood Rodgers, Inc.
Message 10 of 11
slidster
in reply to: david.zavislan

Thanks for getting back to me. I am still having some trouble. I should point out that I have never written a LISP expression so I apologize if Im missing something obvious.

 

Here is an example of a path I am trying to replace:

 

W:\06-5214 Dunhams Farm\049\Cad

 

And this is what I am trying to replace it with.

 

W:\HILLSBOROUGH\W_WINDOWS\06-5214 Dunhams Farm\049\Cad

 

Since I am trying to replace W:\ with W:\HILLSBOROUGH\W_WINDOWS, how would I enter the lone W:\ into the expression you provided? I've included below what I am using now. When I try to execute I get "Updating XREF paths....; error: malformed string on input" in the command line. Also, please note I have tried using "W", "W:", "W:\" and "W:\\" for the path to be replaced and have received the same message. Thanks again.

 

 

 

(vl-load-com)
(princ "\nUpdating XREF paths....")
(setq acadObj (vlax-get-acad-object))
(setq activeDwgObj (vlax-get acadObj 'ActiveDocument))
(setq pathStr (vlax-get activeDwgObj 'Path))
(setq blocksObj (vlax-get activeDwgObj 'Blocks))
;;; loop through blocks searching for xrefs
(setq countInt (vlax-get blocksObj 'Count))
(setq I 0)
(while (< I countInt)
(setq blockObj (vlax-invoke-method blocksObj 'Item (vlax-make-variant I 2)))
;;; test to see if it is xref
(if (= -1 (vlax-get blockObj 'IsXRef));; 0=False -1=True
(progn
(setq xrefPathStr (vlax-get blockObj 'Path))
(princ (strcat "\n" xrefPathStr))
;;; subst function is case sensitive
(setq newXrefPathStr (vl-string-subst "W:\\HILLSBOROUGH\\W_WINDOWS" W:" newXrefPathStr 0))
(princ (strcat " => " newXrefPathStr))
(vlax-put blockObj 'Path newXrefPathStr)
);;end progn
);;end if
(setq I (1+ I))
);; end while I < countInt
(princ)

Message 11 of 11
david.zavislan
in reply to: slidster

The malformed sting error usually means that you are missing a quotation mark.  All stings must be contained within quotation mark pairs.  Looking at what you posted

 

(setq newXrefPathStr (vl-string-subst "W:\\HILLSBOROUGH\\W_WINDOWS" W:" newXrefPathStr 0))

 

you are missing a quotation mark before the W:"


 

David Zavislan, P.E. | Wood Rodgers, Inc.

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

Post to forums  

Rail Community


Autodesk Design & Make Report