Hi, every body.
I have been trying to produce shadow of an entity with Ruby API.
But, I noticed that sunrise time got with Ruby script is a little different from Sketchup application.
For example, with the same sketchup entity, I got sunrise is 6:59 in the interface of Sketchup application and 7:00 by script based Ruby API.
Would somebody do me a favor?
The follows are the code:
#get model representing the Sketchup file
model = Sketchup.active_model
#get view the user are facing
view = model.active_view
#get shadow information
#City of the model
puts "My city is: " + shadow[“City”].to_s
#first day to produce images is initialized with 5th Apr 2016 as a sample
firstDay = Date.new(2016,4,5)
#last day to produce images is initialized with 15th Apr 2016 as a sample
lastDay = Date.new(2016,4,15)
#get the timeZone(measured by second) to eliminate the effect by the local time
timeZoneOffsetInSecond = firstDay.to_time.utc_offset
#this showTime is just to calculate the time of sunrise instead of producing the shadow image
#this time is adjusted by the time zone（timeZoneOffsetInSecond）
shadowTimeForSunrise = Time.new(currentDay.year,currentDay.month,currentDay.day,0,0,0)
#set the shadow time
shadow[“ShadowTime”] = shadowTimeForSunrise
#get the sun rise time
sunRise = shadow[‘SunRise’] - timeZoneOffsetInSecond
#get the sun set time
sunSet = shadow[‘SunSet’] - timeZoneOffsetInSecond
sunRiseHour = sunRise.hour
sunRiseMin = sunRise.min
sunSetHour = sunSet.hour
sunSetMin = sunSet.min