I enjoyed some wonderful hot sunny days since I returned from New England back to Switzerland.
Summer finally arrived. A nice change after the rain and cold both here and in New Hampshire and Massachusetts.
Talking about rain and sun leads up nicely to today's topic, on the sun direction and shadow calculation in a Revit BIM.
Before I get to that, though, I present an update of my Revit add-in wizards resulting in part from yesterday's post on the processor architecture mismatch warning:
I implemented updates of my Visual Studio wizards to generate new C# and VB Revit 2014 add-ins yesterday, for two reasons:
To install, simply copy the zip file of your choice to the matching Visual Studio project template folder in your local file system:
For all further details on this, links back to previous versions, other flavours, and tips on how to adapt the wizards for your own use, please refer to the initial 2014 version.
Determining the shaded areas in a model is obviously important for many areas of analysis.
Assuming certain objects in the BIM cast a shade over others, is there a way to programmatically determine the shadowed areas?
In fact, the Revit API provides a dedicated ExtrusionAnalyzer class for this very kind of calculation, which I made use of to determine the plan view furniture and equipment boundary loops for my 2D cloud-based editor workflow.
Is there a way to mark these areas in the model?
That sounds rather complicated. You might be able to use Boolean operations for 2D polygons and paint the shaded areas.
This leads to the following
Question: I found code snippet showing how to use the ExtrusionAnalyzer class to calculate shadows in the material provided for the Autodesk University class on Geometric Progression: Further Analysis of Geometry using Autodesk Revit 2012 API.
To make use of it, I also need to determine the sun direction using the Revit API. It obviously differs based on time of the day, location, etc.
How can I obtain the sun direction for any given project location, date and time, please?
Answer: The sun direction is available from the Sun and Shadows element. Of course, it always represents a single point in time (date, time) and not the complete range of possible sun directions. The sample takes this into account and recalculates shadows when the sun is moved to another date and time location via the user interface.
Here is the code to determine the sun direction from the sun and shadows settings:
public class ShadowCalculatorUtils { public static XYZ GetSunDirection( View view ) { SunAndShadowSettings sunSettings = view.SunAndShadowSettings; XYZ initialDirection = XYZ.BasisY; //double altitude = sunSettings.Altitude; double altitude = sunSettings.GetFrameAltitude( sunSettings.ActiveFrame ); Transform altitudeRotation = Transform .CreateRotation( XYZ.BasisX, altitude ); XYZ altitudeDirection = altitudeRotation .OfVector( initialDirection ); //double azimuth = sunSettings.Azimuth; double azimuth = sunSettings.GetFrameAzimuth( sunSettings.ActiveFrame ); double actualAzimuth = 2 * Math.PI - azimuth; Transform azimuthRotation = Transform .CreateRotation( XYZ.BasisZ, actualAzimuth ); XYZ sunDirection = azimuthRotation.OfVector( altitudeDirection ); return sunDirection; } }