Default Lighting and Sun objects

In AutoCAD, default lights are activated in a drawing when no user-defined lights are present and when the sun object is turned off. When adding light entities to a drawing, you need to call the setDefaultLightingOn() member function of the viewport to turn off default lighting and enable your lights. If DEFAULTLIGHTING is set to 0, default lights are automatically switched off when a user defined light is added to the drawing. The viewport object keeps track of the default lighting state, which can be accessed through the viewport’s defaultLightingOn() and defaultLightingType() functions.

A sun object is a hard-owned entity of every viewport. It can be accessed through a viewport’s sunId() function. The position of the sun can be set to the real world position for a particular time and date at any geographical location, to study sunlight in the model. Use AcDbSun::setDateTime() and AcDbSun::setDaylightSavingsOn() to automatically set the position of the sun to the correct point in the sky. You can also set the position explicitly through AcDbSun::setAzimuth() and AcDbSun::setAltitude(). The date and time will be recalculated to the correct time if the altitude or azimuth angle are changed directly. Similarly, the sun’s altitude and azimuth angle will be updated if you change the date or time.

The geographic location and orientation of the model is set using AcDbDatabase::setLatitude(), AcDbDatabase::setLongtitude(), AcDbDatabase::setTimeZone(), and AcDbDatabase::setNorthDirection().