Automatic CAD Thumbnails

OK, to work a CNC you need G-Code, to get G-Code you usually need a CAD (Computer Aided Design) program. Since I'm a Windows kind of guy, and well, a cheap kind of guy, I go for the very capable and free CAD program Inkscape.  One of the cool things I found out about Inkscape is it's ability to take a command line argument to output a PNG file.  What's so cool about that?  Well, if you have a bunch of drawings it can be a pain to load and save each as a PNG file just so you can have a thumbnail visible in Windows Explorer. So let's automate making thumbnails viewable from Windows Explorer (PNG files) from a bunch of SVG files (the format Inkscape saves in).

STEP 1: Make the BAT File
Copy the following text into a text editor, like notepad.  Save the text as InkscapeSVG2PNG.BAT.

SET INKSCAPE="C:\Program Files (x86)\Inkscape\inkscape.exe"


%INKSCAPE% -f %1 -e "%1.png" -w 128; done

ECHO Processing directory...
cd %1
for /R %1 %%i in (*.svg) do (ECHO %%i & %INKSCAPE% -f "%%i" -e "%%i.png" -w 128; done)


NOTE: You may have to edit the SET INKSCAPE line to reflect the path Inkscape is installed in.

STEP 2:Make the BAT File Easily Used (no command line junk)
One of my favorite things in Windows is the "Send To" folder, it makes it easy to use complicated scripts by just right clicking on files or directories and Sending To the script for processing. Depending on the version of Windows you are using, the Send To directory may be in different places;

Windows 2000, Windows XP
C:\Documents and Settings\<username>\SendTo

Windows Vista, Windows 7

Once you locate this directory (must be done for each user), simply create a shortcut to the InkscapeSVG2PNG.BAT file by right-clicking in the directory and selecting "New/Shortcut".

STEP 3: Use It!
You can now simply right-click on any file or directory, select "Send To/InkscapeSVG2PNG".

Viola! now you can easily scan through your files without having to open each SVG to see whats in it.

No comments:

Post a Comment