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

    How do i set ShadowTime ?

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 537 Views 2 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.
    • H Offline
      hazyscl
      last edited by

      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 hint 😉

      thanks !
      Lydia

      require '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"
      end

      filename = title + "_21mars_10h.jpg"
      status = view.write_image filename, 5000, 4000
      

      if (status)
      UI.messagebox status
      else
      UI.messagebox "Failure"
      end

      end

      #=============================================================================
      #=============================================================================

      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

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H Offline
          hazyscl
          last edited by

          Hi Jim,

          Thanks loads for your tip!! 👍
          I'll go try it out straight away 😛

          I'll be back... 🎉

          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