Jump to content
ahb001

Attaching Multiple tif's to separate drawings?

Recommended Posts

ahb001

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.

Share this post


Link to post
Share on other sites
MSasu

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.

Share this post


Link to post
Share on other sites
MSasu

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 by MSasu
Extra comments

Share this post


Link to post
Share on other sites
ahb001

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?

Share this post


Link to post
Share on other sites
MSasu

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"

Share this post


Link to post
Share on other sites
ahb001

I tried that. It just says enter file name on the command bar at that point.

Share this post


Link to post
Share on other sites
ahb001

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.

Share this post


Link to post
Share on other sites
MSasu

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")

Share this post


Link to post
Share on other sites
ahb001

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×