Newbie switching active models
-
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
endUI.menu("PlugIns").add_item("Create Thumb") {
Dir.glob("C:/models/3ds/*.3ds") do |file|
import_3ds(file)
end
} -
@travis_k said:
model.close_active # this will return false
What are you trying to do with this? Close the model?
That's not what the method does. From the manual: http://code.google.com/apis/sketchup/docs/ourdoc/model.html#close_active@unknownuser said:
The close_active method is used to close the currently active (open) group or component.
How are you doing this batch process?
@travis_k said:
... sketchup will not switch the focus from the first imported model...
What focus? You operating with multiple windows?
-
Ah! I see now how the batch process is.
Still don't understand what you mean by focus though.
Maybe calling
Sketchup.file_new
before each import will work? http://code.google.com/apis/sketchup/docs/ourdoc/sketchup.html#file_new
Advertisement