How do i set ShadowTime ?
-
Hi !
I'm currently working in a research department in a architect-engineer group in Paris, and we regularly need to export shade views of the studied buildings at three specific dates and three specific times for those dates.
I've written this little test code for exporting shade views, but i don't seem to manage changing the shade time....
would like some help if anyone has a hintthanks !
Lydiarequire 'sketchup.rb'
#=============================================================================
def exportShadeView
model = Sketchup.active_model view = model.active_view title = model.title
Sketchup.active_model.shadow_info["ShadowTime"]="Thu Mar 21 14:00:00 Paris, Madrid 2002"
if (value)
UI.messagebox value
else
UI.messagebox "Failure"
endfilename = title + "_21mars_10h.jpg" status = view.write_image filename, 5000, 4000
if (status)
UI.messagebox status
else
UI.messagebox "Failure"
endend
#=============================================================================
#=============================================================================Add a menu to export shade views
if( not $shadeview_loaded )
shadeview_menu = UI.menu("File")
shadeview_menu.add_item("Shadow Export") { exportShadeView }
$shadeview_loaded = true
end -
Hi Lydia,
First, open the Ruby Console when writing scripts so you are able to view any error messages that are generated.
You are trying to set the time by assigning a String. ShadowInfo["ShadowTime"] expects to be set to a Time object. Try:
Sketchup.active_model.shadow_info["ShadowTime"] = Time.now
or
t = Time.local(2008, 3, 21, 14) Sketchup.active_model.shadow_info["ShadowTime"] = t
Also, the variable "value" is never defined in your example, and will cause an error.
-
Hi Jim,
Thanks loads for your tip!!
I'll go try it out straight awayI'll be back...
Advertisement