• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Problems with ShadowTime/Time conversion

Scheduled Pinned Locked Moved Developers' Forum
7 Posts 5 Posters 10.2k Views 5 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    careca
    last edited by 3 Apr 2009, 07:28

    Hi everybody.

    I just wrote my first (!) few lines in Ruby in order to make Sketchup help me with my Shade Analysis. This script basically creates a series of scenes with different time/date settings.

    It's almost working the way I want to, the only thing I cannot figure out is the ShadowTime-issue and the conversion of the different time formats.

    (My model location is in Japan).

    If anybody is able to have a look at lines 50-54 in the attached file.
    Help would be very much appreciated. 👍

    Best wishes from Tokyo.
    Martin


    shade_analysis_tool.rb

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 3 Apr 2009, 10:17

      It was a bit complex for a first Ruby !!!

      But well done - it was 99% fine... Never be afraid to ask for help - that's what we are here for...

      I've attached a revised script:

      t = Time.local(2009, time_month, time_day, time_start, 0)
      # did not figure hour the time conversion completely, and it is still not working properly
      #new_t = t - (60 * 60 * my_offset)+(60*60*2)
      ###new_t = t - (60 * 60 * my_offset) - (60*60*3)
      new_t = t ### TIG the time IS the time ???***
      new_t = new_t + (60*60) if seasons[sss] == "Summer 6/21" 
      ### this fixes summertime hour discrepency TIG
      ### it makes 5;00 to 21;00 hrs pages for three seasons - several are 'black' as it's night
      ### might be better to have different ranges for each season ?
      for ss in 5...22
        #UI.messagebox ss
        si['ShadowTime'] = new_t
        new_t = new_t + (60*60)
      
        status = pages.add my_view_name.to_s + " - " + seasons[sss]+" - "+ss.to_s+";00"
      end
      

      The bit you had wrong*** was easy fixed - I've also added sometgig to sort out summer daylight saving time glitch that seems to affect the summer - pages and actual times were 1 hour wrong otherwise...

      Keep on scripting...


      shade_analysis_tool.rb

      TIG

      1 Reply Last reply Reply Quote 0
      • C Offline
        careca
        last edited by 6 Apr 2009, 00:40

        Hi TIG.
        Thanks for taking the time to look after my little script.

        Looks like you accidentally for forgot to implement the time zone offset..

        I enhanced the script further by:

        1. including a question in the initial dialog box whether summertime should be included (we do not have summertime in japan...)
        # inpubox
        questions = ["Enter Name", "Summertime"]
        defaults = ["Shadow-Analysis", "no"]
        list = ["", "no|yes"]
        my_view_name_values = UI.inputbox questions, defaults, list, "Please adjust."
        	
        my_view_name = my_view_name_values[0]
        summertime = my_view_name_values[1]
        
        1. manually reset the TZOffset to +9, after the import from GE, it was set to +12...
        si['TZOffset'] = 9
        
        1. include the Time offset & summertime offset
        #include the Time offset
        new_t = t + (my_offset*60*60) ### TIG the time is the time ???
        
        # summertime		
        new_t = t + (60*60) + (my_offset*60*60) if seasons[sss] == "Summer 6/21"  && summetime == "yes"
        

        The only remaining question is why the timezone setting was wrong after importing the location from GE....

        revised script attached.


        shade_analysis_tool.rb

        1 Reply Last reply Reply Quote 0
        • F Offline
          facer
          last edited by 6 Apr 2009, 15:19

          Martin,
          Thank you for the plugin it should evolve into a very useful tool.
          Cheers
          Ray

          A few suggestions:

          1. Could you give Southern Hemisphere users the option of reversing
            your Winter, Summer etc. labels for the months.

          2. An option to print out only the months and dates would assist in
            cross referencing the scenes to town planning regulations.
            For example "Sept 21 - 1500(3pm)" etc.

          3. Could there be a selection for only the times required by the
            authorities. Such as 0900 am, 1200 noon, and 1500 (3pm)

          Notes:
          I have integrated your shadows for set date and times with the SunTool to show the sun views. This results in a useful graphic.

          1 Reply Last reply Reply Quote 0
          • C Offline
            careca
            last edited by 6 Apr 2009, 23:34

            Hi Ray.
            Thanks for your comment.

            When i started to write this script, it was just meant to make my current task easier.
            After some time i noticed this might be useful for other people as well.
            I will try to generalize it as much as possible once I find the time.

            @facer said:

            A few suggestions:

            1. Could you give Southern Hemisphere users the option of reversing
              your Winter, Summer etc. labels for the months.

            2. An option to print out only the months and dates would assist in
              cross referencing the scenes to town planning regulations.
              For example "Sept 21 - 1500(3pm)" etc.

            -> that sounds reasonable.

            @facer said:

            1. Could there be a selection for only the times required by the
              authorities. Such as 0900 am, 1200 noon, and 1500 (3pm)

            -> hmm, either you select certain hours in advance or delete unnecessary scenes afterward.

            Please keep in mind the script is so far only working for Japan, as the offset is preset within the script. This needs to be changed. I also started writing an if-clause that dynamically only creates scenes for between sunrise and sunset hours.

            Best wishes.
            Martin

            1 Reply Last reply Reply Quote 0
            • J Offline
              jdagen
              last edited by 14 Jan 2013, 07:32

              I know this is a fairly old thread, but could someone explain the time zone offset? I get the need for an offset, is it based off of GMT? What constitutes positive and negative?

              1 Reply Last reply Reply Quote 0
              • T Offline
                tab1
                last edited by 9 Aug 2019, 20:44

                Hi Careca,

                Thanks for the extension - looked great - but I'm having trouble with getting it off "summer" in the drop down so it will work with "winter" instead and with a bit different times. Also, how do we output the nice shaded shadows combination, let's say from 9AM thru 4PM on Dec 21, 2019 for our customer? Maybe I've installed it incorrectly? No instructions have shown up either. I'm on a Windows 10 with SU 18.
                Thanks !

                tab1

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement