sketchucation logo sketchucation
    • Login
    ⌛ Sale Ending | 30% Off Profile Builder 4 ends 30th September

    Seasonal animations

    Scheduled Pinned Locked Moved Plugins
    20 Posts 3 Posters 2.7k Views 3 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.
    • Chris FullmerC Offline
      Chris Fullmer
      last edited by

      yeah, the script is fairly simple. It sets the current date to Jan 1st at midnight, 2010. Then it turns on shadows, then it runs through a loop 365 times. The loop makes a page, then addes 12 hours to the current time, then adds another page, then the loop starts over.

      So you can easily change the start date. The line t = Time.gm(2010,"jan",1,0,0,0).to_i you can adjust "jan" to "feb" and 1,0,0,0 is the date (1) and 0,0,0 is the hours, minutes and seconds. And instead of running 365 times, it should only run like 150 times, or however many days you want it to cover.

      I fininshed a few minutes of the video (EDIT: the video which is now posted above) and it is really pretty boring. Well, it just doesn't clearly show anything. I think it might be more interesting if it did like you suggested and started and ended at specific times. Or it might be interesting to just show noon every day of the year, so you can see how the shadows dance around.

      I have dreams of doing this work with a real camera some day. I get pretty excited about it.

      Chris

      Lately you've been tan, suspicious for the winter.
      All my Plugins I've written

      1 Reply Last reply Reply Quote 0
      • D Offline
        danbig
        last edited by

        Hmmm.

        I didn't export any video, but I did watch some of the animation from within SketchUp. It really has potential to do exactly what I'm looking for, which is to allow the viewer to tell if the shadow from a specific object will shade another object at any time during the year.

        I did reduce the scene time to .125 seconds, which compressed a whole year into 1.5 minutes of animation. For shorter durations, I think longer scene times would be cool too.

        So, going off of your description of how to modify the code block: Say I want to set it to create scenes for the month of August, and I want the first scene of the day to be at 7am, and the last scene of the day to be at 1pm. Is this the correct code? (all other code as you posted above)

        t = Time.gm(2010,"aug",1,7,0,0).to_i; 31.times
        

        I don't see where the script would tell the second scene to be at 1pm, so I'm thinking this would create one scene at 7am, and the next scene exactly 24 hours later?

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          model = Sketchup.active_model;si = model.shadow_info;ps = model.pages;si["DisplayShadows"]= true;t = Time.gm(2010,"jan",1,12,0,0).to_i;365.times { |day| si["ShadowTime_time_t"]=t;ps.add;t= t+(60 * 60 * 24);}
          

          This code will make 1 scene at noon, every day of the year. Then set up your animation so it exports 1 frame per scene. You get a great animation of the shadows moving around. I'm rendering it right now, but I can already see from the exported images that its coming out nicely. The video below is a product of the code snippet in this post.

          [flash=853,505:495gh9fp]http://www.youtube.com/v/8RfK_LuwZVg&hl=en_US&fs=1&rel=0[/flash:495gh9fp]

          Chris

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            t= t+(60 * 60 * 24)
            That line is what adds 24 hours to the current day. So first set it to the day you want, then add time to that day. There are plenty of other ways to do it, but that is how I've done it.

            Are you using a multi-line editor by chance? Like Jim's web console or Alex's Ruby Console upgrade? I'll start writing the code in an easier to read manner if you have one of those installed.

            Chris

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

            1 Reply Last reply Reply Quote 0
            • D Offline
              danbig
              last edited by

              I do have Jim's Web console installed. Is Alex's console better?

              So, here's my stab at creating a scene for every day in August, from 10am to 4pm:

                  model = Sketchup.active_model;si = model.shadow_info;ps = model.pages;si["DisplayShadows"]= true;t = Time.gm(2010,"aug",1,10,0,0).to_i;31.times { |day| si["ShadowTime_time_t"]=t;ps.add;t= t+(60 * 60 * 6);}
              

              When I ran this script, I ended up with 4 scenes per day. (4am, 10am, 4pm, 10pm)(the very first day had only three scenes, as it didn't create a 4am scene)

              Maybe I should modify the first version of the sript? (trying now)

              1 Reply Last reply Reply Quote 0
              • D Offline
                danbig
                last edited by

                This code accomplishes what I described above.

                model = Sketchup.active_model; si = model.shadow_info; ps = model.pages; si["DisplayShadows"]= true; t = Time.gm(2010,"aug",1,10,0,0).to_i; 31.times { |day| si["ShadowTime_time_t"]=t; ps.add; t = t + (60 * 60 * 6);si["ShadowTime_time_t"]=t; ps.add; t = t + (60 * 60 * 18);}
                

                For the month of August, it creates two scenes per day. The first is at 10am, and the second is at 4pm.

                This line works as you described above: it sets the time to August, starting at 10am, and sets it to repeat 31x.

                (2010,"aug",1,10,0,0).to_i; 31.times
                

                The first time this line appears, the "6" is the time after first scene that I want to create the second scene. (10am + 6hrs = 4pm)

                t + (60 * 60 * 6)
                

                The second time this line appears, the "18" is the time after the second scene until the first scene the next day (4pm + 18hrs = 10am the following day).

                t = t + (60 * 60 * 18)
                

                Now onto displaying the current month/day onscreen for each scene....

                By the way, are you using the export to AVI function to create your animation, or some other method? It sounded like above you were exporting an image for each scene, which you would then compile into a video. This would be very cool, but you would lose the transition effect that sketchup performs between scenes, right?

                1 Reply Last reply Reply Quote 0
                • Chris FullmerC Offline
                  Chris Fullmer
                  last edited by

                  EDIT: ok, you already figured-out most of what I explain below.

                  model = Sketchup.active_model
                  si = model.shadow_info
                  ps = model.pages
                  si["DisplayShadows"]= true
                  t = Time.gm(2010,"aug",1,10,0,0).to_i
                  
                  
                  31.times do |day| 
                  	si["ShadowTime_time_t"]=t
                  	ps.add
                  	t= t+(60 * 60 * 6)
                  end
                  

                  Since you have a multi line editor, you should be looking at this in regular notation I think, instead of condensing it all onto a single line. So this (above) is your code from your previous post. It sets the time to 10:am on the first day. Then begins the loop 31 times. Its adds the first scene - at 10:00. THen adds 6 hours to the current time and repeats the loop. Add 6 hours, add a scene, add 6 hours, add a scene.

                  You are close, but you are missing 2 things. First, you want to add hours to get to 4:00pm, then you need to 18 hours to get back to 10:00 the next day.

                  Also, you don't want the animation to animate between the 4pm and 10am scene. So you will need to set that scene to not have a transition time. In Ruby, you can set scenes to use the default transition time specified in the model tab. OR, you can set a scene to have its own transition time that overides the default. You're going to need to do that to set the transition to zero so you get a full animation of shadows during the day, then no transition, just skip right into the next day. This is the code that does what you are looking for (I think). Try it out.

                  model = Sketchup.active_model
                  si = model.shadow_info
                  ps = model.pages
                  si["DisplayShadows"]= true
                  t = Time.gm(2010,"aug",1,10,0,0).to_i
                  
                  
                  31.times do |day| 
                  	si["ShadowTime_time_t"]=t
                  	page = ps.add
                  	page.transition_time = 0.0
                  	t= t+(60 * 60 * 6)
                  	si["ShadowTime_time_t"]=t
                  	page = ps.add
                  	page.transition_time = -1
                  	t= t+(60 * 60 * 18)
                  end
                  

                  And check out my youtube videos channel (in my signature link) and I've got 2 videos uploaded or uploading there. The good one is the one that does noon at every day throughout the year. It came out looking great.

                  Chris

                  Lately you've been tan, suspicious for the winter.
                  All my Plugins I've written

                  1 Reply Last reply Reply Quote 0
                  • Chris FullmerC Offline
                    Chris Fullmer
                    last edited by

                    Hey Dan, ok I posted the videos above. They came out as I said before - the first one is rather difficult to watch (boring) and does not show much anything interesting. The second one is cool though. I am also hoping to post a video of the recent code snippet I posted where it just shows the hours of the day for a month. Maybe I'll get that done tonight still.

                    For video export, I export to jpegs for pngs. SU will export each frame as a separate image. Not each scene, but actually each frame. So if you set it to export 20 frames per second, and have 2 seconds for each scene transition, then it will export 40 jpegs per scene. That is how I always export my movies from SU for quality reasons. I then turn that image sequence into a single movie using quicktime Pro, but there are free softwares that also do it.

                    Chris

                    Lately you've been tan, suspicious for the winter.
                    All my Plugins I've written

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      danbig
                      last edited by

                      Hi Chris -

                      The videos both look great. I agree that the second approach, with only one time stamp per day, makes for a more interesting animation.

                      Do you know if it's possible to show shadows for more than one time at the same time?

                      I added

                      status = page.use_camera=false
                      

                      in two places below. As I'm sure you know, this makes it so that the scenes do not save the camera position from when the script was run.

                      model = Sketchup.active_model
                      si = model.shadow_info
                      ps = model.pages
                      si["DisplayShadows"]= true
                      #set the year, month, day, and time of first shading scene
                      t = Time.gm(2010,"aug",1,10,0,0).to_i
                      
                      
                      #set number of days to repeat
                      31.times do |day|
                      si["ShadowTime_time_t"]=t
                      page = ps.add
                      status = page.use_camera=false
                      page.transition_time = 0.0
                      t= t+(60 * 60 * 6)
                      si["ShadowTime_time_t"]=t
                      page = ps.add
                      status = page.use_camera=false
                      page.transition_time = -1
                      t= t+(60 * 60 * 18)
                      end
                      
                      

                      I've moved onto trying to add screen text, which notes the month and day of the current shadow displayed. I'm thinking this will be more involved than turning off the camera location save. Any ideas, anyone? The end result would be in the finished animation, there would be a time stamp of sorts on the screen as the animation plays back.

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        danbig
                        last edited by

                        Ok, so turning the camera location off in the first script worked fine.

                        When I tried to insert the extra line into the one time stamp per day version, this is what happened:

                        (eval):9:in ‘initialize’: undefined method ‘use_camera=’ for #Sketchup::Pages:0x16f5d910

                        Here's how I put the status line into the code:

                        model = Sketchup.active_model
                        si = model.shadow_info
                        ps = model.pages
                        si["DisplayShadows"]= true
                        t = Time.gm(2010,"jan",1,12,0,0).to_i
                        
                        365.times { |day| si["ShadowTime_time_t"]=t
                        ps.add
                        status = ps.use_camera = false
                        t= t+(60 * 60 * 24);}
                        
                        
                        1 Reply Last reply Reply Quote 0
                        • Chris FullmerC Offline
                          Chris Fullmer
                          last edited by

                          NOTE: in the rext of the post I use the word "page" a lot. It is interchangeable with "scene".

                          The variable ps is pointing to the entire collection of pages - not just a single page. The use_camera= method works on a single page, not a pages collection. So when you make the page with page.add, you need to make a variable that points to that single new page. Then tell that page to not use the camera. Change these two lines:

                          ps.add status = ps.use_camera = false

                          to this:

                          page = ps.add status = page.use_camera = false

                          Now when the page is being added to the pages collection, you have the variable page that points directly to that new page. Then you tell that page to not use the camera.

                          Also, good luck with the time stamp thing. I think the only way to do that is with separate layers FOR EACH DATE you plan to insert. I would guess that you will want to make all the layers first. Then make all the text, and put it on the correct layer as you make it. Then when you make the pages, turn off all the layers for the dates you do not want on. That is the only way I can think to do it.

                          And lastly, for the dual shadows. There is no way to do that through SketchUp and the API. But it is possible to combine images if you export the animation as frames. You could overlay the dual animations on top of eachother using a batch process in photoshop, or automate it with a free software called imagemagic. Once you get the process down, it is not that hard to do. and if you really had to do this often, could script then entire process so that none of it was manual.

                          Chris

                          Lately you've been tan, suspicious for the winter.
                          All my Plugins I've written

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            danbig
                            last edited by

                            Hmm.

                            Thanks for the tips on the script, and the thoughts on the time stamp. I'm off to read the SketchUp Ruby API.

                            Best,
                            Dan

                            1 Reply Last reply Reply Quote 0
                            • DavidBoulderD Offline
                              DavidBoulder
                              last edited by

                              I haven't looked through this entire post, but I like the idea of picking 10-12 days throughout the year for the simulation, or running the simulation for every day of year but first for 8am, then 9am, 10am, etc. So not as jumpy as going through the year chronologically.

                              Not quite the same, but I had also setup a LayOut project that had pages for the solstices and equinoxes, at 9am, noon, and 3pm. It had a plan and and elevation view on each page. I was using this to study shading devices,so my my elevation was zoomed in on a window.

                              As long as I was careful how I named my scenes, I could drop swap out my SketchUp fle in my Layout project, and get a quick shadow studies for any project.

                              --

                              David Goldwasser
                              OpenStudio Developer
                              National Renewable Energy Laboratory

                              1 Reply Last reply Reply Quote 0
                              • Chris FullmerC Offline
                                Chris Fullmer
                                last edited by

                                @davidboulder said:

                                I haven't looked through this entire post.

                                Good, don't waste your time 😄 Just watch the videos and if there is one you like, then use code associated to that video. Much of the thread was me rambling on and on.

                                @davidboulder said:

                                As long as I was careful how I named my scenes, I could drop swap out my SketchUp fle in my Layout project, and get a quick shadow studies for any project.

                                I think that is an neat idea too.

                                I find myself drawn to video and animation for this type of study personally, but whatever works for what you need it for.

                                I would like to develop a full script that layers multiple shadow times on top of eachother and colors them differently - maybe blue red and orange or something for morning noon and afternoon, for each day of the year. I think that is potentially a useful script.

                                Bytheway, Al at renderplus has a script that will layer shadows on top of each other and output them as a single image. I think it is part of his NPR (non-photo-real) toolkit. I'm not sure if it costs or is free. But he developed that after we had some discussions along this line, about how to layer shadows. It is workth looking at.

                                Chris

                                Lately you've been tan, suspicious for the winter.
                                All my Plugins I've written

                                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