# Copyright 2006, TIG # Permission to use, copy, modify, and distribute this software for # any purpose and without fee is hereby granted, provided the above # copyright notice appear in all copies. # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #----------------------------------------------------------------------- # Name : Elev45shadows.rb # Description : Adds 45 degree top-left shadows to elevations etc. # Menu Item : View -> Elevation 45 Shadows # Context Menu: Not available # Author : TIG # Usage : Set up your elevation-view page(s). Tip - Select an # elevation face and right-click and pick Align View to # get a non-orthogonal [non-F/B/L/R] elevation. # Then select this tool from the menu and it will # automatically work out camera view direction and add # shadows as if the sun is from the top-left of the view # at 45 degrees in elevation or in plan... # Note aligning views to 3D sloping faces will have # unexpected affects. # It will realign North in each altered view so IF North # is important in other shadow studies ensure that pages # are kept separate. # Shadow setting changes are NOT Undo-able... # To toggle shadows to 'top-right' for that session open # the Ruby Console, and type or copy-paste the following # and press enter = $e45s=0 # to turn back it's = $e45s=1 or just restart SketchUp. # # Date : 18/02/2006 # Type : Tool # Version : 1.0 18/02/06 First issue. # 1.1 19/02/06 Ruby console puts removed. # 1.2 20/02/06 Time zone now auto-changes to GMT and # city/country = "...45...". # $e45s=1 / 0 = left / right toggle added.. # 1.3 09/10/08 Minor adjustments to get near 45 as possible. #----------------------------------------------------------------------- require 'sketchup.rb' ### def elev45shadows ### model= Sketchup.active_model shadowinfo= model.shadow_info view= model.active_view direction= view.camera.direction $e45s= 1 if not $e45s ###at startup x= direction.x y= direction.y z= direction.z a= Math.atan2(y,x) a= a.abs*57.295779513082320900 ### into abs degrees if y == 0 if x > 0 ###looking east (axis) angle= 90+45 end if x < 0 ###looking west angle= 270+45 end end if y > 0 angle= 0+45 if x == 0 ###looking north if x > 0 ### ne quadrant angle= 90-a+45### end if x < 0 ### nw quadrant angle= 180-a-90+45### end end if y < 0 angle= 180+45 if x == 0 ###looking south if x > 0.0 ### se quadrants angle= a+180-45### end if x < 0 ### sw quadrant angle= a+90+45### end end angle=angle-90 if $e45s == 0 ### angle= 90+45 if z != 0 and (x==0 and y==0) ###plan ### shadowinfo["Country"]= "Elevation 45 shadows" ### shadowinfo["City"]= "Elevation 45 shadows" ### shadowinfo["TZoffset"]= 0 ### shadowinfo["DisplayShadows"]= true shadowinfo["Latitude"]= 55.1800 ### why ??? but it works !!! shadowinfo["Longitude"]= 0.1000 ### why ??? but it works !!! shadowinfo["NorthAngle"]= angle shadowinfo["ShadowTime"]= Time.gm(2000,"mar",21,12,06,50) ### why ??? but it works !!! ### end#def ########################### #--------- menu ----------------------------- if( not file_loaded?("Elev45shadows.rb") ) UI.menu("View").add_separator UI.menu("View").add_item("Elevation 45 Shadows") {elev45shadows} end#if file_loaded("Elev45shadows.rb") #---------------------------------