Automating export of scenes
-
-
Thanks again TIG. I will try it out tomorrow as it's time for dinner hereabouts. Did you have a look at the post links? I would be interested to have your opinion on whether the ruby part is possible.
Cheers
Chris
-
Try something like this...
def scenes2images() model=Sketchup.active_model view=model.active_view width=view.vpwidth.to_int height=view.vpheight.to_int ### you can change the width/height away from the default if you desire pages=model.pages pages_times=[] pages.each{|page|pages_times.push([page,page.transition_time]) page.transition_time=0.0 } ### remembers pages' transition times and sets them all to 0 filepath=File.dirname(model.path)+"\\" ### assumes model is saved 0.upto(pages.count-1)do|images| ### this msgbox pauses and lets each view refresh and the image process... UI.messagebox("Exporting Image of Scene...") model.active_view.write_image("#{filepath+pages.selected_page.name}.jpg",width,height,true) Sketchup.send_action("pageNext;") end#loop ### reset pages' transition times pages_times.each{|array|array[0].transition_time=array[1]} UI.messagebox("Scenes' Image Exporting - Completed.") end#def
save as scenes2images.rb and scenes2images in the ruby console to run it...
-
Thanks again TIG. Here's your code that I have altered a bit (in black) to be later made into a callback. Hope that's OK with you.
My regards
Chris
` def scenes2images()
%(#000000)[# variables from js in webdialog
subdir = "E:/Chiang Mai/Scenes jpg/"
w = 800]model=Sketchup.active_model view=model.active_view width=view.vpwidth.to_int height=view.vpheight.to_int %(#000000)[width = w height = w/width*height]
you can change the width/height away from the default if you desire
pages=model.pages pages_times=[] pages.each{|page|pages_times.push([page,page.transition_time]) page.transition_time=0.0 }
remembers pages' transition times and sets them all to 0
filepath=File.dirname(model.path)+"\" ### assumes model is saved
## changed to subdir variable - see above
0.upto(pages.count-1)do|images|
%(#000000)[# using 2 just for testing
0.upto(2)do|images|]
model.active_view.write_image("#{subdir+pages.selected_page.name}.jpg",width,height,true)
Sketchup.send_action("pageNext:")%(#000000)[UI.messagebox("Exported "+pages.selected_page.name)]
this msgbox pauses and lets each view refresh and the image process...
%(#000000)[## changed position to get correct scene name
considering change to question with OK/Skip/Cancel + new position]
end#loop
reset pages' transition times
pages_times.each{|array|array[0].transition_time=array[1]}
UI.messagebox("Scene Image Exporting - Completed.")
end#def` -
SceneExporter and SceneExporterPro will do this as well.
-
@rickw said:
SceneExporter and SceneExporterPro will do this as well.
Very thoughtful and generous, thanks.
You may be interested in seeing how this relates to my templates query
Chris
Advertisement