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_newbefore each import will work? http://code.google.com/apis/sketchup/docs/ourdoc/sketchup.html#file_new
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement