Generate thumbnails from skp file


#1

Hi all, I have a large number of components that I would like to catalog in a spreadsheet. I want the file names in one column with a thumbnail of the component in the next column. Unfortunately, I can’t find an easy way to extract thumbnails in bulk from a folder containing said components. Does anyone know of a way I can accomplish this fairly easily. I have pretty much no experience with Ruby. All of the script I could find would not work or I’m using them incorrectly. Thanks in advance.


#2

Use the following snippet in the Ruby Console.
Start in an empty model or changes might get lost otherwise.
Select the folder of SKPs to process.
All SKPs get thumbnails saved into a PNGS folder…

f=UI.select_directory
if f
  pngs=File.join(f, 'PNGS')
  dir=Dir.mkdir(pngs) unless File.exist?(pngs)
  Dir.glob("#{f}/*.skp").each{|skp|
    s=Sketchup.open_file(skp)
    if s
      p skp
      p png=File.join(pngs, File.basename(skp, ".*")+".png")
      Sketchup.active_model.save_thumbnail(png)
    end
  }
  UI.openURL("file::///#{dir}")
  Sketchup.active_model.close
end

Comparing different versions of drawing
#3

Tig, Thank you so much! This is exactly what I needed!