feargt Posted May 21, 2009 Author Posted May 21, 2009 Hi Ronjonp, I won't be able to check this until tomorrow when I'm back in work unfortunately. But maybe you can tell me something in the mean time. Will this completely change the path or replace part of the xref path? This is the reason that I wanted to use the redir command originally. After _projects in the path name comes the project number followed by some sub directory names. The part I want to swap is common to all xrefs and images and is found only at the start of the path. Thanks Quote
ronjonp Posted May 21, 2009 Posted May 21, 2009 It will only replace part of it ....give this a try: (alert (vl-string-subst "\\\\SERVER101\ACAD\\_Projects" "B:\\_Projects" "B:\\_Projects\\myfolder\\123\\abc")) Quote
feargt Posted May 22, 2009 Author Posted May 22, 2009 It will only replace part of it ....give this a try: (alert (vl-string-subst "\\\\SERVER101\ACAD\\_Projects" "B:\\_Projects" "B:\\_Projects\\myfolder\\123\\abc")) Hi ronjonp, many thanks again for your time on this. So I've tested this and I cannot get it to work. When I test it I get this Befehl: vlisp b:\_projects\P101\standard\xref_plankopf.dwg ACADDOC.LSP loaded.... This is what I am using. (defun rjp-changexrefpath (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)) (if (and (vl-string-search (strcase path1 t) 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) ) (rjp-changexrefpath "B:\\_Projects" "\\\\SERVER101\\acad\\_Projects") I've tried running it, then saving and reopening but the path does not change. I cannot see why it does not work. (alert (vl-string-subst "\\\\SERVER101\ACAD\\_Projects" "B:\\_Projects" "B:\\_Projects\\myfolder\\123\\abc")) I tried this and works as it should.....so I'm a bit stumped at the mo. Can anyone else see why it doesn't work for me? Quote
Lee Mac Posted May 22, 2009 Posted May 22, 2009 Try changing this: (rjp-changexrefpath "B:\\_Projects" "\\\\SERVER101\\acad\\_Projects") to this: (rjp-changexrefpath "\\\\SERVER101\\acad\\_Projects" "B:\\_Projects") Quote
feargt Posted May 22, 2009 Author Posted May 22, 2009 Hi Lee, I tried that but with no success. From the original post by ronjonp it sounds as though it was working for ronjonp. (alert (vl-string-subst "\\\\SERVER101\ACAD\\_Projects" "B:\\_Projects" "B:\\_Projects\\myfolder\\123\\abc")) From this quote it appears that the paths are in the correct order with (rjp-changexrefpath "B:\\_Projects" "\\\\SERVER101\\acad\\_Projects") Quote
feargt Posted May 22, 2009 Author Posted May 22, 2009 Ok for now I have a solution, Whether it is the optimal solution or not I cannot say. But basically from the acaddoc.lsp file, I am now calling a script file which runs the Redir command. This works now. Thanks for all the input but if anyone does have a better solution please share it. Thanks Quote
ronjonp Posted May 22, 2009 Posted May 22, 2009 Sorry for the late response...will you give this a try and let me know if it works for you. I think the issue before was related to strcase (defun rjp-changexrefpath (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) ) Quote
feargt Posted May 22, 2009 Author Posted May 22, 2009 Hi ronjonp, I certainly will give it a shot, but it will be Monday I'd say before I get a chance to. Thanks for following it up. Will give you the feedback as soon as I try it. Thanks Quote
feargt Posted May 26, 2009 Author Posted May 26, 2009 So I tried that out and it works. But as you said the result is only visible in the Classic Xref dialogue box. Unfortunately I don't know any VB, VBA so I do not know how to modify this so that it works on images too. For now I'll leave it using my script file. It seems to be working well. But I am considering also redefining the Save command so that it also runs the script. That way it will work on both new Xref files which are created in a short space of time and require no modification (ie. Ortho photos. after theý are created they do not need to be opened again and a are only used as an xref)and also will work on existing drawings in older projects. Thanks again to everyone for their help Quote
Grenco Posted December 15, 2009 Posted December 15, 2009 Hey there, I've got the same kind of problem here with replacing a server. I think this a good VBA to renew the path to another path: Public Sub Rename_XPath() Dim tempBlock As AcadBlock For Each tempBlock In ThisDrawing.Blocks If tempBlock.IsXRef Then ' Block is an external reference If Left(tempBlock.Path, 5) = "xxxx" Then 'Checks the first 5 characters if the x-ref has a old path tempBlock.Path = "[color=red]NEW PATH[/color]" & tempBlock.Name & ".dwg" tempBlock.Reload End If End If Next End Sub This looks much more easier to me.... Please comment! Quote
ronjonp Posted January 16, 2010 Posted January 16, 2010 Why not use the code already given to you? Quote
Lee Mac Posted January 22, 2010 Posted January 22, 2010 I'm more a VBA-dude then a Lisp-er I would be inclined to be more of a LISP-dude than VBA-er, seeing as VBA is getting phased out... Quote
Grenco Posted January 25, 2010 Posted January 25, 2010 I would be inclined to be more of a LISP-dude than VBA-er, seeing as VBA is getting phased out... Speeking of that. Can you tell me anything about the phasing out of VBA? And how it's supported in future autocad version? Will there be another way to program things for your own? Probably there is something on the internet about that but I wasn't able to find anything concrete. Quote
Lee Mac Posted January 25, 2010 Posted January 25, 2010 Can you tell me anything about the phasing out of VBA? And how it's supported in future autocad version? Will there be another way to program things for your own? Here is a good thread detailing it: http://www.cadtutor.net/forum/showthread.php?t=32857 Also, in it's no longer installed on 2010: 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.