Setting the Date and Time for a Shadows study
-
I am just starting on Ruby scripting, so there is probably an obvious answer to this...
I need to be able to change the date and time from within a script and can find nothing in the documentation of how to do this.
Any help would be most appreciated -
Welcome!, there lots of us just learning around here right now. Its a great time to learn ruby!
This shows the shadow info for the model.
model = Sketchup.active_model model.shadow_info.to_a.join(', ')
Here is an example of how to adjust the information:
model = Sketchup.active_model shadowinfo = model.shadow_info value = shadowinfo["City"] UI.messagebox value value = shadowinfo["City"]="Denver, CO" UI.messagebox value
And here is a link to the ShadowInfo class in the API:
http://code.google.com/apis/sketchup/docs/ourdoc/shadowinfo.html
the []= method is the one that shows how to set the values in the shadowinfo hash. Hope that helps, keep asking questions,
Chris
-
Welcome Kevin,
The time and date settings, among others, are stored in the ShadowInfo class.
It acts like an attribute array, so you get and set the values by name;
shadow_info = Sketchup.active_model.shadow_info time = shadow_info["ShadowTime"] shadow_info["Longitude"] = 105.2830
F u l l M E R ! (beat me to it.)
-
Just one thing: To know all parameters of a
shadow_info
entity, you can use.keys
Exemple:Sketchup.active_model.shadow_info.keys
will returns
["City", "Country", "Dark", "DayOfYear", "DaylightSavings", "DisplayNorth", "DisplayOnAllFaces", "DisplayOnGroundPlane", "DisplayShadows", "EdgesCastShadows", "Latitude", "Light", "Longitude", "NorthAngle", "ShadowTime", "ShadowTime_time_t", "SunDirection", "SunRise", "SunRise_time_t", "SunSet", "SunSet_time_t", "TZOffset", "UseSunForAllShading"]
If you want to know one of these parameters, just do like that:
Sketchup.active_model.shadow_info["City"]
-
Chris, Mat, Jim
Many thanks - each of your responses added that extra bit to my knowledge. I think I have all I need for the next step of my journey. I am trying to build a virtual sundial correct for any Latitude and Longitude - which may seem a bit of a strange task. But Stetchup has rather a good model of the Earth's movement around the Sun. It correctly distinguishes between solar time - as seen on a sundial - from civil time - as read from your watch. So, with its ability to cast shadows correctly, a sundial simulator should not be too difficult.I'll keep you posted !
Advertisement