Does anyone know how to convert a Solidworks Drawing in to a .gif format.

In order to link an image of a drawing to a part number in our part management system (Epicor), that image needs to be in a .gif format.

To do this, we have been printing out drawings, and then scanning them.  I would like to eliminate the printing and scanning steps.

Recently we discovered saving a drawing file as a .jpeg, opening the .jpeg in paint, then saving the file as a .gif.  However, some image quality is lost in the process.

We also have to figure out image size.

Does anyone have any suggestions about how to do this better?

SolidworksGeneral
Answers 7
IM
IM 2015-06-24 Best Answer

In cases like this, I save it as .pdf and save it as image from the  pdf. File. In options when saving as image you can control the quality. In solidworks you can also control the quality when saving as image file when you have selected the image type, when you select the option button.

JS
JS 2015-06-24

Change your DPI when saving as a jpeg, set it as high as you can then you should be able to get better quality, can you use tif?? 

comment imagecomment image
DG
DG 2015-06-24

You can try saving as PNG or TIFF and then editing/opening that in paint and save as GIF.

JS
JS 2015-06-24

We have also used an .ai file

For our catalog we tried a few different ways and ai was the best - jpeg is good on it's own, however the graphics people couldn't use those images, however they made it work with .ai files .

The issues with the jpeg or tif files was the circles being badly pixelated

comment imagecomment imagecomment imagecomment image
JS
JS 2015-06-24

A macro to do this is fairly simple.  Windows already has built in functions to convert between image types.

First make a new VSTA C# Macro and paste this into the Main() method:

<p>ModelDoc2 mDoc = swApp.ActiveDoc as ModelDoc2;</p><p>ModelDocExtension mExt = mDoc.Extension;</p><p>if (mDoc.GetType() != (int)swDocumentTypes_e.swDocDRAWING)</p><p>{</p><p>    MessageBox.Show("This macro works with drawing files only");</p><p>    return;</p><p>}</p><p>try</p><p>{</p><p>    string tempFilePath = Path.GetTempFileName();</p><p>    string tifPath = tempFilePath.Replace(".tmp", ".tif");</p><p>    File.Move(tempFilePath, tifPath);</p><p>    int errors = 0;</p><p>    int warnings = 0;</p><p>    mExt.SaveAs(tifPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, 0, null, ref errors, ref warnings);</p><p>    if (errors != 0 || warnings != 0)</p><p>    {</p><p>        MessageBox.Show("Errors: " + errors + " Warnings: " + warnings);</p><p>    }</p><p>    System.Drawing.Image jpegImage = System.Drawing.Image.FromFile(tifPath);</p><p>    string drawingName = Path.GetFileNameWithoutExtension(mDoc.GetPathName());</p><p>    string gifFileName = Path.GetDirectoryName(mDoc.GetPathName()) + Path.DirectorySeparatorChar + drawingName + ".gif";</p><p>    jpegImage.Save(gifFileName, System.Drawing.Imaging.ImageFormat.Gif);</p><p>    jpegImage.Dispose();</p><p>    File.Delete(tifPath);</p><p>}</p><p>catch (Exception e)</p><p>{</p><p>    MessageBox.Show("Fatal error: " + e.Message);</p><p>}</p>

Also add the following at the top with the other 'using' statements:

<p>using System.Windows.Forms;</p><p>using System.Drawing;</p><p>using System.IO;</p>

Last, in the pane on the left, right click on References and then click 'Add Reference'.  In the dialog that is shown, scroll down and select 'System.Drawing' and then click OK.

Open a drawing and run the macro.  It will create a temp file and then saves the drawing to the temp file as a TIF image.  Next it loads the TIF and converts it to a GIF saving it to the same directory where the original drawing is located.  Lastly it cleans up by deleting the temp file.

For the various image file types the SW Save As doesn't give you any option for selecting sheets, so you will always get an image of the sheet displayed on the screen.  If you have a multisheet drawing, you will need to rename the GIFs before running the macro for subsequent sheets.

This is example code only.  Use at your own risk.

Jim S.

KC
KC 2015-06-24

Hello,

Have you tried printing to a gif?

I Googled "print to gif" and one of the hits was:

Print to GIF. Print to GIF any your Documents.

I haven't tried it, but the old school method of printing to other file formats might work out for you.

I hope this helps.

Cheers,

Kevin

MS
MS 2015-06-25

Thanks for your input, everyone.  This gives me good directions to go.  I'll look into these things.