Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Replace old xref files with a set of new xref files

  1. #1
    Member
    Join Date
    2010-05
    Posts
    9
    Login to Give a bone
    0

    Default Replace old xref files with a set of new xref files

    Hi Good Afternoon, evening, morning,

    Firstly i must apologise if i have posted this in the wrong area, i didnt see a specific forum for .lsp related issues

    I am looking for any assistance possible, as from the title i am looking at some kind of Lisp code that will change the X-Ref file name from 'x' to 'y' for multiple x-refs on multiple drawings.

    I have found some information on Google that pointed to a thread back in 2010, instead of copying the code into this thread i have attached the link below

    http://www.cadtutor.net/forum/archiv...p/t-38673.html

    I would like someone to confirm if the LISP code that is metioned in the above thread worked and if someone could please explain how i would go about loading it into my computer and autocad softaware.

    Case history..... Our office in Hamburg has a huge number of x-refs (3000) that have been created and we now wish to update the x-ref file name from a German based accronym to a universal accronym for our global offices. Is there a way that when we open an existing drawing containing x-refs that the Lisp function would rename the x-refs to the new x-ref file name?

    once we have renamed the x-refs we are lookling to relocate them on an international file server for all offices to use, i belive that reference manager can be used for this, its the x-ref file name renaming that has me stumped I would appreciate any assistance where ever possible....


    Many Thanks Kind Regards Simon

  2. #2
    Active Member
    Join Date
    2013-03
    Location
    Can you say DERECHO, Iowa
    Posts
    66
    Login to Give a bone
    0

    Default Re: Replace old xref files with a set of new xref files

    Quote Originally Posted by simon_coupland View Post
    Hi Good Afternoon, evening, morning,

    Firstly i must apologise if i have posted this in the wrong area, i didnt see a specific forum for .lsp related issues

    I am looking for any assistance possible, as from the title i am looking at some kind of Lisp code that will change the X-Ref file name from 'x' to 'y' for multiple x-refs on multiple drawings.

    I have found some information on Google that pointed to a thread back in 2010, instead of copying the code into this thread i have attached the link below

    http://www.cadtutor.net/forum/archiv...p/t-38673.html

    I would like someone to confirm if the LISP code that is metioned in the above thread worked and if someone could please explain how i would go about loading it into my computer and autocad softaware.

    Case history..... Our office in Hamburg has a huge number of x-refs (3000) that have been created and we now wish to update the x-ref file name from a German based accronym to a universal accronym for our global offices. Is there a way that when we open an existing drawing containing x-refs that the Lisp function would rename the x-refs to the new x-ref file name?

    once we have renamed the x-refs we are lookling to relocate them on an international file server for all offices to use, i belive that reference manager can be used for this, its the x-ref file name renaming that has me stumped I would appreciate any assistance where ever possible....


    Many Thanks Kind Regards Simon
    If I'm reading your post right, this might just work... (This is a script not a lisp, so you would need ScriptPro 2 or something to run it...)

    Code:
    -rename
    b
    xrefX_old
    xrefY_new
    -xref
    p
    xrefY_new
    "C:\NEW XREF\xrefY_new.dwg"
    Last edited by FabriCADed; 2013-05-28 at 03:39 PM. Reason: add code tags

  3. #3
    Member
    Join Date
    2010-05
    Posts
    9
    Login to Give a bone
    0

    Default Re: Replace old xref files with a set of new xref files

    Hiya,

    Firstly .... thank you for your feedback


    This is new to me, i have a copy of ScriptPro that i got off the internet,

    so as a newbe to all this my understanding is that i copy the above text into Notepad and save as a .scr file and then load it into the drawings using ScriptPro....

    if all the above is coorect then i am half way there, my only other question is:

    what is the proceedure for repeating this process if there are multiple X-Refs within a drawing that need to be renamed?

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,713
    Login to Give a bone
    0

    Default Re: Replace old xref files with a set of new xref files

    Scripts are very slow by comparison, as they require that each Drawing be opened within the Editor... Methinks you'd be much better off using ObjectDBX to iterate a directory of drawings, to edit the external references programmatically... Just depends on how adept you are at Visual LISP.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  5. #5
    Member
    Join Date
    2010-05
    Posts
    9
    Login to Give a bone
    0

    Default Re: Replace old xref files with a set of new xref files

    Thank You all for the various options really appreciate as much input as possible

    i did come across this when i googled it, i am really interested int the rename part of the .lsp below
    Code:
    ("X-TEST-1a" . "X-TEST-1b")
    ("X-TEST-2a" . "X-TEST-2b")
    ("X-TEST-3a" . "X-TEST-3b")
    something like that looks like it would work, this way i could enter a list of 100 - 200 old to new X-Ref file names to one LISP file and get it to autorun everytime AutoCAD starts...

    Please let me know what part of the code below would do, it seems there is more to it than just rename at the moment

    Many Thanks

    Simon
    Code:
    ;................................................. ..............................
    ;
    ; << 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") >>>>>>
    ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
    ("X-TEST-1a" . "X-TEST-1b")
    ("X-TEST-2a" . "X-TEST-2b")
    ("X-TEST-3a" . "X-TEST-3b")
    
    ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    )
    (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:\\AutoCAD Customisation" "c:\\AutoCAD Customisation\\Working")
    (xrefpathchange "c:\\AutoCAD Customisation" "c:\\AutoCAD Customisation\\Working")
    (xrefpathchange "c:\\AutoCAD Customisation" "c:\\AutoCAD Customisation\\Working")
    
    (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
    Last edited by BlackBox; 2013-05-28 at 03:54 PM. Reason: Please use [CODE] Tags

  6. #6
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,713
    Login to Give a bone
    0

    Default Re: Replace old xref files with a set of new xref files

    Please edit your post to include [CODE ] Tags.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  7. #7
    Member
    Join Date
    2010-05
    Posts
    9
    Login to Give a bone
    0

    Default Re: Replace old xref files with a set of new xref files

    Without sounding like a complete Numpty.... what are [code] tags ???

    the above code was from a post off the internet, i can copy the link into this reply if that helps?

    http://www.cadtutor.net/forum/archive/index.php/t-38673.html

    Sorry for sounding clueless

    Regards

    Simon

  8. #8
    Active Member
    Join Date
    2013-03
    Location
    Can you say DERECHO, Iowa
    Posts
    66
    Login to Give a bone
    0

    Default Re: Replace old xref files with a set of new xref files

    Simon,

    I think that BlackBox is stressing that using Code Tags will eliminate the emoticons from the code you pasted in for example "
    Code:
    c:xrefnamechange
    " is not equal to "crefnamechange"....

  9. #9
    Active Member
    Join Date
    2013-03
    Location
    Can you say DERECHO, Iowa
    Posts
    66
    Login to Give a bone
    0

    Default Re: Replace old xref files with a set of new xref files

    This image shows what I typed for the previous example...
    code.JPG

  10. #10
    Member
    Join Date
    2010-05
    Posts
    9
    Login to Give a bone
    0

    Default Re: Replace old xref files with a set of new xref files

    Ha Ha..... i only just noticed that it copied in the smiley faces ..... sorry my bad ooooops

    hopefully the link i posted should help clear up any confusion

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 7
    Last Post: 2024-02-17, 01:56 AM
  2. Find which files contain a certain xref
    By geoff.80680 in forum AutoCAD General
    Replies: 4
    Last Post: 2009-02-09, 06:04 PM
  3. Repath Xref Files
    By harilalmn in forum VBA/COM Interop
    Replies: 5
    Last Post: 2008-04-16, 02:07 PM
  4. xref Files
    By rhayes.99001 in forum ACA General
    Replies: 1
    Last Post: 2005-11-18, 05:14 PM
  5. XREF files not Updating
    By CLEMENTEM in forum AutoCAD General
    Replies: 1
    Last Post: 2005-04-16, 12:14 AM

Posting Permissions

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