Guus Posted August 22 Posted August 22 Hi, I got a problem at my work: We are going to change the location of all our logos to a new path. Now i hope someone has a solution to change the path from our logo xref with one easy to use LISP or with a command. Al we want to do is change "P:\Sjablonen\LOGO\logo.jpg" to "F:\7- Sjablonen\LOGOS\logo.jpg" I did try to use reference manager, but it takes way to long to load and changing it by hand is going to be a terrible job. Because we are talking about 100-150 drawings with each 4 logos. Please help Quote
SLW210 Posted August 22 Posted August 22 You can add the new path to the Support File Search Path on all computers with AutoCAD. REDIR Express Tool in a script file. 1 Quote
Guus Posted August 23 Author Posted August 23 Hi, I dont know much about making lisp or command stings. But the only thing I want to do is make a commandstring with a path. The commandstring I made is: REDIR;P:\Sjablonen;F:\7 - Sjablonen\Logo's; But it pauses because of the \ symbols. How to avoid this? Quote
SLW210 Posted August 23 Posted August 23 I may have a LISP, I can look, I started one, not sure if I finished the LISP. REDIR is handy, but the LISP would put the old path and new path then select a folder of drawings. As an aside, I long ago made our company LOGO a vector file and placed it in the titleblock drawing. Now just have to repath the titleblocks. Our IT still likes to change where the folders are stored, drives, etc., no clue (more likely it's a "not our problem" attitude) how the software people use is affected. Though I suppose it gives them job security sorting out issues they have caused. Quote
Steven P Posted August 23 Posted August 23 It's an express tool? Might also need to add in " " either side of the file paths REDIR;"P:\\Sjablonen";"F:\\7 - Sjablonen\\Logo's"; 1 Quote
Guus Posted August 23 Author Posted August 23 oke, so if I change \ to / it works. Thats great thanks! 1 Quote
BIGAL Posted August 24 Posted August 24 (edited) As suggested can add support paths via lisp a one time thing for say each computer. But can check if path is already set. We had a Autoload.lsp file it resided on server but every pc loaded it on startup via "Appload, Start up Suite" so can add that check path as part of start up, I stay away from acaddoc.lsp etc Copy and paste to command line (setq *files* (vla-get-files (vla-get-preferences (vlax-get-Acad-object)))) (vlax-dump-object *files*) ;make new support paths exist + new (setq paths (vla-get-SupportPath *files*)) (setq XXXXpaths "L:\\autodesk\\supportfiles;L:\\autodesk\\lisp;L:\\autodesk\\fonts;") (setq newpath (strcat XXXXpaths paths)) (vla-put-SupportPath *files* newpath) For Autocad need to add "Trusted paths" (setq oldtrust (getvar 'trustedpaths)) (setq newtrust (strcat oldtrust ";" "L:\\Autodesk...")) (setvar 'trustedpaths newtrust) There was something about the "..." says look for sub directories below trying to remember Edited August 25 by BIGAL Quote
BIGAL Posted August 24 Posted August 24 Have a look at your other post. Maybe Admin will merge. Quote
SLW210 Posted August 25 Posted August 25 Merged to new thread with a new title, Change Image Path in Many Drawings Quote
SLW210 Posted August 26 Posted August 26 I did a quick test on this, hopefully it works for you, sorry it took so long to find and clean up a little. I was in the process of changing to selecting the folder with a dialog box, but never finished that, at least I don't think they are working yet. Lots of storms over the weekend, my power and internet were in and out, so I got very little done at home. I guess I should add I am no super Lisper, lot's of help from old books (think R14 and before), the various internet forums and numerous individuals. If I can figure this stuff out, almost anyone can at some level do basic programming on AutoCAD IMO. P.S. I use the AutoCAD developers guide a lot, particularly looking up things like vl-, vla-, vlax-, etc. and how they are used. ;;; Update image paths in a folder of drawings. | ;;; | ;;; https://www.cadtutor.net/forum/topic/90022-change-image-path-in-many-drawings/?do=findComment&comment=649609 | ;;; | ;;; By SLW210 (Steve Wilson) | ;;;________________________________________________________________________________________________________________________________________| ;;; | ;;; Original- August 26th, 2024 | ;;; | ;;;________________________________________________________________________________________________________________________________________| ;;; | (defun c:UPP () (c:UpYourPath)) ;; You can change the shortcut to suit what is convenient for you (remember to also change the prompt at the end of the LISP). (defun c:UpYourPath (/ old-path new-path dir files file doc model-space paper-space imgref ) ;; Set the old and new paths (setq old-path "C:\\***\\****\\ImageFile") ;; Add your current file path here. (setq new-path "C:\\***\\****\\ImageFile") ;; Add the new file path here. ;; Prompt user to enter the folder path (setq dir (getstring T "\nEnter the folder path containing the DWG files: " ) ) ;; When prompted type in file path to folder of drawings to update. ;; Check if folder valid (if (not (vl-file-directory-p dir)) (progn (princ "\nInvalid folder. Exiting.") (exit) ) ) ;; Get list of DWG files in the folder (setq files (vl-directory-files dir "*.dwg" 1)) ;; Loop through each file (foreach file files (setq doc (vla-open (vla-get-Documents (vlax-get-acad-object)) (strcat dir "\\" file) ) ) ;; Access model space and paper space (setq model-space (vla-get-ModelSpace doc)) (setq paper-space (vla-get-PaperSpace doc)) ;; Loop through objects in model space (vlax-for obj model-space (if (and (vlax-property-available-p obj 'Path) (wcmatch (vla-get-Path obj) old-path) ) (vla-put-Path obj new-path) ) ) ;; Loop through objects in paper space (vlax-for obj paper-space (if (and (vlax-property-available-p obj 'Path) (wcmatch (vla-get-Path obj) old-path) ) (vla-put-Path obj new-path) ) ) ;; Save and close the drawing (vla-save doc) (vla-close doc) ) ;; Notify process is complete (princ "\nImage paths updated successfully.") ) (princ "\nLoad the script and run 'UPP' or 'UpdateImagePaths' to start." ) Quote
BIGAL Posted August 26 Posted August 26 (edited) Maybe use this https://lee-mac.com/getfilesdialog.html Edited August 26 by BIGAL Quote
SLW210 Posted August 27 Posted August 27 I was looking at LM:DirectoryDialog.lsp and GetFilesV1-6.lsp. Busy at work right now. Quote
SLW210 Posted August 27 Posted August 27 This should work if you have Express Tools..... ;;; Update image paths in a folder of drawings. | ;;; | ;;; https://www.cadtutor.net/forum/topic/90022-change-image-path-in-many-drawings/?do=findComment&comment=649825 | ;;; | ;;; By SLW210 (Steve Wilson) | ;;;________________________________________________________________________________________________________________________________________| ;;; | ;;; Original- August 26th, 2024 | ;;; | ;;; V1.0- August 27th, 2024 Select files and folders added. | ;;; | ;;;________________________________________________________________________________________________________________________________________| ;;; | (defun c:UPP () (c:UpYourPath)) ; You can change the shortcut to suit what is convenient for you. (defun c:UpYourPath (/ folderPath oldPath newPath files file acadApp doc) (defun update-drawing (dwgPath oldPath newPath / acadApp doc blkTbl blkRec entities entity imagePath) (setq acadApp (vlax-get-acad-object)) (setq doc (vla-open (vla-get-Documents acadApp) dwgPath :vlax-false)) (vla-startundomark doc) ;; Get the Block Table (setq blkTbl (vla-get-Blocks doc)) ;; Iterate through blocks (vlax-for blkRec blkTbl (if (and (vlax-property-available-p blkRec 'Name) (vlax-property-available-p blkRec 'BlockType)) (progn ;; Check if it's an image block (if (= (vla-get-BlockType blkRec) acBlockRasterImage) (progn (vlax-for entity (vla-get-Entities blkRec) (if (and (vlax-property-available-p entity 'Path) (vl-string-search oldPath (vla-get-Path entity))) (progn (setq imagePath (vla-get-Path entity)) (setq newPathName (vl-string-subst newPath oldPath imagePath)) (vla-put-Path entity newPathName) (princ (strcat "\nUpdated image path in: " (vla-get-Name blkRec))) ) ) ) ) ) ) ) ) (vla-endundomark doc) (vla-save doc) (vla-close doc) ) ;; Prompt user to select the old image file (setq oldPath (getfiled "Select the old image file" "C:/" "jpg;png;bmp" 10)) (if (not oldPath) (progn (princ "\nNo old image file selected. Exiting.") (exit) ) ) ;; Prompt user to select the new image file (setq newPath (getfiled "Select the new image file" "C:/" "jpg;png;bmp" 10)) (if (not newPath) (progn (princ "\nNo new image file selected. Exiting.") (exit) ) ) ;; Use acet-ui-pickdir to select the folder (setq folderPath (acet-ui-pickdir "\nSelect the folder containing the DWG files: ")) ;; Check if folder is valid (if (or (not folderPath) (not (vl-file-directory-p folderPath))) (progn (princ "\nInvalid folder or operation cancelled. Exiting.") (exit) ) ) (if (and folderPath oldPath newPath) (progn ;; Ensure folderPath has trailing backslash (if (/= (substr folderPath (- (strlen folderPath) 1)) "\\") (setq folderPath (strcat folderPath "\\")) ) ;; Get list of DWG files in the folder (setq files (vl-directory-files folderPath "*.dwg" 1)) (foreach file files (setq file (strcat folderPath file)) (update-drawing file oldPath newPath) ) (princ "\nImage paths updated in all drawings.") ) (princ "\nError: Invalid folder or file paths entered.") ) (princ) ) I have a couple of more in the works to not use Express Tools. I am leaning towards this by rlx Quote
rlx Posted August 27 Posted August 27 (edited) I'm not sure if images behave the same as xrefs but maybe its possible to strip out path completely and use Bigal's suggestion to add path to support path? With xrefs you have something like (setvar "projectname" "MyProjectName") and by adding alternative path(s?) to this variable you can make AutoCad also search there. At my work we don't work with images so I would have to experiment but if it works you would only have to change path in variable 'projectname and you're back on the road. Edited August 27 by rlx Quote
SLW210 Posted August 28 Posted August 28 Or just place the images in the folders of the .dwgs. If on a network, it fixes it for everyone. As stated earlier by me, using the Support Path requires an update to all users. That's why there isn't much out there in the way of code to do this. IIRC there are some paid programs that do this like ToolPac, etc. though I could be mistaken on that. Though unlike other forum responses around the www, I do see a need where it is better to repath a lot of drawings on a network rather than going into every possible users Support Path, but I do know that is something that gets done as well. This should be a default action in AutoCAD, IMO. Quote
rlx Posted August 28 Posted August 28 (edited) Once I had to work on other location and drawings containing xrefs had to be saved with path stripped out and variable projectname set to local networkpath. Now that I'm working on site again I indeed use full networkpath again. Sometimes drawings have to use a 'project xref' so now I have 2 buttons , one to replace path with project path and one to change it back to normal network path. Just meant to say if users use a network profile you would only have to set projectname in one place. Twenty-ish years ago we also had hybrid drawings , where part of the drawing was tif and saved in same folder as drawing , and other part drawn in AutoCad but that not allowed any more where I work , now its tif or dwg , not both. Now I use tif-to-dwg or pdf-to-dwg , replace all polyline texts with normal AutoCad text & voila... Edited August 28 by rlx Quote
BIGAL Posted August 29 Posted August 29 I did where is that person ? A building directory that showed where a person sat in the building plus a index etc, it was like 100 images but they were only relevant to that project, so saved in same location as the dwg, as already suggested, they could be replaced by another as staff left. They were linked for location via image name. If it is corporate images there may be another way around it as provided by one of my clients, they have a dynamic block with each image as a visibility state, these are saved in a master dwg, and using layout copy it is brought into current dwg. A client chosen and some stuff done so only a single client image remains and it is inside the dwg not external as its a OLE object. The building of the dynamic block requires pasting the image into each visibility state. Another way is open image say in paint use Ctrl+C then paste into CAD it should then be a OLE object not an attached image. I tried finding a way to pick a file a say PNG and get it to clipboard using an external program like powershell to do the "to clipboard" part, someone may be able to do a .net program. 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.