SunAndShadowSettings Class


The SunAndShadowSettings class represents the sun control.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 17.0.0.0 (17.0.1090.0)
Since: 2011

Syntax

C#
public class SunAndShadowSettings : Element
Visual Basic
Public Class SunAndShadowSettings _
	Inherits Element
Visual C++
public ref class SunAndShadowSettings : public Element

Remarks

The SunAndShadowSettings element represents the settings applied to a project or view regarding the position, dates, time intervals and other options for the sun control and solar studies. To differentiate between the project and view settings, test the ViewSpecific or OwnerViewId property. If the element is not view-specific this element represents a project-wide setting. If the element is associated to a view, this element represents a per view SunAndShadowSettings. When you create a new view, a new view-specific SunAndShadowSettings element is automatically created for it.

Examples

Copy C#
SunAndShadowSettings sunSettings = view.SunAndShadowSettings; // get current settings from view

// modify Sun and Shadow Settings
DateTime sunrise = sunSettings.GetSunrise(DateTime.SpecifyKind(new DateTime(2011, 4, 20), DateTimeKind.Local)); // sunrise on April 20, 2011
DateTime sunset = sunSettings.GetSunset(DateTime.SpecifyKind(new DateTime(2011, 4, 22), DateTimeKind.Local)); // sunset on April 22, 2011
sunSettings.SunAndShadowType = SunAndShadowType.MultiDayStudy;
sunSettings.StartDateAndTime = sunrise.AddHours(2); // start 2 hours after sunrise on April 20, 2011
sunSettings.EndDateAndTime = sunset.AddHours(-2); // end 2 hours before sunset on April 22, 2011
if (sunSettings.IsTimeIntervalValid(SunStudyTimeInterval.Hour)) // check that this interval is valid for this SunAndShadowType
    sunSettings.TimeInterval = SunStudyTimeInterval.Hour;

// check for validity of start and end times
if (!(sunSettings.IsAfterStartDateAndTime(sunSettings.EndDateAndTime)
    && sunSettings.IsBeforeEndDateAndTime(sunSettings.StartDateAndTime)))
    TaskDialog.Show("Error", "Start and End dates are invalid");

view.get_Parameter(BuiltInParameter.VIEW_GRAPH_SUN_PATH).Set(1); // turn on display of the sun path
Copy VB.NET
Dim sunSettings__1 As SunAndShadowSettings = view.SunAndShadowSettings
' get current settings from view
' modify Sun and Shadow Settings
Dim sunrise As DateTime = sunSettings__1.GetSunrise(DateTime.SpecifyKind(New DateTime(2011, 4, 20), DateTimeKind.Local))
' sunrise on April 20, 2011
Dim sunset As DateTime = sunSettings__1.GetSunset(DateTime.SpecifyKind(New DateTime(2011, 4, 22), DateTimeKind.Local))
' sunset on April 22, 2011
sunSettings__1.SunAndShadowType = SunAndShadowType.MultiDayStudy
sunSettings__1.StartDateAndTime = sunrise.AddHours(2)
' start 2 hours after sunrise on April 20, 2011
sunSettings__1.EndDateAndTime = sunset.AddHours(-2)
' end 2 hours before sunset on April 22, 2011
If sunSettings__1.IsTimeIntervalValid(SunStudyTimeInterval.Hour) Then
    ' check that this interval is valid for this SunAndShadowType
    sunSettings__1.TimeInterval = SunStudyTimeInterval.Hour
End If

' check for validity of start and end times
If Not (sunSettings__1.IsAfterStartDateAndTime(sunSettings__1.EndDateAndTime) AndAlso sunSettings__1.IsBeforeEndDateAndTime(sunSettings__1.StartDateAndTime)) Then
    TaskDialog.Show("Error", "Start and End dates are invalid")
End If

view.Parameter(BuiltInParameter.VIEW_GRAPH_SUN_PATH).[Set](1)
' turn on display of the sun path

Inheritance Hierarchy

System Object
Autodesk.Revit.DB Element
Autodesk.Revit.DB SunAndShadowSettings

See Also