View Full Version : I want to insert 50 (more or less) images into a drawing
droak
2006-03-10, 01:38 PM
I want to insert 50 (more or less) images into a drawing.
1) I am using AutoCAD 2006.
2) All the files are located in the same folder.
3) All the files have a similar naming convention; H541-0200 REV A TEST_45.tif,
H541..._46.tif, H541..._4.tif.
4) To over-ride the dialog box, I have set Expert to 4.
5) I can't highlight the entire list of Image-Files and paste them into the Image Manager.
6) I don't want to type all the file names into the Image Manager.
7) As I remember from long ago, I should be able to use CAR, CDR, CADR... to enter the
file names; I can't remember the syntax, and I think I may need to build a list as well.
8) Please look at the last Command Statement, and suggest what I should enter into the <<< ??? >>>.
(defun c:QTemp ()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;
;;;;; This LISP is for making sketches for quoting
;;;;; purposes.
;;;;;
;;;;; Um-teen images will be inserted into a
;;;;; template drawing. The images will be placed
;;;;; on their own layers. And Layout Tabs will be
;;;;; created for each image also.
;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;Retrieve the Environment
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
(setq oldblip (getvar "blipmode");
oldblip (getvar "blipmode");
oldecho (getvar "cmdecho");
oldosmode (getvar "osmode");
oldorthomode (getvar "orthomode");
oldpolarmode (getvar "polarmode");
oldautosnap (getvar "autosnap");
oldlayer (getvar "clayer");
oldexpert (getvar "expert");
oldluprec (getvar "luprec");
;;
(setvar "blipmode" 0);
(setvar "cmdecho" 0);
(setvar "luprec" 2);
(setvar "expert" 4);
);; end of setq;
;;
(command "layer" "new" "Sheet-1" "current" "")
(Command "Image" "A" "C:/Documents and Settings/Darrell.Roak.PUMP_EXCH/Desktop/H541-0200 REV A TEST_45.tif" "" "" "" "")
(command "layer" "new" "Sheet-2" "current" "")
(Command "Image" "A" "C:/Documents and Settings/Darrell.Roak.PUMP_EXCH/Desktop/<<< ??? >>>" "" "" "" "")
;;
): End Defun
I am apt to ask a question or two more, but for now I would like to address this one issue.
Respectfully,
Darrell
[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]
rkmcswain
2006-03-10, 01:56 PM
No need to fool with EXPERT.
(setq dir "C:\\T")
(foreach item (vl-directory-files dir "*.png" 1)
(command "._image" "_a" (strcat dir "\\" item) "" "" "")
)
That will insert all the .PNG files in the directory "C:\T"
Modify as needed.
If your images are georeferenced, you will have to extract the insertion and scaling parameters and feed them to the ._image command.
droak
2006-03-10, 11:05 PM
I typed:
(foreach item (vl-directory-files "T:\\ENG FILES\\DRAWINGS\\DRAWINGS\\CD to Server GOV Drawings\\Electric Boat\\LET Trunk Drawings\\" ".png" 1))
where:
T:\ENG FILES\DRAWINGS\\DRAWINGS\CD to Server GOV Drawings\Electric Boat\LET Trunk Drawings\
is the Path for the Image Files.
I tried using a forward-slash as well as the double-backslash as well.
The result was:
; error: too many arguments
Are the spaces within the Folder-Names an issue? Or, have I miss-interpreted you intended syntax?
Darrell
Hi Darrell,
I think the attached code is what RK had in mind: (I didn't post it in a code window because of word wrap issues).
But don't forget what he said:
If your images are georeferenced, you will have to extract the insertion and scaling parameters and feed them to the ._image command.
The attached code will insert them at 0,0, and I haven't had experience with georeferenced images so I can't help you with that (yet).
And, for the layers, I don't know what goes on what layer, so I can't help with that, either. Sorry.
I hope this gets you closer to your goal,
rkmcswain
2006-03-11, 02:05 AM
I typed:
(foreach item (vl-directory-files "T:\\ENG FILES\\DRAWINGS\\DRAWINGS\\CD to Server GOV Drawings\\Electric Boat\\LET Trunk Drawings\\" ".png" 1))
But you missed some...
(setq dir "C:\\T");<- set up the directory name
(foreach item (vl-directory-files dir "*.png" 1);<- are your drawings .PNG's??
(command "._image" "_a" (strcat dir "\\" item) "" "" "");<- you missed this line
)
rkmcswain
2006-03-11, 02:10 AM
haven't had experience with georeferenced images so I can't help you with that (yet).
The world file (.TFW) format is documented, assuming that is where the correlation information is stored. (It's also possible to embed this information in the TIFF image).
The OP might benefit from looking at Toolpac [ http://www.dotsoft.com ] which includes a tool for inserting multiple georeferenced images. If they do not include a world file, I'm not sure of the point, since they will all fall on top of each other...
:beer:
droak
2006-03-11, 02:03 PM
I have finally got your code to work, but:
1) The images are entered into the Image-Manager, but they are "unreferenced"
2) The response from the command 1s listed below:
Command: (setq dir "T:\\ENG FILES\\DRAWINGS\\DRAWINGS\\CD to Server GOV
Drawings\\Electric Boat\\LET Trunk Drawings\\")
"T:\\ENG FILES\\DRAWINGS\\DRAWINGS\\CD to Server GOV Drawings\\Electric
Boat\\LET Trunk Drawings\\"
Command: (foreach item (vl-directory-files dir "*.tif" 1)
(_> (command "._image" "_a" (strcat dir "T:\\ENG
FILES\\DRAWINGS\\DRAWINGS\\CD to Server GOV Drawings\\Electric Boat\\LET Trunk
Drawings\\" item) "" "" "")
(_> )
._image Enter image option [?/Detach/Path/Reload/Unload/Attach] <Attach>: _a
Enter image file name to attach: T:\ENG FILES\DRAWINGS\DRAWINGS\CD to Server
GOV Drawings\Electric Boat\LET Trunk Drawings\T:\ENG FILES\DRAWINGS\DRAWINGS\CD
to Server GOV Drawings\Electric Boat\LET Trunk Drawings\H541-0200 REV A
TEST_45.tif
Image not found.
Enter image file name to attach:
Invalid or unsupported image file.
Enter image file name to attach:
Invalid or unsupported image file.
Enter image file name to attach:
Invalid or unsupported image file.
Enter image file name to attach: ._image
Image not found.
Enter image file name to attach: _a
Image not found.
3) It appears that I need to place the location (0,0), the scale (0) and the rotation (0) into
the code, and it is not being requested. (as you indicated by referencing "georeferenced
images").
4) This Code works really well for one image:
(command "_image" "attach" "T:\\ENG FILES\\DRAWINGS\\DRAWINGS\\CD to
Server GOV Drawings\\Electric Boat\\LET Trunk Drawings\\H541-0200 REV A
TEST_50.tif" "" "" "" "")
5) It places the image where I want it to be, and it rotates it as needs and it scales it
properly.
6) So my original thought was to run this code continually (with continually changing
suffixes).
7) This may seem like a lot of work to do, but I have been tasked with creating several
thousand sketches.
8) Should I continue in the direction you are leading me, or should I revert to my original
course of logic.
Darrell
rkmcswain
2006-03-11, 06:36 PM
Are you are entering these lines at the command line?
Although technically possible, not the best route. Looking at the code you are posting back, you are modifying what I am posting. That is why it isn't working.
Open AutoCAD, type in VLIDE at the command line. When the VLIDE opens, start a new file. Paste in the code below. Save this file. Close VLIDE.
(defun c:multi_images ( / dir)
(setq dir "T:\\ENG FILES\\DRAWINGS\\DRAWINGS\\CD to Server GOV
Drawings\\Electric Boat\\LET Trunk Drawings"); leave off the ending \\
;dont repeat the path in the line below, use "dir"
(foreach item (vl-directory-files dir "*.TIF" 1)
(command "._image" "_a" (strcat dir "\\" item) "" "" "")
; each double quote above represents the {enter} key
; if you need to enter different values for the
; location, rotation, scale, then do it
)
At the AutoCAD command line, type in APPLOAD. Find the file, load it.
Type in MULTI_IMAGES to start
This method WILL WORK - I have tested it myself here using several images.
droak
2006-03-13, 01:28 PM
The instructions you've given make sence to me.
I entered the code as you typed it and recieved a malformed list error. When I entered the command, I got nil.
I reviewed the code and it seemed to be missing a close parentasis at the end of the foreach statement.
The code I entered:
(defun c:multi_images ( / dir)
(setq dir "T:\\ENG FILES\\DRAWINGS\\DRAWINGS\\CD to Server GOV Drawings\\Electric Boat\\LET Trunk Drawings")
(foreach item (vl-directory-files dir "*.TIF" 1))
(command "._image" "_a" (strcat dir "\\" item) "" "" "")
)
Result from AutoCAD Text Window:
Command: appload
Multi_Images.lsp successfully loaded.
Command:
Command:
Command: Multi_Images
._image Enter image option [?/Detach/Path/Reload/Unload/Attach] <Attach>: _a
Enter image file name to attach: ; error: bad argument type: stringp nil
I checked the Image Manager Dialog Box, and no files were attached.
I checked the path, it is correct. I checked for extra spaces, there aren't any.
Are there any variables I have set that should be set differently?
Expert = 0
FILEDIA = 1
CMDDIA = 1
CMDACTIVE = 1
I have one last comment; there are files within the "LET Trunk Drawings" Folder which are not image files, I believe that by using "*.TIF" those files are disreguarded.
rkmcswain
2006-03-13, 04:36 PM
Do the same thing with this lisp code:
(defun c:test ( / dir)
(setq dir "T:\\ENG FILES\\DRAWINGS\\DRAWINGS\\CD to Server GOV Drawings\\Electric Boat\\LET Trunk Drawings")
(foreach item (vl-directory-files dir "*.TIF" 1)
(princ "\n")
(princ (strcat dir "\\" item))
)
(princ)
)
Now after you save this and load it, run TEST at the command line. Rather than INSERT the images, this will just print the path and name of each one it finds. If nothing is returned, then you have a problem with the path or .TIF part.
droak
2006-03-13, 04:42 PM
That worked as designed:
The Result on the AutoCAD Text Window is:
C:TEST
Command: test
T:\ENG FILES\DRAWINGS\DRAWINGS\CD to Server GOV Drawings\Electric Boat\LET
Trunk Drawings\H728-4501 REV A_01.tif
T:\ENG FILES\DRAWINGS\DRAWINGS\CD to Server GOV Drawings\Electric Boat\LET
Trunk Drawings\H728-4501 REV A_02.tif
T:\ENG FILES\DRAWINGS\DRAWINGS\CD to Server GOV Drawings\Electric Boat\LET
Trunk Drawings\H728-4501 REV A_03.tif
T:\ENG FILES\DRAWINGS\DRAWINGS\CD to Server GOV Drawings\Electric Boat\LET
Trunk Drawings\H728-4501 REV A_04.tif
T:\ENG FILES\DRAWINGS\DRAWINGS\CD to Server GOV Drawings\Electric Boat\LET
Trunk Drawings\H728-4501 REV A_05.tif
T:\ENG FILES\DRAWINGS\DRAWINGS\CD to Server GOV Drawings\Electric Boat\LET
Trunk Drawings\H728-4501 REV A_06.tif
T:\ENG FILES\DRAWINGS\DRAWINGS\CD to Server GOV Drawings\Electric Boat\LET
Trunk Drawings\H728-4501 REV A_07.tif
T:\ENG FILES\DRAWINGS\DRAWINGS\CD to Server GOV Drawings\Electric Boat\LET
Trunk Drawings\H728-4501 REV A_08.tif
T:\ENG FILES\DRAWINGS\DRAWINGS\CD to Server GOV Drawings\Electric Boat\LET
Trunk Drawings\H728-4501 REV A_09.tif
T:\ENG FILES\DRAWINGS\DRAWINGS\CD to Server GOV Drawings\Electric Boat\LET
Trunk Drawings\H728-4501 REV A_10.tif
T:\ENG FILES\DRAWINGS\DRAWINGS\CD to Server GOV Drawings\Electric Boat\LET
Trunk Drawings\H728-4501 REV A_11.tif
T:\ENG FILES\DRAWINGS\DRAWINGS\CD to Server GOV Drawings\Electric Boat\LET
Trunk Drawings\H728-4501 REV A_12.tif
rkmcswain
2006-03-13, 05:04 PM
I just created my own:
"T:\\ENG FILES\\DRAWINGS\\DRAWINGS\\CD to Server GOV Drawings\\Electric Boat\\LET Trunk Drawings" drive letter and path. I then copied some TIF images in there, then renamed them the same as yours.
It works fine here.
In your LISP file, make sure that the (setq dir....) statement is all on one line. I know it's broken as displayed here, but it should be on ONE line.
Here are some screen caps.
http://forums.augi.com/attachment.php?attachmentid=20867&stc=1
http://forums.augi.com/attachment.php?attachmentid=20868&stc=1
droak
2006-03-13, 06:04 PM
Finally Success!!!!!!!!!!
A few replies ago, I added a close Parenthesis at the end of the Foreach Statement.
I noticed in your screen shot that you had the Parenthesis in another location, so I duplicated that.
Thank you so much. I'll be asking my next question after lunch, hopefully I won't appear so dense.
Darrell
rkmcswain
2006-03-13, 06:13 PM
I noticed in your screen shot that you had the Parenthesis in another location, so I duplicated that.
You know what they say....
A picture is worth a thousand words...
jack.foster
2008-03-01, 04:18 AM
Thanks to RKMcSwaim I will have to order another AUGI sweatshirt. Your help with this problem I copied and modifed to create a program to output the names of all the drawing files in a folder on the network. I could not do this using shell and dir because they put spaces in the file names which screwed it up. Modifying the above to the code I am posting below worked perfectly. I had beat on the keyboard for a few frustrating hours and then I came to old faithful AUGI. Thank you a WHOLE BUNCH. Jack Foster
(defun c:test ( / dir)
(setq kisspfl "I:\\PlotScripts\\");path to output file to
(setq fow1 (open (strcat kisspfl "PlotDwgs.SCR") "w"));file & path for "dir" list.
(setq dir (getvar "dwgprefix"))
(foreach item (vl-directory-files dir "*.dwg" 1);this is what I borrowed or stole
(princ "\n")
(princ (strcat dir "\\" item))
(write-line item fow1);writes each file name to a folder
)
(close fow1)
(princ)
)
Moderator Note:
Please use [ CODE ] tags. (http://forums.augi.com/misc.php?do=bbcode#code)
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.