cadamrao Posted March 13, 2012 Posted March 13, 2012 Hi friends I need LISP to change xref (from one folder to another folder - location path change) in all drawings at time. some times my copied folder (xref) shown in older xref, All dwgs very difficult to change from (found at) xref dialog box. Advance thanks venki Quote
MSasu Posted March 13, 2012 Posted March 13, 2012 Did you tried the Reference Manager tool? Regards, Mircea Quote
cadamrao Posted March 13, 2012 Author Posted March 13, 2012 I'm using acad2004 only.pls send LISP urgent,bcoz I need to change 82 dwgs thanks Quote
MSasu Posted March 13, 2012 Posted March 13, 2012 You can find here and here some AutoLISP approaches. Regards, Mircea Quote
cadamrao Posted March 13, 2012 Author Posted March 13, 2012 pls find the xref LISP error.i attached the image file.I need to change the xref from the server folder thanks Quote
pBe Posted March 13, 2012 Posted March 13, 2012 (edited) See if this works for you UPDATED (defun c:FindMe (/ LM:FindFile Blks blk NewPath XrefFile) (vl-load-com) (defun LM:FindFile ( file directory ) (cond ( (findfile (strcat (setq directory (vl-string-right-trim "\\" directory)) "\\" file)) ) ( (vl-some (function (lambda ( dir ) (LM:FindFile file (strcat directory "\\" dir)) ) ) (vl-remove "." (vl-remove ".." (vl-directory-files directory nil -1))) ) ) ) ) (setq Blks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (while (setq blk (tblnext "block" (not blk))) (if (and [color=blue][b](= 4 (logand 4 (cdr (assoc 70 blk)))) [/b][/color] (setq NewPath (LM:FindFile (strcat (cdr (assoc 2 blk)) ".dwg") [b][color=blue] "Y:\\VENKI\ST11\\"[/color][/b])) ) (progn (setq XrefFile (vla-item Blks (cdr (assoc 2 blk)))) (vla-put-path XrefFile NewPath) (vla-reload XrefFile)) ) ) ) The container folder is where the code will look for the existing Xref Name on your drawing. Xref name should be the same name as before and only the path is different. kudos to LeeMac for LM:FindFile routine Edited March 14, 2012 by pBe Update Code Quote
cadamrao Posted March 14, 2012 Author Posted March 14, 2012 See if this works for you (defun c:FindMe (/ LM:FindFile Blks blk NewPath XrefFile) (vl-load-com) (defun LM:FindFile ( file directory ) (cond ( (findfile (strcat (setq directory (vl-string-right-trim "\\" directory)) "\\" file)) ) ( (vl-some (function (lambda ( dir ) (LM:FindFile file (strcat directory "\\" dir)) ) ) (vl-remove "." (vl-remove ".." (vl-directory-files directory nil -1))) ) ) ) ) (setq Blks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (while (setq blk (tblnext "block" (not blk))) (if (and (or (= (cdr (assoc 70 blk)) 12) (= (cdr (assoc 70 blk)) 4)) (setq NewPath (LM:FindFile (strcat (cdr (assoc 2 blk)) ".dwg") [color=blue]"P:\\SERVER_PATH\\CONTAINER_FOLER\\"[/color])) ) (progn (setq XrefFile (vla-item Blks (cdr (assoc 2 blk)))) (vla-put-path XrefFile NewPath) (vla-reload XrefFile)) ) ) ) The container folder is where the code will look for the existing Xref Name on your drawing. Xref name should be the same name as before and only the path is different. kudos to LeeMac for LM:FindFile routine ****************************** Good evening! Still ur Lisp not working, waht I need to change xref in drawing new folder I attached the dwg (procedure) for ur reference that need to me. thanks venki xref path issue.dwg Quote
pBe Posted March 14, 2012 Posted March 14, 2012 (edited) Did you change this "P:\\SERVER_PATH\\CONTAINER_FOLER\\" to "Y:\\VENKI\ST11\\" EDIT: I just thought of something, The Xref is currently on the drawing but you want to repath? And theres me thinking the XREF is not found hence (= (cdr (assoc 70 blk)) 12) See Updated CODE AND Since you know where the files are located: [color=blue][b](defun c:FindMe (/ Blks blk pth XrefFile) (vl-load-com) (setq Blks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))[/b][/color] [color=blue][b] (while (setq blk (tblnext "block" (not blk))) (if (and (= 4 (logand 4 (cdr (assoc 70 blk)))) (wcmatch (setq cp (cdr (assoc 1 blk))) "*\\VENKI\\ST10*") ) (progn (setq fn (fnsplitl cp)) (vl-mkdir (setq pth (strcat (vl-string-subst "ST11" "ST10" (car fn))))) (vl-file-copy cp (setq pth (strcat pth (cadr fn) (caddr fn)))) (setq XrefFile (vla-item Blks (cdr (assoc 2 blk)))) (vla-put-path XrefFile pth) (vla-reload XrefFile)) ) ) )[/b][/color] Otherwise use the first code to dig into sub folders. EDIT: Code Updated: to include file copy. Edited March 16, 2012 by pBe vl-file-copy Quote
cadamrao Posted March 16, 2012 Author Posted March 16, 2012 Did you change this"P:\\SERVER_PATH\\CONTAINER_FOLER\\" to "Y:\\VENKI\ST11\\" EDIT: I just thought of something, The Xref is currently on the drawing but you want to repath? And theres me thinking the XREF is not found hence (= (cdr (assoc 70 blk)) 12) See Updated CODE AND Since you know where the files are located: (defun c:FindMe (/ Blks blk NewPath XrefFile) (vl-load-com) (setq Blks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (while (setq blk (tblnext "block" (not blk))) (if (and (= 4 (logand 4 (cdr (assoc 70 blk)))) (wcmatch (setq cp (cdr (assoc 1 blk))) "*\\VENKI\\ST10*") (setq NewPath (findfile (vl-string-subst "ST11" "ST10" cp))) ) (progn (setq XrefFile (vla-item Blks (cdr (assoc 2 blk)))) (vla-put-path XrefFile NewPath) (vla-reload XrefFile)) ) ) ) Otherwise use the first code to dig into sub folders. ************************* Hi Good evening! I appreciated to spend the time for this issue, sorry to say still can’t work. I would checked what u send latest updated LISP followed by server path folder ST11 "Y:\\VENKI\ST11\\")) below error displayed & I attached last updated lisp from you command: findme findme nil ok again I explain.i need to copy my ST10 folder into ST11 in same server, that inside folder drawings (ST11) need to show xref in same folder (ST11). Thanks venki Findme.lsp Quote
pBe Posted March 16, 2012 Posted March 16, 2012 (edited) Your mean to say the files are not yet on this folder "Y:\\VENKI\ST11\\\" ? UPDATE CODE: I'm hopng you have "write" rights on your server Edited March 16, 2012 by pBe Quote
cios106 Posted March 17, 2012 Posted March 17, 2012 i have similar problem, there is a folder in server. Im copying this folder to my desktop. I open the main file, and i see the paths are still on server, i want to change all paths as my desktop. is there any way to do it? thank you all! Quote
asos2000 Posted March 17, 2012 Posted March 17, 2012 i have similar problem, there is a folder in server. Im copying this folder to my desktop. I open the main file, and i see the paths are still on server, i want to change all paths as my desktop. is there any way to do it? thank you all! By using Reference Manager program it comes with AutoCAD Quote
cios106 Posted March 19, 2012 Posted March 19, 2012 By using Reference Manager program it comes with AutoCAD thank you asos2000, i wouldn't know this. Quote
cadamrao Posted March 23, 2012 Author Posted March 23, 2012 Hello! friends Attached LISP I collected from lisp site, this one excellent works for my xref path change (replace another xref) in copied folder, but the problem is I need to open all dwgs and replaced xref one by one, this one also take so much of time .pls anyone to change this LISP to apply all drawings (64 dwgs) in folder. My xref file name CHI-TBLK in old folder ST10 and new folder ST11. Now I need to change my xref in new folder ST11 (after copy my folder ST10 into ST11 xref path shown in ST10. My working folder…server I need to change xref @ Y:\venki\ST11 This is very urgent Thanks venki replace xref.lsp 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.