cpriedel Posted August 8, 2008 Posted August 8, 2008 Hi, i found this lisp on CADDmager (author: Mark McDonough) and it gives a relative path to the Xrefs in our drwings. I am currently trying to find a way to archive our files without having to repath the xrefs in every .dwg we archive. Since the LISP is apparently to long to post here the link to the website i found it on: http://www.plantbuzz.com/cad/cad_utils.htm the directory we are using for our current projects is e.g.: Z:\Files\Current Files\Projectname.... and for our archived projects we use Z:\Files\Archived Files\Projectname.... my problem is by using this Lips it changes the relative path to ..\..\Current Files\Projectname\drawings\Xref.dwg and i want it to change the relative path to ..\..\projectname\drawings\xref.dwg I am pretty sure this is an easy one for you all but i cant figure out where to change what since i have very little experiance with writing lisps. Any help is appreciated Thx Quote
borgunit Posted August 9, 2008 Posted August 9, 2008 Here is a few of my XREF codes. See if any help you. Good luck. ;------------------------------------------------------------------------------ ;REM_XREF_PATH: Remove external reference path ;------------------------------------------------------------------------------ (defun REM_XREF_PATH (/ NEWPATH PPOS XPATH XREF XREFNAME XREFS) (if (= (setq XREFS (GETXREF)) nil) ;(alert "No XREF's are present") (princ) (progn (if (= (setq LISTLEN (length XREFS)) 1) (progn (setq XREFNAME (car XREFS)) (setq XREF (tblsearch "BLOCK" XREFNAME)) (setq XPATH (cdr (assoc 1 XREF))) (setq PPOS (pp_LastCharPosInString XPATH "\\")) (if PPOS (progn (setq NEWPATH (substr XPATH (1+ PPOS))) (if (not (FILE_EXIST_CURR_FOLDER NEWPATH)) (alert "XREF drawing does not reside in folder with this drawing, \nor the name of the file does not match the XREF path. \nPlease correct this before proceeding.") (progn (command "-XREF" "PATH" XREFNAME NEWPATH) (princ "\nXREF path changed") );progn );if );progn ;(princ "\nXREF path is correct already.") );if );progn (alert "More than 1 XREF exists.\nPlease correct this before processing") );if );progn );if (princ) );defun ;------------------------------------------------------------------------------ ;GETXREF: Get external reference path ;------------------------------------------------------------------------------ (defun GETXREF (/ ABLOCK ACTIVEDOC ITEM THEBLOCKS THELIST YESXREF) ;retrieve a reference to the Active Document (setq ACTIVEDOC (vla-get-activedocument (vlax-get-acad-object))) ;retrieve a reference to the blocks (setq THEBLOCKS (vla-get-blocks ACTIVEDOC)) ;create an empty list (setq THELIST '()) ;process each block (vlax-for ITEM THEBLOCKS ;check if it's an Xref (setq YESXREF (vlax-get-property ITEM 'ISXREF)) ;if it is (if (= YESXREF :vlax-true) ;do the following (progn ;get the Xref name (setq ABLOCK (vlax-get-property ITEM 'NAME)) ;store it in the list (setq THELIST (append (list ABLOCK) THELIST)) ) ;progn ) ;if ) ;vlax-for ;print the list THELIST ) ;defun ;------------------------------------------------------------------------------ ;LISTXREFS: List all external references ;------------------------------------------------------------------------------ (defun LISTXREFS (/ CODE ENT) (apply 'append (mapcar '(lambda (X / ENT CODE) (if (= (logand (setq CODE (cdr (assoc 70 (setq ENT (entget (tblobjname "BLOCK" X))) );assoc );cdr );setq 4);logand compare to see if 4 is present in dotted 70 ;if 4 is present, it is an xref 4);equal to ;if the logand = 4 then create the list of properties (list (list (cdr (assoc 2 ENT)) (if (= (logand CODE 8) "Overlay" "Attachment" );if (if (= (logand CODE 32) 32) "Loaded" "Unloaded" );if (cdr (assoc 1 ENT)) );list ) ;list ) ;if ) ;lambda (TABLE "BLOCK") ;list all blocks in block table );mapcar ) ) Quote
asos2000 Posted August 11, 2008 Posted August 11, 2008 u want to change the xref path for several files. Did u try to use Reference Manager? Quote
cpriedel Posted August 12, 2008 Author Posted August 12, 2008 yes i want to change the path of all xrefs that are in the drawing (usually between 1-10). i do use the Xref mager to load and reload the xrefs but it takes a while to reastablish all the path of all the files we archive since the path is changing as soon as you move the project folder. Since the whole project folder gets moved (so the subfolders stay the same) i thought i could save some time and just run the lisp before i move the folder to archived projects and the Xrefs stay loaded since they dont loode the path. Quote
cpriedel Posted August 12, 2008 Author Posted August 12, 2008 Borgunit, Thank you very much for sharing your codes. Unfortunatly I can not use them for some reason. I saved them in Notepad as .lsp-files. Loaded them in autocad successfully and when i try to run the .lsp it says unknown command. Nor sure what i am doing wrong (was typing REM_Xref_Path , Getxref and Listxrefs in Command line and all said unknown) Quote
borgunit Posted August 13, 2008 Posted August 13, 2008 Just a check, when you type them in are they in parentheses? ie (REM_Xref_path) Quote
SLW210 Posted August 13, 2008 Posted August 13, 2008 Did you Load them into AutoCAD using APPLOAD? Quote
cpriedel Posted August 13, 2008 Author Posted August 13, 2008 yes i loaded the Lsp. Even added it to the Startup Suite. Closed the Autocad (thought it may need a restart) and still this message: >>Command: REM_Xref_path Unknown command "REM_XREF_PATH". Press F1 for help. Quote
Gringo Posted August 13, 2008 Posted August 13, 2008 maybe change the start of each function from (defun REM_XREF_PATH (defun GETXREF (defun LISTXREFS to (defun c:REM_XREF_PATH (defun c:GETXREF (defun c:LISTXREFS I don't know but does that make a difference?? Change the file save it then reappload it then run comands It should work?? also borgunit it seems as though you know your stuff about xrefs - would you be able to have a look at my post that i put up in the lisp section - it should be easy to find its my only post - maybe you can help me aswell?? Quote
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.