See the top rated post in this thread. Click here

Page 1 of 3 123 LastLast
Results 1 to 10 of 29

Thread: changing xref paths

  1. #1
    100 Club
    Join Date
    2000-11
    Posts
    146
    Login to Give a bone
    0

    Default changing xref paths

    I have a couple of thousand drawings that I need to change the front portion of the xref path from something like "S:\job\proj\for\..." to "S:\boj\jorp\jak\.... The current path or partial path I want to replace can set in a variable and the replacement string can be in a varialble. I have pasted some nice code I found on the forum and I can get it to actually find the path for the xrefs. What I can not do is figure out how to either entmod or vla-put and change it. I sure do wish there was a good book or something that explained how to program with the VLA- functions. Hopefully somebody will know how to do this and it be a piece of cake. Everytime I get awesome help from AUGI I buy another sweatshirt and this will definitely qualify. I already have 3 so maybe we need different color sweatshirts. Thanks to everyone and to whomever can modify this to work as it will be highly appreciated.

    Code:
    (defun c:jd (/ *blks* ref xname)
      (vl-load-com)
      (setq nxrp "C:\$temp")
      (setq	blks
    	 (vla-get-Blocks
    	   (vla-get-ActiveDocument
    	     (vlax-get-acad-object)
    	   )
    	 )
      )
      (vlax-for item blks
        (if	(eq (vla-get-IsXref item) :vlax-true)
          (progn
    	(setq ref (tblsearch "BLOCK" (setq xname (vla-get-Name item))))
    	(if (eq (logand (cdr (assoc 70 ref)) 32) 32)
    	  (setq xx (vla-get-path xname))
    	  (vla-put-textstring  nxrp xx)
    	)
    	(setq refpath (cdr (assoc 1 ref)));current xref path
    	);progn
        );if
      );vlax
    ;  (vl-cmdf "-Image" "D" "*")
      (princ)
    )
    Last edited by Opie; 2007-08-05 at 12:43 PM. Reason: [code] tags added

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,831
    Login to Give a bone
    0

    Default Re: changing xref paths

    Quote Originally Posted by jack.foster
    I have a couple of thousand drawings that I need to change the front portion of the xref path from something like "S:\job\proj\for\..." to "S:\boj\jorp\jak\....
    Why not just use the Reference Manager?
    R.K. McSwain | CAD Panacea |

  3. #3
    100 Club
    Join Date
    2000-11
    Posts
    146
    Login to Give a bone
    0

    Default Re: changing xref paths

    The biggest thing that is wrong with the xref manager is the drawings are in lots of different folders. When you have to pick different paths for different drawings you have to start with the drive letter and pick through a bunch of folders each time. If it would remember the last folder you were in that would be a big improvement. Maybe that is in the settings but I would think that would be the default. Where I know I have a drawing that has a lot of drawings in the same folder I use the ref manager. I am old and have to worry about carpal tunnel and all that picking makes my hands sore by the end of a 12 hour day. If I could open up a drawing and hit one button and fix all the drawing paths in multiple subfolders it would be much easier. If there is something I am missing about the xref manager please let me know. Thanks for your reply and I hope mine was okay. Take care, Jack.
    Last edited by jack.foster; 2007-08-04 at 05:17 PM.

  4. #4
    100 Club
    Join Date
    2000-11
    Posts
    146
    Login to Give a bone
    0

    Default Re: changing xref paths

    Just thought I would give a description of what I am doing that has been a help. I go into the Options Files and I set a bunch of paths to a section of folders where I will be changing paths to on a lot of xrefs. I will put those paths into the Files section. Instead of using the Add and then having to Browse to each folder I use windows explorer and I move quickly from one folder to the next. I then copy that path from Windows explorer into the new box to add a path. Much easier than browsing and glad AutoCAD made that ability available. Now when I open up a drawing and the xref dialog box I can scroll down through all of the drawings. If they are not nested at the bottom it will show the Found Path for the drawing not grayed out. I can then press ALT + P and that saves the new found location in the Saved Path section. Hit a down arrow until the next one and ALT + P and I can fix them fairly quickly. So far this has been the easiest method that I have been able to come up with for repathing lots of drawings that management decided needed to be moved. However; a good AutoLISP program would be better yet.

  5. #5
    Member
    Join Date
    2007-03
    Location
    U.K.
    Posts
    21
    Login to Give a bone
    0

    Default Re: changing xref paths

    Jack,

    How can I make this routine work on my CAD 2008?I do not know at all.

    Please explain if you can

    Thanks,

    Norbert

  6. #6
    100 Club
    Join Date
    2000-11
    Posts
    146
    Login to Give a bone
    0

    Default Re: changing xref paths

    Norbert the routine does not yet work. I am hoping some AUGI member who could work for NASA can fix the code to change the paths. Until then the post of the method I am using is the best way I know how to change LOTS of xref's whose paths have been moved. There is a program call LinkFixerPlus which claims to do such. However, it failed miserably when I ran it. They are now trying to fix what failed which was it did not changed the saved path name if the file the xref is in happens to be in the same folder. Because AutoCAD will find the xrefs when the drawings are in the same path they just ignored the full path that they were saved with. I alway use a full path so I can move the root files to other folders and have all the nested files found. I also had problems with relative paths a few years back so I just always use the full path feature. Check back to the thread for a possible solution later on. Take care, Jack.

  7. #7
    Member
    Join Date
    2004-05
    Location
    Los Angeles
    Posts
    8
    Login to Give a bone
    0

    Default Re: changing xref paths

    Quote Originally Posted by jack.foster
    Just thought I would give a description of what I am doing that has been a help. I go into the Options Files and I set a bunch of paths to a section of folders where I will be changing paths to on a lot of xrefs. I will put those paths into the Files section. Instead of using the Add and then having to Browse to each folder I use windows explorer and I move quickly from one folder to the next. I then copy that path from Windows explorer into the new box to add a path. Much easier than browsing and glad AutoCAD made that ability available. Now when I open up a drawing and the xref dialog box I can scroll down through all of the drawings. If they are not nested at the bottom it will show the Found Path for the drawing not grayed out. I can then press ALT + P and that saves the new found location in the Saved Path section. Hit a down arrow until the next one and ALT + P and I can fix them fairly quickly. So far this has been the easiest method that I have been able to come up with for repathing lots of drawings that management decided needed to be moved. However; a good AutoLISP program would be better yet.
    Use the windows explorer Search feature, search for *.dwg, select your files then drag and drop onto Reference Manager.

  8. #8
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: changing xref paths

    Here is a simple example of how to get the path of an xref, to set it just use "vla-put-Path"
    Code:
    (vlax-for layout (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-Acad-Object)))
     (vlax-for obj (vla-get-Block layout)
      (if
       (and
        (= (vla-get-ObjectName obj) "AcDbBlockReference")
    	(vlax-property-available-p obj 'Path)
       )
       (prompt (strcat "\n Name: " (vla-get-Name obj) "\n   Path: " (vla-get-Path obj)))
      )
     )
    )

  9. #9
    100 Club
    Join Date
    2003-11
    Location
    Dublin, Ireland.
    Posts
    152
    Login to Give a bone
    0

    Default Re: changing xref paths

    Quote Originally Posted by T.Willey
    Here is a simple example of how to get the path of an xref, to set it just use "vla-put-Path"
    Tim,
    nice code.
    I have stuck in the "vla-put-path" and whenever I inspect the "obj" the path has changed,
    however the information in the xref manager hasn't updated.
    Whenever I save and open the drawing everything is as it should be with the paths changed.
    Would you know how to update the information in the xref manager ?


    Code:
    (vlax-for layout (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-Acad-Object)))
     (vlax-for obj (vla-get-Block layout)
      (if
       (and
        (= (vla-get-ObjectName obj) "AcDbBlockReference")
    	(vlax-property-available-p obj 'Path)
       )
       (vla-put-path obj (strcat "c:\\New Job\\" (vla-get-Name obj) ".dwg"))
      )
     )
    )

  10. #10
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    1

    Default Re: changing xref paths

    Glad that part worked for you.

    To get it to update the xref manager dialog box is a different story. I think you might have to reload the xrefs, and I think you do that from the object in the block collection, not the ones inserted. So what I would do is, make a list of all the xref names that are in the drawing, making sure not to have the name in more than once. Then grab the object from the block collection, and reload it. I think that might work.

    The great thing about working with ActiveX is you can use ObjectDBX. What this does is open the drawing (not in the editor) and make the changes, so it is a lot faster. If you have hundreds of drawings, I would do this route. If you do a search here for ObjectDBX I'm sure you will find some examples.

Page 1 of 3 123 LastLast

Similar Threads

  1. XREF Paths All Messed Up
    By TerribleTim in forum CAD Management - General
    Replies: 23
    Last Post: 2013-07-08, 05:01 PM
  2. Changing Xref Paths
    By jason907238 in forum Dot Net API
    Replies: 5
    Last Post: 2010-08-10, 02:53 PM
  3. xref paths.
    By got_green in forum AutoCAD General
    Replies: 5
    Last Post: 2009-01-22, 05:33 PM
  4. Globally changing the drive letter of all xref paths
    By gregb.68838 in forum AutoLISP
    Replies: 7
    Last Post: 2005-06-20, 08:51 PM
  5. Xref paths
    By Coolmo in forum AutoLISP
    Replies: 5
    Last Post: 2005-02-10, 05:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •