PDA

View Full Version : Save dwg with attached image name


carlos.a.argueta
2004-12-15, 11:25 PM
I need to attach a .Tiff file to a blank dwt then save as a dwg with the name of the attached file. My basic steps are to attach the file, do some stuff to it then save. I can't figure out how to get the attached name to also be the dwg name. I want to do this using my very basic lisp abilities.

Thanks to anyone who can help

kennet.sjoberg
2004-12-16, 12:58 PM
Hi Carlos !

Who was first, the hen or the egg ?

open a drawing, then Command :
_new and use . for no template <= Then You have an empty drawing with no name
_imageattach attach the tiff file <= You must know the tiff file name here ( or are You a magician ? )
_saveas dwg, the name is the same as the tiff, but extension .dwg

Beware to use a image file(.tif) in a template file(.dwt) or drawing file(.dwg) because it act as an Xref and You must always distribute the image file together with the drawing file, else the information is missing, You can not "bind the image as a block". ( or am I wrong ? )

: ) Happy Computing !

kennet

Mike.Perry
2004-12-16, 02:18 PM
You can not "bind the image as a block". ( or am I wrong ? )Hi

The below offers a workaround.

Check out the following Submission # EX001348 by Celie Dailey on the AUGI Exchange Page -

AUGI Exchange Search Page (http://www.augi.com/exchange/search.asp?page=415)

Have a good one, Mike

kennet.sjoberg
2004-12-16, 03:50 PM
...hmmm Mike, is there a way to see the picture ? I can only see the OLE "post stamp" to a jpg or tiff file. But if I link to a program like Word or Excel it works.

_imageattach work as I mentioned
_insertobj do not work as "Celie Dailey" mentioned
( AutoCAD 2002 )

: ) Happy Computing !

kennet

Mike.Perry
2004-12-16, 03:58 PM
Hi

Works for me, please refer to attached ZIP file for example.

Have a good one, Mike

kennet.sjoberg
2004-12-16, 04:36 PM
Great Mike, how do You do.. line by line . .

: ) Happy Computing !

kennet

Mike.Perry
2004-12-16, 04:44 PM
Hi

Below is one method:

Open JPG image in MS Paint
Edit PullDownMenu -> Select All
Edit PullDownMenu -> Copy

New drawing file in AutoCAD (2002)
Edit PullDownMenu -> Paste Special -> Picture (Metafile) -> OK button

JPG image is no embedded within AutoCAD drawing file.

Have a good one, Mike

kennet.sjoberg
2004-12-16, 05:03 PM
OK, Thank You Mike,

I was struggling with _imageattach and _insertobj

: ) Happy Computing !

kennet

carlos.a.argueta
2004-12-16, 05:30 PM
Kennet

Thanks for the info. I was able to use the . for no template but I can't get a command line version for image attach. Also when I go to the command line and use the saveas command, the name of the file to be saved is not the name of the tif file but the name of the open drawing (e.g. drawing1, drawing2). Is there a variable that controls the image attach dialog box in 2005? Unfortunately I am not allowed to down Zip files to my place of employment so I can't view the file that Mike Perry posted.

Thank you

kennet.sjoberg
2004-12-17, 08:08 AM
Hi Carlos, the way Mike Perry was doing, was to cut from an other application
and then paste by hand into AutoCAD, not to import a file programmatically.

But here may be a start for You to play with. . .


(defun c:imagein ( / OldFileDia MyImage MyDwtFile MySaveFormat )
(setq OldFileDia (getvar "FILEDIA" ) ) ; Save the old variable
(setvar "FILEDIA" 0 ) ; Supress the file dialogbox
(setq MyImage "D:/grafik/tif/boat400k.tif" ) ; <<----------- Give the name of Your image
(setq MyDwtFile (strcat (substr MyImage 1 (vl-string-position (ascii ".") MyImage ) ) ".dwt" ) ) ; Make DwtName of ImageName
(command "-image" "Attach" MyImage* "0,0" "1" "0" ) ; Attach the image in command line mode
(command "Zoom" "E" ) ; Show the image
(setq MySaveFormat (getenv "DefaultFormatForSave" ) )
(setenv "DefaultFormatForSave" "14" ) ; change saveas format
(command "_saveas" "Template" MyDwtFile ) ; Save the new "image-template-dwt"
(command) ;; I do not know how to get rid of the dialogbox "Template Description" here
(setenv "DefaultFormatForSave" MySaveFormat ) ; reset saveas format
(setvar "FILEDIA" OldFileDia ) ; reset the file dialogbox
(princ) ; silens end
)

: ) Happy Computing !

kennet

Mike.Perry
2004-12-17, 09:41 AM
the way Mike Perry was doing, was to cut from an other application and then paste by hand into AutoCAD, not to import a file programmatically.Hi Kennet

In fairness to myself I was only answering your question, I was not attempting to answer Carlos's.

:beer: Mike

kennet.sjoberg
2004-12-17, 11:17 AM
Mike please no hard feelings, I explained what Carlos was unable to see "I can't view the file that Mike Perry posted"
and also explained how You did it (You did it self too), but I asked for the _insertobj way that Celie Dailey mentioned,
in the workaround You offered, I can still not get it to work in that way.

: ) Happy Computing !

kennet

Mike.Perry
2004-12-17, 11:50 AM
Hi Kennet

I honestly wasn't trying to be negative, no hard feelings :)

I've just followed the instructions given in EX001348 worked for me.

Image file was embedded within drawing file.

For it to work correctly you must have the "Link" Tick Box within the "Insert Object" Dialog Box unchecked (please refer to attached file).

:beer: Mike

kennet.sjoberg
2004-12-17, 01:25 PM
Hi again Mike, if I do like Celie Dailey wrote :

1. Open the drawing file in which you want to Insert a picture (OLE Object).
2. From the Insert menu pick “OLE Object...”

I get the "post stamp" even when [ ] Link is unchecked
= Command: _insertobj


so my problem still remain, but now I think I have an answer

In Your attached file "Insert Object"
I can see that "Microsoft Photo Editor" is associated to Your image
In my case it is empty ( but there is a program associated to the file type )

so there may bee an OLE problems, because I am running a language converted XP.

But if I :
2. From the Insert menu pick “Raster Image...”
I got a embedded image, but no OLE link, thats make me partly happy.

: ) Happy Computing !

kennet