ahb001 Posted April 12, 2012 Share Posted April 12, 2012 Hello all, I have about 1500 .tif files that I need to attach to drawings. Is it possible to write a script or macro of some sort that will automate this process? I know how to insert them manually in raster design, but the number of files would be very time consuming. I am using AutoCAD 2009. Any help would be appreciated. Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 12, 2012 Share Posted April 12, 2012 For sure you can use a script to automate this task. Create a BAT file in the same folder with those TIFF files and paste there the code below - run that file to get the list of the files to insert. DIR /b *.TIF > fileslst.txt After I suggest you to use Excel to create the script lines. Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 12, 2012 Share Posted April 12, 2012 (edited) Your script file should look like: _NEW _IMAGE _A [color=magenta]C:\\TiffFiles\\TiffFile1st.TIF[/color] [color=blue]0,0[/color] [color=darkorange]1[/color] [color=darkgreen]0[/color] _ZOOM _E _SAVE [color=red]C:\\DWGFiles\\DWGFile1st.DWG[/color] _CLOSE _NEW _IMAGE _A [color=magenta]C:\\TiffFiles\\TiffFile2nd.TIF[/color] [color=blue]0,0[/color] [color=darkorange]1[/color] [color=darkgreen]0[/color] _ZOOM _E _SAVE [color=red]C:\\DWGFiles\\DWGFile2nd.DWG[/color] _CLOSE _NEW _IMAGE _A [color=magenta]C:\\TiffFiles\\TiffFile3rd.TIF[/color] [color=blue]0,0[/color] [color=darkorange]1[/color] [color=darkgreen]0[/color] _ZOOM _E _SAVE [color=red]C:\\DWGFiles\\DWGFile3rd.DWG[/color] _CLOSE Adjust the colored parts to match your requirements - path of TIFF file, insertion point, scale factor, rotation angle and target DWG file's path. Please take care that after _NEW you should let 2 spaces; also the script should end with an empty line. Save this file with SCR extension. It is very important to don't have spaces in TIFF or DWG paths, since those will be treated as . Call the SCRIPT command, you will be asked to point to the said script file. Edited April 12, 2012 by MSasu Extra comments Quote Link to comment Share on other sites More sharing options...
ahb001 Posted April 16, 2012 Author Share Posted April 16, 2012 Thanks, I got it working...... sort of. I created a test file on my desktop and the script works perfectly. The files I need to work with are on our server and the file path has spaces in it. The script gives an error on the first space every time. Is there a way to ignore the space in the file path? Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 16, 2012 Share Posted April 16, 2012 Try to contain that path with quotation marks ("). _NEW _IMAGE _A "C:\\TiffFiles\\TiffFile1st.TIF" 0,0 1 0 _ZOOM _E _SAVE "C:\\DWGFiles\\DWGFile1st.DWG _CLOSE" Quote Link to comment Share on other sites More sharing options...
ahb001 Posted April 16, 2012 Author Share Posted April 16, 2012 I tried that. It just says enter file name on the command bar at that point. Quote Link to comment Share on other sites More sharing options...
ahb001 Posted April 16, 2012 Author Share Posted April 16, 2012 I am just trying to insert it at this point. This is what my script looks like: _NEW _IINSERT "G:\Engineering\CURRENT JOBS\PLANT\11153 DCS Migration Execute Phase\DRAWINGS\WORKING SET\LOOPS\HEATH1.TIF" This is what shows up in the AutoCAD text window: Command: _IINSERT Command: Enter image file name: "G:\Engineering\CURRENT JOBS\PLANT\11153 DCS Migration Execute Phase\DRAWINGS\WORKING SET\LOOPS\HEATH1.TIF" "G:\Engineering\CURRENT JOBS\PLANT\11153 DCS Migration Execute Phase\DRAWINGS\WORKING SET\LOOPS\HEATH1.TIF" was not found or is not valid. Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 16, 2012 Share Posted April 16, 2012 Seems that the path you used isn'y valid of the file is not available. Please past the line below on AutoCAD's command prompt - if the result will be "nil" then you should re-check the path. (findfile "G:\\Engineering\\CURRENT JOBS\\PLANT\\11153 DCS Migration Execute Phase\\DRAWINGS\\WORKING SET\\LOOPS\\HEATH1.TIF") Quote Link to comment Share on other sites More sharing options...
ahb001 Posted April 16, 2012 Author Share Posted April 16, 2012 Well, if I copied the path and entered it manually, it worked. Just wouldnt work when the script ran. I got it to work though, I think I was missing a space or blank line. Thanks for all your help. Quote Link to comment Share on other sites More sharing options...
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.