cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Sun direction documentation

Hey All,

I think that the documentation for APIAny_CalcSunOnPlaceID is bad, since API_PlaceInfo has been changed.

I try to figure out how does it work now, but I have some troubles. Could you please help?

double getSunDir (void){
	API_PlaceInfo  placeInfo;
	API_Attribute  attrib;
	GSErrCode      err;

	BNZeroMemory (&attrib, sizeof (API_Attribute));
	attrib.header.typeID = API_CityID;
	CHCopyC ("Budapest", attrib.header.name);

	err = ACAPI_Attribute_Search (&attrib.header);
	if (!err) {
		BNZeroMemory (&placeInfo, sizeof (API_PlaceInfo));
		placeInfo.timeZone = attrib.city.zone;
		placeInfo.latitude = attrib.city.latitude;
		placeInfo.longitude = attrib.city.longitude;
		DBPrintf("latitude %d",placeInfo.latitude);
		DBPrintf("longitude %d",placeInfo.longitude);
		placeInfo.sumTime = false;    // winter time 
		placeInfo.dayOfYear = 60;
		placeInfo.minOfDay = 600;
		placeInfo.north = PI / 2;     // up direction

		err = ACAPI_Goodies (APIAny_CalcSunOnPlaceID, &placeInfo, NULL);
		return placeInfo.sunAngXY;
	}
	else{
	DBPrintf("We don't know where the sun is.");
	return 0;
	}
	
}
2 Replies 2
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
Szia Andor,

I will fix the documentation for APIAny_CalcSunOnPlaceID.
Here's an example code from Environment_Control test AddOn:
// ----------------------------------------------------------------------------- 
// Get city/date/time/sun information 
// ----------------------------------------------------------------------------- 
 
static void		Do_DumpLocation (void) 
{
	API_PlaceInfo	placeInfo; 
	API_Vector3D	sunDir; 
	GSErrCode		err; 
 
	BNZeroMemory (&placeInfo, sizeof (API_PlaceInfo)); 
	err = ACAPI_Environment (APIEnv_GetPlaceSetsID, &placeInfo, NULL); 
	if (err) { 
		ErrorBeep ("APIEnv_GetPlaceSetsID", err); 
		return; 
	} 
 
	WriteReport ("actual day: %d", placeInfo.dayOfYear); 
	WriteReport ("actual minute: %d", placeInfo.minOfDay); 
 
	placeInfo.dayOfYear = 45; 
	placeInfo.minOfDay = 8 * 60 + 45; 
	err = ACAPI_Goodies (APIAny_CalcSunOnPlaceID, &placeInfo, NULL); 
	if (err) { 
		ErrorBeep ("APIAny_CalcSunOnPlaceID", err); 
		return; 
	} 
 
	sunDir.x = cos (placeInfo.sunAngXY) * cos (placeInfo.sunAngZ); 
	sunDir.y = sin (placeInfo.sunAngXY) * cos (placeInfo.sunAngZ); 
	sunDir.z = sin (placeInfo.sunAngZ); 
 
	WriteReport ("Sun data at 8:45 on 14th February"); 
	WriteReport ("  xy angle: %lf", placeInfo.sunAngXY); 
	WriteReport ("  z angle:  %lf", placeInfo.sunAngZ); 
	WriteReport ("  dirVect:  (%lf, %lf, %lf) ", sunDir.x, sunDir.y, sunDir.z); 
 
	return; 
}		// Do_DumpLocation


This shows how to calculate the sun direction from the given placeInfo.

Best Regards,
Tibor
Anonymous
Not applicable
Ran into the incorrect documentation also.

I was wondering if there is a way to pull out the current selected city in the sun directoin in Archicad 19

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!