JeepMaster Posted July 30, 2009 Author Share Posted July 30, 2009 Try this: Start --> Programs --> Autodesk --> AutoCAD 20xx --> Reference Manager I designed an application to cater for these needs and then discovered this Autodesk freebie so abandoned my plans. Hope this helps. Wannabe, Reference manager only repath the same xrefs, it doesn't work if the xrefs have a different name, which this lisp will do. (ie: xref FP00.dwg renamed to FP01.dwg) Quote Link to comment Share on other sites More sharing options...
wannabe Posted August 4, 2009 Share Posted August 4, 2009 How about this: http://www.lazydrafter.com/autocad-tips/quickly-redirect-xref-paths/ Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 4, 2009 Share Posted August 4, 2009 How about this: http://www.lazydrafter.com/autocad-tips/quickly-redirect-xref-paths/ The problem Jeepmaster had was the file names changed and the path remained intact. Quote Link to comment Share on other sites More sharing options...
JeepMaster Posted August 4, 2009 Author Share Posted August 4, 2009 I've now combined both blkrenamer lisp and the path change lisp from rjp. So if the path changed as well as name changed, it will still work. I kept the xref reload lisp in there because it seems to need it after the pathchange lisp from rjp. Here's what I have now. Hope others will find it useful. I tried to make it as clear as possible of how to modify the lisp for individual use. ;............................................................................... ; ; << Replace old xref files with a set of new xref files >> ; ; << Version 1.0 >> ; ; NOTE: If new xrefs are in a different folder, you must call out ; XrefPathChange.lsp from the code below. ; ;............................................................................... (defun c:xrefnamechange (/ b bcol path) (setq bcol (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (foreach blk '( ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>>>> Enter all xref names below in this format >>>>>> ;>>>>> ("OldXrefName" . "NewXrefName") >>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ("fp01" . "fp01_new") ("ABC" . "ABC_new") ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ) (if (and (not (vl-catch-all-error-p (setq b (vl-catch-all-apply 'vla-item (list bcol (car blk)))))) (= (vla-get-isxref b) :vlax-true) ) (progn (vla-put-name b (cdr blk)) (if (= (setq path (vl-filename-directory (vla-get-path b))) "") (vla-put-path b (strcat (cdr blk) ".dwg")) (vla-put-path b (strcat path "\\" (cdr blk) ".dwg")) ) (vla-reload b) ) ) ) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>> XrefPathChange.lsp call out here. >>>> ;>>> Enter all xref paths to be changed in this format. >>>> ;>>> (xrefpathchange "c:\\Oldfolder\\oldfolder" "c:\\newfolder\\newfolder") >>>> ;>>> Note: Remove code if new xref path is unchanged. >>>> ;>>> Add ; infront of each line to block code. >>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (xrefpathchange "L:\\Buildings\\E" "c:\\temp\\new xref") (xrefpathchange "L:\\Buildings\\A" "c:\\temp\\new xref") (XReload) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (princ) );end of c:XrefNameChange ;........................................................... ;.... Xref Path Change sub routine by ronjonp ...... ;........................................................... (defun xrefpathchange (path1 path2 / newpath xrpath) (vl-load-com) (vlax-map-collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (function (lambda (x) (if (= (vla-get-isxref x) :vlax-true) (progn (setq xrpath (strcase (vlax-get x 'path) t) path1 (strcase path1 t) path2 (strcase path2 t) ) (if (and (vl-string-search path1 xrpath) (setq newpath (vl-string-subst path2 path1 xrpath)) (findfile newpath) ) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-path (list x newpath))) (princ (strcat "\n**OLD path found but was not changed!\n" xrpath)) (princ (strcat "\n" newpath)) ) ) ) ) ) ) ) (princ) ); end of XrefPathChange ;............................................................. ;.... Xref Reload sub routine ....... ;............................................................. (defun XReload (/ cObj cName); Updated 2007-10-1: added error trap (defun *error*(msg) (setvar "modemacro" ".") (setvar "cmdecho" 1) (princ "\n...Reload xref terminated!!! ") (princ) ); end of *error* (setvar "modemacro" "Reloading loaded xrefs......please wait......") (setvar "cmdecho" 0) (setq cObj(tblnext "BLOCK" T)) (while cObj (setq cName(cdr(assoc 2 cObj))) (if (and (=(logand(cdr(assoc 70 cObj))32)32) (=(logand(cdr(assoc 70 cObj))4)4) ); end and (progn (vl-cmdf "_.xref" "_unload" cName) (vl-cmdf "_.xref" "_reload" cName) ); end progn ); wnd if (setq cObj(tblnext "BLOCK")) ); end while (setvar "modemacro" ".") (setvar "cmdecho" 1) (prompt "\n--- Xref change finished! ---") (princ) ); end of XReload Quote Link to comment Share on other sites More sharing options...
RyanGC Posted June 8, 2010 Share Posted June 8, 2010 I've now combined both blkrenamer lisp and the path change lisp from rjp. So if the path changed as well as name changed, it will still work. I kept the xref reload lisp in there because it seems to need it after the pathchange lisp from rjp. Here's what I have now. Hope others will find it useful. I tried to make it as clear as possible of how to modify the lisp for individual use. ;............................................................................... ; ; << Replace old xref files with a set of new xref files >> ; ; << Version 1.0 >> ; ; NOTE: If new xrefs are in a different folder, you must call out ; XrefPathChange.lsp from the code below. ; ;............................................................................... (defun c:xrefnamechange (/ b bcol path) (setq bcol (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (foreach blk '( ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>>>> Enter all xref names below in this format >>>>>> ;>>>>> ("OldXrefName" . "NewXrefName") >>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ("fp01" . "fp01_new") ("ABC" . "ABC_new") ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ) (if (and (not (vl-catch-all-error-p (setq b (vl-catch-all-apply 'vla-item (list bcol (car blk)))))) (= (vla-get-isxref b) :vlax-true) ) (progn (vla-put-name b (cdr blk)) (if (= (setq path (vl-filename-directory (vla-get-path b))) "") (vla-put-path b (strcat (cdr blk) ".dwg")) (vla-put-path b (strcat path "\\" (cdr blk) ".dwg")) ) (vla-reload b) ) ) ) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>> XrefPathChange.lsp call out here. >>>> ;>>> Enter all xref paths to be changed in this format. >>>> ;>>> (xrefpathchange "c:\\Oldfolder\\oldfolder" "c:\\newfolder\\newfolder") >>>> ;>>> Note: Remove code if new xref path is unchanged. >>>> ;>>> Add ; infront of each line to block code. >>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (xrefpathchange "L:\\Buildings\\E" "c:\\temp\\new xref") (xrefpathchange "L:\\Buildings\\A" "c:\\temp\\new xref") (XReload) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (princ) );end of c:XrefNameChange ;........................................................... ;.... Xref Path Change sub routine by ronjonp ...... ;........................................................... (defun xrefpathchange (path1 path2 / newpath xrpath) (vl-load-com) (vlax-map-collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (function (lambda (x) (if (= (vla-get-isxref x) :vlax-true) (progn (setq xrpath (strcase (vlax-get x 'path) t) path1 (strcase path1 t) path2 (strcase path2 t) ) (if (and (vl-string-search path1 xrpath) (setq newpath (vl-string-subst path2 path1 xrpath)) (findfile newpath) ) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-path (list x newpath))) (princ (strcat "\n**OLD path found but was not changed!\n" xrpath)) (princ (strcat "\n" newpath)) ) ) ) ) ) ) ) (princ) ); end of XrefPathChange ;............................................................. ;.... Xref Reload sub routine ....... ;............................................................. (defun XReload (/ cObj cName); Updated 2007-10-1: added error trap (defun *error*(msg) (setvar "modemacro" ".") (setvar "cmdecho" 1) (princ "\n...Reload xref terminated!!! ") (princ) ); end of *error* (setvar "modemacro" "Reloading loaded xrefs......please wait......") (setvar "cmdecho" 0) (setq cObj(tblnext "BLOCK" T)) (while cObj (setq cName(cdr(assoc 2 cObj))) (if (and (=(logand(cdr(assoc 70 cObj))32)32) (=(logand(cdr(assoc 70 cObj))4)4) ); end and (progn (vl-cmdf "_.xref" "_unload" cName) (vl-cmdf "_.xref" "_reload" cName) ); end progn ); wnd if (setq cObj(tblnext "BLOCK")) ); end while (setvar "modemacro" ".") (setvar "cmdecho" 1) (prompt "\n--- Xref change finished! ---") (princ) ); end of XReload Ouch! This program is giving me the line: ; error: no function definition: VLAX-GET-ACAD-OBJECT Any help, anyone? BTW, I'll say thanks, in advance (for when I get it working), for the great programming, JeepMaster, ronjonp & Lee. Cheers. Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 8, 2010 Share Posted June 8, 2010 add (vl-load-com) to the top Quote Link to comment Share on other sites More sharing options...
RyanGC Posted June 8, 2010 Share Posted June 8, 2010 add (vl-load-com) to the top Thanks............ Quote Link to comment Share on other sites More sharing options...
RyanGC Posted June 11, 2010 Share Posted June 11, 2010 For those who may be interested, this program does not appear to work with files referenced with relative paths, only full paths. Modification possible? Quote Link to comment Share on other sites More sharing options...
RyanGC Posted June 11, 2010 Share Posted June 11, 2010 I'm testing this program, in order to better my programming understanding, and it works "out-of-the-box" when the xrefs are renamed, but their paths unchanged. However, when I attempt to rename & change the paths, I get the following command line error: ; error: Automation Error. File access error Here's my modifications (added (vl-load-com), names & paths only!) to the program for testing ;............................................................................... ; ; << Replace old xref files with a set of new xref files >> ; ; << Version 1.0 >> ; ; NOTE: If new xrefs are in a different folder, you must call out ; XrefPathChange.lsp from the code below. ; ;............................................................................... (defun c:xrefnamechange (/ b bcol path ) [color=Blue](vl-load-com)[/color] (setq bcol (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (foreach blk '( ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>>>> Enter all xref names below in this format >>>>>> ;>>>>> ("OldXrefName" . "NewXrefName") >>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [color=Red] ("X-TEST-1a" . "X-TEST-1b") ("X-TEST-2a" . "X-TEST-2b") ("X-TEST-3a" . "X-TEST-3b")[/color] ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ) (if (and (not (vl-catch-all-error-p (setq b (vl-catch-all-apply 'vla-item (list bcol (car blk)))))) (= (vla-get-isxref b) :vlax-true) ) (progn (vla-put-name b (cdr blk)) (if (= (setq path (vl-filename-directory (vla-get-path b))) "") (vla-put-path b (strcat (cdr blk) ".dwg")) (vla-put-path b (strcat path "\\" (cdr blk) ".dwg")) ) (vla-reload b) ) ) ) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>> XrefPathChange.lsp call out here. >>>> ;>>> Enter all xref paths to be changed in this format. >>>> ;>>> (xrefpathchange "c:\\Oldfolder\\oldfolder" "c:\\newfolder\\newfolder") >>>> ;>>> Note: Remove code if new xref path is unchanged. >>>> ;>>> Add ; infront of each line to block code. >>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [color=Red](xrefpathchange "c:\\AutoCAD Customisation" "c:\\AutoCAD Customisation\\Working") (xrefpathchange "c:\\AutoCAD Customisation" "c:\\AutoCAD Customisation\\Working") (xrefpathchange "c:\\AutoCAD Customisation" "c:\\AutoCAD Customisation\\Working")[/color] (XReload) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (princ) );end of c:XrefNameChange ;........................................................... ;.... Xref Path Change sub routine by ronjonp .... ;........................................................... (defun xrefpathchange (path1 path2 / newpath xrpath) (vl-load-com) (vlax-map-collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (function (lambda (x) (if (= (vla-get-isxref x) :vlax-true) (progn (setq xrpath (strcase (vlax-get x 'path) t) path1 (strcase path1 t) path2 (strcase path2 t) ) (if (and (vl-string-search path1 xrpath) (setq newpath (vl-string-subst path2 path1 xrpath)) (findfile newpath) ) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-path (list x newpath))) (princ (strcat "\n**OLD path found but was not changed!\n" xrpath)) (princ (strcat "\n" newpath)) ) ) ) ) ) ) ) (princ) ); end of XrefPathChange ;............................................................. ;.... Xref Reload sub routine ....... ;............................................................. (defun XReload (/ cObj cName); Updated 2007-10-1: added error trap (defun *error*(msg) (setvar "modemacro" ".") (setvar "cmdecho" 1) (princ "\n...Reload xref terminated!!! ") (princ) ); end of *error* (setvar "modemacro" "Reloading loaded xrefs......please wait......") (setvar "cmdecho" 0) (setq cObj(tblnext "BLOCK" T)) (while cObj (setq cName(cdr(assoc 2 cObj))) (if (and (=(logand(cdr(assoc 70 cObj))32)32) (=(logand(cdr(assoc 70 cObj))4)4) ); end and (progn (vl-cmdf "_.xref" "_unload" cName) (vl-cmdf "_.xref" "_reload" cName) ); end progn ); wnd if (setq cObj(tblnext "BLOCK")) ); end while (setvar "modemacro" ".") (setvar "cmdecho" 1) (prompt "\n--- Xref change finished! ---") (princ) ); end of XReload Any help??? Quote Link to comment Share on other sites More sharing options...
JeepMaster Posted June 14, 2010 Author Share Posted June 14, 2010 RyanGC, I don't know what that "File access error" means. Do you have those xrefs open? I tested my code many times and it's been working great with xref name changed as well as path changed. Our company only use full path, so I never have to deal with relative paths xrefs. Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted June 14, 2010 Share Posted June 14, 2010 I'm testing this program, in order to better my programming understanding, and it works "out-of-the-box" when the xrefs are renamed, but their paths unchanged. However, when I attempt to rename & change the paths, I get the following command line error: ; error: Automation Error. File access error Here's my modifications (added (vl-load-com), names & paths only!) to the program for testing ;............................................................................... ; ; << Replace old xref files with a set of new xref files >> ; ; << Version 1.0 >> ; ; NOTE: If new xrefs are in a different folder, you must call out ; XrefPathChange.lsp from the code below. ; ;............................................................................... (defun c:xrefnamechange (/ b bcol path ) [color=Blue](vl-load-com)[/color] (setq bcol (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (foreach blk '( ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>>>> Enter all xref names below in this format >>>>>> ;>>>>> ("OldXrefName" . "NewXrefName") >>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [color=Red] ("X-TEST-1a" . "X-TEST-1b") ("X-TEST-2a" . "X-TEST-2b") ("X-TEST-3a" . "X-TEST-3b")[/color] ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ) (if (and (not (vl-catch-all-error-p (setq b (vl-catch-all-apply 'vla-item (list bcol (car blk)))))) (= (vla-get-isxref b) :vlax-true) ) (progn (vla-put-name b (cdr blk)) (if (= (setq path (vl-filename-directory (vla-get-path b))) "") (vla-put-path b (strcat (cdr blk) ".dwg")) (vla-put-path b (strcat path "\\" (cdr blk) ".dwg")) ) (vla-reload b) ) ) ) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>> XrefPathChange.lsp call out here. >>>> ;>>> Enter all xref paths to be changed in this format. >>>> ;>>> (xrefpathchange "c:\\Oldfolder\\oldfolder" "c:\\newfolder\\newfolder") >>>> ;>>> Note: Remove code if new xref path is unchanged. >>>> ;>>> Add ; infront of each line to block code. >>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [color=Red](xrefpathchange "c:\\AutoCAD Customisation" "c:\\AutoCAD Customisation\\Working") (xrefpathchange "c:\\AutoCAD Customisation" "c:\\AutoCAD Customisation\\Working") (xrefpathchange "c:\\AutoCAD Customisation" "c:\\AutoCAD Customisation\\Working")[/color] (XReload) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (princ) );end of c:XrefNameChange ;........................................................... ;.... Xref Path Change sub routine by ronjonp .... ;........................................................... (defun xrefpathchange (path1 path2 / newpath xrpath) (vl-load-com) (vlax-map-collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (function (lambda (x) (if (= (vla-get-isxref x) :vlax-true) (progn (setq xrpath (strcase (vlax-get x 'path) t) path1 (strcase path1 t) path2 (strcase path2 t) ) (if (and (vl-string-search path1 xrpath) (setq newpath (vl-string-subst path2 path1 xrpath)) (findfile newpath) ) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-path (list x newpath))) (princ (strcat "\n**OLD path found but was not changed!\n" xrpath)) (princ (strcat "\n" newpath)) ) ) ) ) ) ) ) (princ) ); end of XrefPathChange ;............................................................. ;.... Xref Reload sub routine ....... ;............................................................. (defun XReload (/ cObj cName); Updated 2007-10-1: added error trap (defun *error*(msg) (setvar "modemacro" ".") (setvar "cmdecho" 1) (princ "\n...Reload xref terminated!!! ") (princ) ); end of *error* (setvar "modemacro" "Reloading loaded xrefs......please wait......") (setvar "cmdecho" 0) (setq cObj(tblnext "BLOCK" T)) (while cObj (setq cName(cdr(assoc 2 cObj))) (if (and (=(logand(cdr(assoc 70 cObj))32)32) (=(logand(cdr(assoc 70 cObj))4)4) ); end and (progn (vl-cmdf "_.xref" "_unload" cName) (vl-cmdf "_.xref" "_reload" cName) ); end progn ); wnd if (setq cObj(tblnext "BLOCK")) ); end while (setvar "modemacro" ".") (setvar "cmdecho" 1) (prompt "\n--- Xref change finished! ---") (princ) ); end of XReload Any help??? Something from Autodesk on that subject. http://through-the-interface.typepad.com/through_the_interface/2006/08/handling_automa.html I hope its helpful. Quote Link to comment Share on other sites More sharing options...
RyanGC Posted June 15, 2010 Share Posted June 15, 2010 RyanGC,I don't know what that "File access error" means. Do you have those xrefs open? I tested my code many times and it's been working great with xref name changed as well as path changed. Our company only use full path, so I never have to deal with relative paths xrefs. The xrefs are not open. I've tried this is in several different directory setups, to eliminate the possibility that I didn't have "full" access to original test directories, but I don't think this is the problem. I get the impression, after reading another forum thread that "maybe" similar, that this problem has something to do with the loading and access to ARX files... Quote Link to comment Share on other sites More sharing options...
dpenney Posted August 9, 2013 Share Posted August 9, 2013 I've now combined both blkrenamer lisp and the path change lisp from rjp. So if the path changed as well as name changed, it will still work. I kept the xref reload lisp in there because it seems to need it after the pathchange lisp from rjp. Here's what I have now. Hope others will find it useful. I tried to make it as clear as possible of how to modify the lisp for individual use. ;............................................................................... ; ; << Replace old xref files with a set of new xref files >> ; ; << Version 1.0 >> ; ; NOTE: If new xrefs are in a different folder, you must call out ; XrefPathChange.lsp from the code below. ; ;............................................................................... (defun c:xrefnamechange (/ b bcol path) (setq bcol (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (foreach blk '( ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>>>> Enter all xref names below in this format >>>>>> ;>>>>> ("OldXrefName" . "NewXrefName") >>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ("fp01" . "fp01_new") ("ABC" . "ABC_new") ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ) (if (and (not (vl-catch-all-error-p (setq b (vl-catch-all-apply 'vla-item (list bcol (car blk)))))) (= (vla-get-isxref b) :vlax-true) ) (progn (vla-put-name b (cdr blk)) (if (= (setq path (vl-filename-directory (vla-get-path b))) "") (vla-put-path b (strcat (cdr blk) ".dwg")) (vla-put-path b (strcat path "\\" (cdr blk) ".dwg")) ) (vla-reload b) ) ) ) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>> XrefPathChange.lsp call out here. >>>> ;>>> Enter all xref paths to be changed in this format. >>>> ;>>> (xrefpathchange "c:\\Oldfolder\\oldfolder" "c:\\newfolder\\newfolder") >>>> ;>>> Note: Remove code if new xref path is unchanged. >>>> ;>>> Add ; infront of each line to block code. >>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (xrefpathchange "L:\\Buildings\\E" "c:\\temp\\new xref") (xrefpathchange "L:\\Buildings\\A" "c:\\temp\\new xref") (XReload) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (princ) );end of c:XrefNameChange ;........................................................... ;.... Xref Path Change sub routine by ronjonp ...... ;........................................................... (defun xrefpathchange (path1 path2 / newpath xrpath) (vl-load-com) (vlax-map-collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (function (lambda (x) (if (= (vla-get-isxref x) :vlax-true) (progn (setq xrpath (strcase (vlax-get x 'path) t) path1 (strcase path1 t) path2 (strcase path2 t) ) (if (and (vl-string-search path1 xrpath) (setq newpath (vl-string-subst path2 path1 xrpath)) (findfile newpath) ) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-path (list x newpath))) (princ (strcat "\n**OLD path found but was not changed!\n" xrpath)) (princ (strcat "\n" newpath)) ) ) ) ) ) ) ) (princ) ); end of XrefPathChange ;............................................................. ;.... Xref Reload sub routine ....... ;............................................................. (defun XReload (/ cObj cName); Updated 2007-10-1: added error trap (defun *error*(msg) (setvar "modemacro" ".") (setvar "cmdecho" 1) (princ "\n...Reload xref terminated!!! ") (princ) ); end of *error* (setvar "modemacro" "Reloading loaded xrefs......please wait......") (setvar "cmdecho" 0) (setq cObj(tblnext "BLOCK" T)) (while cObj (setq cName(cdr(assoc 2 cObj))) (if (and (=(logand(cdr(assoc 70 cObj))32)32) (=(logand(cdr(assoc 70 cObj))4)4) ); end and (progn (vl-cmdf "_.xref" "_unload" cName) (vl-cmdf "_.xref" "_reload" cName) ); end progn ); wnd if (setq cObj(tblnext "BLOCK")) ); end while (setvar "modemacro" ".") (setvar "cmdecho" 1) (prompt "\n--- Xref change finished! ---") (princ) ); end of XReload Based on a problem we found today regarding Copy Design of drawings in Vault Professional.... I thought I had a decent workaround using this lisp, however it didn't work. The plan involved (in Vault) the auto-renumbering a folder of drawing files to suit the new project, which involved the re-pathing and renaming of the drawings master xrefs (because Vault wont accept identical file-names for good reason). The Vault part of the process worked reasonably well, and although I didn't seem to get any error messages, the lisp itself didn't actually rename any of the 'replacement' Xrefs on checking the (checked out from Vault) drawings on C drive. I double checked the "Old Path"..."New Path" and the "Old Name"...."New name"....and they seemed fine? Old Paths/New path: "c:\Vault\Designs\012 - ARR\0500\GA\Xref" "c:\Vault\Designs\STD - Project\0100\GA\Xref" "c:\Vault\Designs\012 - ARR\0500\GA" "c:\Vault\Designs\STD - Project\0100\GA" Old Xrefs/New Xrefs: "XREF ARR Site Plan.dwg" "XREF GEN Site Plan.dwg" "012-0500-AG-0004.dwg" "STD-0100-AG-0004.dwg" "012-0500-AG-0006.dwg" "STD-0100-AG-0006.dwg" Anybody had any luck with this? Or does anyone know of a working 3rd party tool for achieving this re-path/rename of an identical Xref? Any suggestions would be appreciated. Cheers DP Quote Link to comment Share on other sites More sharing options...
JeepMaster Posted August 9, 2013 Author Share Posted August 9, 2013 Im surprise this thread is still alive. Can you post the actual code that you used? I see a few errors on your naming format from what you wrote if that's what you entered. Quote Link to comment Share on other sites More sharing options...
dpenney Posted August 10, 2013 Share Posted August 10, 2013 Im surprise this thread is still alive. Can you post the actual code that you used? I see a few errors on your naming format from what you wrote if that's what you entered. Yep, entered it differently in the lisp.... ;............................................................................... ; ; << Replace old xref files with a set of new xref files >> ; ; << Version 1.0 >> ; ; NOTE: If new xrefs are in a different folder, you must call out ; XrefPathChange.lsp from the code below. ; ;............................................................................... (defun c:xrefnamechange (/ b bcol path) (setq bcol (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (foreach blk '( ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>>>> Enter all xref names below in this format >>>>>> ;>>>>> ("OldXrefName" . "NewXrefName") >>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ("XREF ARR Site Plan.dwg" "XREF GEN Site Plan.dwg") ("012-0500-AG-0004.dwg" "STD-0100-AG-0004.dwg") ("012-0500-AG-0006.dwg" "STD-0100-AG-0006.dwg") ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ) (if (and (not (vl-catch-all-error-p (setq b (vl-catch-all-apply 'vla-item (list bcol (car blk)))))) (= (vla-get-isxref b) :vlax-true) ) (progn (vla-put-name b (cdr blk)) (if (= (setq path (vl-filename-directory (vla-get-path b))) "") (vla-put-path b (strcat (cdr blk) ".dwg")) (vla-put-path b (strcat path "\\" (cdr blk) ".dwg")) ) (vla-reload b) ) ) ) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>> XrefPathChange.lsp call out here. >>>> ;>>> Enter all xref paths to be changed in this format. >>>> ;>>> (xrefpathchange "c:\\Oldfolder\\oldfolder" "c:\\newfolder\\newfolder") >>>> ;>>> Note: Remove code if new xref path is unchanged. >>>> ;>>> Add ; infront of each line to block code. >>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (xrefpathchange "c:\\Vault\\Designs\\012 - ARR\\0500\\GA\\Xref" "c:\\Vault\\Designs\\STD - Project\\0100\\GA\\Xref") (xrefpathchange "c:\\Vault\\Designs\\012 - ARR\\0500\\GA" "c:\\Vault\\Designs\\STD - Project\\0100\\GA") (XReload) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (princ) );end of c:XrefNameChange ;........................................................... ;.... Xref Path Change sub routine by ronjonp ...... ;........................................................... (defun xrefpathchange (path1 path2 / newpath xrpath) (vl-load-com) (vlax-map-collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (function (lambda (x) (if (= (vla-get-isxref x) :vlax-true) (progn (setq xrpath (strcase (vlax-get x 'path) t) path1 (strcase path1 t) path2 (strcase path2 t) ) (if (and (vl-string-search path1 xrpath) (setq newpath (vl-string-subst path2 path1 xrpath)) (findfile newpath) ) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-path (list x newpath))) (princ (strcat "\n**OLD path found but was not changed!\n" xrpath)) (princ (strcat "\n" newpath)) ) ) ) ) ) ) ) (princ) ); end of XrefPathChange ;............................................................. ;.... Xref Reload sub routine ....... ;............................................................. (defun XReload (/ cObj cName); Updated 2007-10-1: added error trap (defun *error*(msg) (setvar "modemacro" ".") (setvar "cmdecho" 1) (princ "\n...Reload xref terminated!!! ") (princ) ); end of *error* (setvar "modemacro" "Reloading loaded xrefs......please wait......") (setvar "cmdecho" 0) (setq cObj(tblnext "BLOCK" T)) (while cObj (setq cName(cdr(assoc 2 cObj))) (if (and (=(logand(cdr(assoc 70 cObj))32)32) (=(logand(cdr(assoc 70 cObj))4)4) ); end and (progn (vl-cmdf "_.xref" "_unload" cName) (vl-cmdf "_.xref" "_reload" cName) ); end progn ); wnd if (setq cObj(tblnext "BLOCK")) ); end while (setvar "modemacro" ".") (setvar "cmdecho" 1) (prompt "\n--- Xref change finished! ---") (princ) ); end of XReload Quote Link to comment Share on other sites More sharing options...
JeepMaster Posted August 10, 2013 Author Share Posted August 10, 2013 Its missing a "." In between the names. I also added (vl-load-com) to the beginning ng of the code. Try this and see if it makes any difference. ;............................................................................... ; ; << Replace old xref files with a set of new xref files >> ; ; << Version 1.0 >> ; ; NOTE: If new xrefs are in a different folder, you must call out ; XrefPathChange.lsp from the code below. ; ;............................................................................... (defun c:xrefnamechange (/ b bcol path) (vl-load-com) (setq bcol (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (foreach blk '( ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>>>> Enter all xref names below in this format >>>>>> ;>>>>> ("OldXrefName" . "NewXrefName") >>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ("XREF ARR Site Plan.dwg" . "XREF GEN Site Plan.dwg") ("012-0500-AG-0004.dwg" . "STD-0100-AG-0004.dwg") ("012-0500-AG-0006.dwg" . "STD-0100-AG-0006.dwg") ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ) (if (and (not (vl-catch-all-error-p (setq b (vl-catch-all-apply 'vla-item (list bcol (car blk)))))) (= (vla-get-isxref b) :vlax-true) ) (progn (vla-put-name b (cdr blk)) (if (= (setq path (vl-filename-directory (vla-get-path b))) "") (vla-put-path b (strcat (cdr blk) ".dwg")) (vla-put-path b (strcat path "\\" (cdr blk) ".dwg")) ) (vla-reload b) ) ) ) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>> XrefPathChange.lsp call out here. >>>> ;>>> Enter all xref paths to be changed in this format. >>>> ;>>> (xrefpathchange "c:\\Oldfolder\\oldfolder" "c:\\newfolder\\newfolder") >>>> ;>>> Note: Remove code if new xref path is unchanged. >>>> ;>>> Add ; infront of each line to block code. >>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (xrefpathchange "c:\\Vault\\Designs\\012 - ARR\\0500\\GA\\Xref" "c:\\Vault\\Designs\\STD - Project\\0100\\GA\\Xref") (xrefpathchange "c:\\Vault\\Designs\\012 - ARR\\0500\\GA" "c:\\Vault\\Designs\\STD - Project\\0100\\GA") (XReload) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (princ) );end of c:XrefNameChange ;........................................................... ;.... Xref Path Change sub routine by ronjonp ...... ;........................................................... (defun xrefpathchange (path1 path2 / newpath xrpath) (vl-load-com) (vlax-map-collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (function (lambda (x) (if (= (vla-get-isxref x) :vlax-true) (progn (setq xrpath (strcase (vlax-get x 'path) t) path1 (strcase path1 t) path2 (strcase path2 t) ) (if (and (vl-string-search path1 xrpath) (setq newpath (vl-string-subst path2 path1 xrpath)) (findfile newpath) ) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-path (list x newpath))) (princ (strcat "\n**OLD path found but was not changed!\n" xrpath)) (princ (strcat "\n" newpath)) ) ) ) ) ) ) ) (princ) ); end of XrefPathChange ;............................................................. ;.... Xref Reload sub routine ....... ;............................................................. (defun XReload (/ cObj cName); Updated 2007-10-1: added error trap (defun *error*(msg) (setvar "modemacro" ".") (setvar "cmdecho" 1) (princ "\n...Reload xref terminated!!! ") (princ) ); end of *error* (setvar "modemacro" "Reloading loaded xrefs......please wait......") (setvar "cmdecho" 0) (setq cObj(tblnext "BLOCK" T)) (while cObj (setq cName(cdr(assoc 2 cObj))) (if (and (=(logand(cdr(assoc 70 cObj))32)32) (=(logand(cdr(assoc 70 cObj))4)4) ); end and (progn (vl-cmdf "_.xref" "_unload" cName) (vl-cmdf "_.xref" "_reload" cName) ); end progn ); wnd if (setq cObj(tblnext "BLOCK")) ); end while (setvar "modemacro" ".") (setvar "cmdecho" 1) (prompt "\n--- Xref change finished! ---") (princ) ); end of XReload Quote Link to comment Share on other sites More sharing options...
dpenney Posted August 10, 2013 Share Posted August 10, 2013 (edited) Thanks JeepMaster, but nope, didn't work. It would help matters if I had the path correct, should have been AG not GA.....! But even changing those letters didn't help......so this is the latest (with corrected paths - copied and pasted from drawing properties): EDIT: Someone (Jeff_M) kindly gave this a once over for me and realised that the Xref drawings were showing the .dwg" extension! Whereas in the XR Manager, this is not the case. Upon removing the .dwg extensions, AND putting the FULL drawing path WITH the extensions in, it worked! The changes are shown in RED......! Many Thanks Jeff for the pointer in the right direction and anyone else that may have helped me...and after 50 hours, i can finally put my feet up and enjoy the remainder of my weekend! Edit 2: After a few tests, I have noticed it is making paths Absolute. Any way to update this lisp and make paths Relative? Cheers All. ;............................................................................... ; ; << Replace old xref files with a set of new xref files >> ; ; << Version 1.0 >> ; ; NOTE: If new xrefs are in a different folder, you must call out ; XrefPathChange.lsp from the code below. ; ;............................................................................... (defun c:xrefnamechange (/ b bcol path) (vl-load-com) (setq bcol (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (foreach blk '( ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>>>> Enter all xref names below in this format >>>>>> ;>>>>> ("OldXrefName" . "NewXrefName") >>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [color="red"] ("XREF ARR Site Plan" . "XREF GEN Site Plan") ("ARR Site Plan - 16042013" . "XREF GEN Site Plan") ("012-0500-AG-0004" . "STD-0100-AG-0004") ("012-0500-AG-0006" . "STD-0100-AG-0006")[/color] ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ) (if (and (not (vl-catch-all-error-p (setq b (vl-catch-all-apply 'vla-item (list bcol (car blk)))))) (= (vla-get-isxref b) :vlax-true) ) (progn (vla-put-name b (cdr blk)) (if (= (setq path (vl-filename-directory (vla-get-path b))) "") (vla-put-path b (strcat (cdr blk) ".dwg")) (vla-put-path b (strcat path "\\" (cdr blk) ".dwg")) ) (vla-reload b) ) ) ) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>> XrefPathChange.lsp call out here. >>>> ;>>> Enter all xref paths to be changed in this format. >>>> ;>>> (xrefpathchange "c:\\Oldfolder\\oldfolder" "c:\\newfolder\\newfolder") >>>> ;>>> Note: Remove code if new xref path is unchanged. >>>> ;>>> Add ; infront of each line to block code. >>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [color="red"](xrefpathchange "C:\\Vault\\Designs\\012 - ARR\\0500 - PDS 1\\AG\\XREF DRG\\XREF ARR Site Plan.dwg" "C:\\Vault\\Designs\\STD - PROJECT\\0100 - CDP\\AG\\XREF DRG\\XREF GEN Site Plan.dwg") (xrefpathchange "C:\\Vault\\Designs\\012 - ARR\\0500 - PDS 1\\AG\\XREF DRG\\ARR Site Plan - 16042013.dwg" "C:\\Vault\\Designs\\STD - PROJECT\\0100 - CDP\\AG\\XREF DRG\\XREF GEN Site Plan.dwg") (xrefpathchange "C:\\Vault\\Designs\\012 - ARR\\0500 - PDS 1\\AG\\012-0500-AG-0004.dwg" "C:\\Vault\\Designs\\STD - PROJECT\\0100 - CDP\\AG\\STD-0100-AG-0004.dwg") (xrefpathchange "C:\\Vault\\Designs\\012 - ARR\\0500 - PDS 1\\AG\\012-0500-AG-0006.dwg" "C:\\Vault\\Designs\\STD - PROJECT\\0100 - CDP\\AG\\STD-0100-AG-0006.dwg")[/color] (XReload) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (princ) );end of c:XrefNameChange ;........................................................... ;.... Xref Path Change sub routine by ronjonp ...... ;........................................................... (defun xrefpathchange (path1 path2 / newpath xrpath) (vl-load-com) (vlax-map-collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (function (lambda (x) (if (= (vla-get-isxref x) :vlax-true) (progn (setq xrpath (strcase (vlax-get x 'path) t) path1 (strcase path1 t) path2 (strcase path2 t) ) (if (and (vl-string-search path1 xrpath) (setq newpath (vl-string-subst path2 path1 xrpath)) (findfile newpath) ) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-path (list x newpath))) (princ (strcat "\n**OLD path found but was not changed!\n" xrpath)) (princ (strcat "\n" newpath)) ) ) ) ) ) ) ) (princ) ); end of XrefPathChange ;............................................................. ;.... Xref Reload sub routine ....... ;............................................................. (defun XReload (/ cObj cName); Updated 2007-10-1: added error trap (defun *error*(msg) (setvar "modemacro" ".") (setvar "cmdecho" 1) (princ "\n...Reload xref terminated!!! ") (princ) ); end of *error* (setvar "modemacro" "Reloading loaded xrefs......please wait......") (setvar "cmdecho" 0) (setq cObj(tblnext "BLOCK" T)) (while cObj (setq cName(cdr(assoc 2 cObj))) (if (and (=(logand(cdr(assoc 70 cObj))32)32) (=(logand(cdr(assoc 70 cObj))4)4) ); end and (progn (vl-cmdf "_.xref" "_unload" cName) (vl-cmdf "_.xref" "_reload" cName) ); end progn ); wnd if (setq cObj(tblnext "BLOCK")) ); end while (setvar "modemacro" ".") (setvar "cmdecho" 1) (prompt "\n--- Xref change finished! ---") (princ) ); end of XReload Edited August 11, 2013 by dpenney Wrong Xref Name Quote Link to comment Share on other sites More sharing options...
Tripledot Posted July 20, 2016 Share Posted July 20, 2016 Working well till recently hit a snag. If the original path status is "NOT FOUND", it will not replace with the new path. Please advise. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted July 20, 2016 Share Posted July 20, 2016 I can't replicate your problem. Are you sure that your new file path is OK? If the file is not found it will not repath it. Quote Link to comment Share on other sites More sharing options...
Tripledot Posted July 21, 2016 Share Posted July 21, 2016 I can't replicate your problem. Are you sure that your new file path is OK? If the file is not found it will not repath it. Yes, new path is fine cause can manually repath it using the Externally Reference box. The problem is when the current/old xref drawing & folders is no longer there & when the main dwg is open, status indicated "NOT FOUND". That is when i run the LISP, i get this error Command: xrefr Initializing...Automation Error. File access error Command: A photo for your reference Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.