AutoCAD Civil 3D General

Reply
Active Member
slidster
Posts: 9
Registered: ‎10-27-2009
Message 1 of 11 (4,296 Views)

Updated XRef File Paths

4296 Views, 10 Replies
03-07-2012 12:38 PM

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

Valued Mentor
gjrcmb
Posts: 322
Registered: ‎06-21-2011
Message 2 of 11 (4,292 Views)

Re: Updated XRef File Paths

03-07-2012 12:48 PM 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

*Expert Elite*
Joe-Bouza
Posts: 4,755
Registered: ‎12-15-2008
Message 3 of 11 (4,261 Views)

Re: Updated XRef File Paths

03-07-2012 03:21 PM in reply to: gjrcmb

The reference manager will save your butt. :smileywink:

Thank you

Joseph D. Bouza, P.E. (one of 'THOSE' People) Civil 3D 2012 & 2013
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 Win7 OS
*Expert Elite*
sboon
Posts: 2,067
Registered: ‎11-08-2005
Message 4 of 11 (4,250 Views)

Re: Updated XRef File Paths

03-07-2012 06:56 PM 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.

*Expert Elite*
Jeff_M
Posts: 4,178
Registered: ‎07-22-2003
Message 5 of 11 (4,247 Views)

Re: Updated XRef File Paths

03-07-2012 07:02 PM 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
Active Member
slidster
Posts: 9
Registered: ‎10-27-2009
Message 6 of 11 (4,232 Views)

Re: Updated XRef File Paths

03-08-2012 08:30 AM 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.

 

Mentor
david.zavislan
Posts: 254
Registered: ‎10-31-2006
Message 7 of 11 (4,227 Views)

Re: Updated XRef File Paths

03-08-2012 09:44 AM 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.
Active Member
slidster
Posts: 9
Registered: ‎10-27-2009
Message 8 of 11 (4,202 Views)

Re: Updated XRef File Paths

03-12-2012 01:22 PM 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.

Mentor
david.zavislan
Posts: 254
Registered: ‎10-31-2006
Message 9 of 11 (4,181 Views)

Re: Updated XRef File Paths

03-13-2012 07:56 AM 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.
Active Member
slidster
Posts: 9
Registered: ‎10-27-2009
Message 10 of 11 (4,169 Views)

Re: Updated XRef File Paths

03-13-2012 10:43 AM 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)

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Civil 3D Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for AutoCAD Civil 3D helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Civil 3D

Twitter

Facebook

Blogs