I am trying to create a set of thumbnails (600px x 600px) for several thousand .3ds files by importing each file then write a image. I can create a thumb for a single .3ds file without any difficulties. However when I try to batch the process sketchup will not switch the focus from the first imported model and all resulting thumbnails are identical to the first image / model.
Any help would be much appreciated!
#######################################
require 'sketchup'
Sketchup.send_action "showRubyPanel:"
def import_3ds(file)
model = Sketchup.active_model
model.import file, false
m_def = model.definitions
location = Geom::Point3d.new 0,0,0
entities = Sketchup.active_model.active_entities
instance = entities.add_instance m_def[0], location
thumb = file.gsub "3ds", "jpg"
view = model.active_view.zoom_extents
view.write_image thumb, 600, 600, true
entities.erase_entities entities[0]
model.close_active # this will return false
end
UI.menu("PlugIns").add_item("Create Thumb") {
Dir.glob("C:/models/3ds/*.3ds") do |file|
import_3ds(file)
end
}