Jump to content

Recommended Posts

Posted

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

Posted

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
 )
)

Posted

u want to change the xref path for several files.

 

Did u try to use Reference Manager?

Posted

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.

Posted

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)

Posted

Just a check, when you type them in are they in parentheses? ie (REM_Xref_path)

Posted

Did you Load them into AutoCAD using APPLOAD?

Posted

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.

Posted

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??

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...