<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to get the projected area through API function？ in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-the-projected-area-through-API-function/m-p/236907#M4232</link>
    <description>Ralph's right, you have to calculate this on your own.&lt;BR /&gt;
But of course we are here to help you, so I wrote you a draft for this calculation:&lt;BR /&gt;

&lt;PRE&gt;#include	"ACAPinc.h"

#include	"basicgeometry.h"
#include	"Polygon2D.hpp"

static double CalculateProjectedAreaOfElem (const API_Guid&amp;amp; elemGuid)
{
	double			calculatedArea = 0.;
	GSErrCode		err = NoError;
	Geometry::Plane	floorPlanPlane;
	API_Elem_Head	elemHead = {};
	elemHead.guid = elemGuid;

	API_ElemInfo3D 	info3D;
	err = ACAPI_Element_Get3DInfo (elemHead, &amp;amp;info3D);
	if (DBERROR (err != NoError))
		return 0;

	Geometry::MultiPolygon2D projectedPolygon2DArray; 
	for (Int32 ibody = info3D.fbody; ibody &amp;lt;= info3D.lbody; ++ibody) {
		API_Component3D 	component = {};
		component.header.typeID = API_BodyID;
		component.header.index  = ibody;
		err = ACAPI_3D_GetComponent (&amp;amp;component);
		if (DBERROR (err != NoError))
			continue;

		Int32		nPgon = component.body.nPgon;
		API_Tranmat	tm = component.body.tranmat;

		for (Int32 iPgon = 1; iPgon &amp;lt;= nPgon; ++iPgon) {
			component.header.typeID = API_PgonID;
			component.header.index  = iPgon;
			err = ACAPI_3D_GetComponent (&amp;amp;component);
			if (DBERROR (err != NoError))
				continue;

			GS::Array&amp;lt;Coord&amp;gt;	pgonCoordsProjectedToFloorPlan;
			for (Int32 iEdge = component.pgon.fpedg; iEdge &amp;lt;= component.pgon.lpedg; ++iEdge) {
				component.header.typeID = API_EdgeID;
				component.header.index  = iEdge;
				err = ACAPI_3D_GetComponent (&amp;amp;component);
				if (DBERROR (err != NoError))
					continue;

				component.header.typeID = API_VertID;
				component.header.index  = component.edge.vert1;
				err = ACAPI_3D_GetComponent (&amp;amp;component);
				if (DBERROR (err != NoError))
					continue;

				Geometry::Coord3D	worldCoord;
				worldCoord.x = tm.tmx[0]*component.vert.x + tm.tmx[1]*component.vert.y + tm.tmx[2]*component.vert.z + tm.tmx[3];
				worldCoord.y = tm.tmx[4]*component.vert.x + tm.tmx[5]*component.vert.y + tm.tmx[6]*component.vert.z + tm.tmx[7];
				worldCoord.z = tm.tmx[8]*component.vert.x + tm.tmx[9]*component.vert.y + tm.tmx[10]*component.vert.z + tm.tmx[11];
				Geometry::Coord3D	projectedCoord = floorPlanPlane.ProjectToPlane (worldCoord);
				pgonCoordsProjectedToFloorPlan.PushNew (projectedCoord.x, projectedCoord.y);
			}

			Geometry::MultiPolygon2D polygon2DArray; 
			Geometry::Polygon2D::Create (pgonCoordsProjectedToFloorPlan, 0, polygon2DArray);
			projectedPolygon2DArray.Append (polygon2DArray);
		}
	}

	projectedPolygon2DArray.Unify (Geometry::WithoutHoles);
	for (const Geometry::Polygon2D&amp;amp; polygon2D : projectedPolygon2DArray)
		calculatedArea += polygon2D.CalcArea ();

	return calculatedArea;
}&lt;/PRE&gt;

This is based on Ralph's idea.</description>
    <pubDate>Thu, 23 Aug 2018 07:40:13 GMT</pubDate>
    <dc:creator>Tibor Lorantfy</dc:creator>
    <dc:date>2018-08-23T07:40:13Z</dc:date>
    <item>
      <title>How to get the projected area through API function？</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-the-projected-area-through-API-function/m-p/236903#M4228</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Does anyone know this question?If I have a 3D object and I want to get the projected area of this object, is there any way to get this area through the API function?&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Leilei&lt;/DIV&gt;</description>
      <pubDate>Wed, 30 Nov 2022 09:47:56 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-the-projected-area-through-API-function/m-p/236903#M4228</guid>
      <dc:creator>leilei</dc:creator>
      <dc:date>2022-11-30T09:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the projected area through API function？</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-the-projected-area-through-API-function/m-p/236904#M4229</link>
      <description>Could you clarify whether you mean the total surface area of the 3D body or the area visible in the 3D window?</description>
      <pubDate>Thu, 23 Aug 2018 06:28:53 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-the-projected-area-through-API-function/m-p/236904#M4229</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2018-08-23T06:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the projected area through API function？</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-the-projected-area-through-API-function/m-p/236905#M4230</link>
      <description>&lt;BLOCKQUOTE&gt;Ralph wrote:&lt;BR /&gt;
Could you clarify whether you mean the total surface area of the 3D body or the area visible in the 3D window?
&lt;/BLOCKQUOTE&gt;

Hi Ralph,&lt;BR /&gt;
The area I want is like a projection on a floor plan.&lt;BR /&gt;
Regards,&lt;BR /&gt;
Leilei</description>
      <pubDate>Thu, 23 Aug 2018 06:40:05 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-the-projected-area-through-API-function/m-p/236905#M4230</guid>
      <dc:creator>leilei</dc:creator>
      <dc:date>2018-08-23T06:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the projected area through API function？</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-the-projected-area-through-API-function/m-p/236906#M4231</link>
      <description>I don't know if there's an easy answer to that. Bottom line, you could extract the faces of the 3D body, project them to 2D polygons in the view plane and merge them to result in the bounding polygon(s). Hopefully there is a simpler method.</description>
      <pubDate>Thu, 23 Aug 2018 07:10:20 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-the-projected-area-through-API-function/m-p/236906#M4231</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2018-08-23T07:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the projected area through API function？</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-the-projected-area-through-API-function/m-p/236907#M4232</link>
      <description>Ralph's right, you have to calculate this on your own.&lt;BR /&gt;
But of course we are here to help you, so I wrote you a draft for this calculation:&lt;BR /&gt;

&lt;PRE&gt;#include	"ACAPinc.h"

#include	"basicgeometry.h"
#include	"Polygon2D.hpp"

static double CalculateProjectedAreaOfElem (const API_Guid&amp;amp; elemGuid)
{
	double			calculatedArea = 0.;
	GSErrCode		err = NoError;
	Geometry::Plane	floorPlanPlane;
	API_Elem_Head	elemHead = {};
	elemHead.guid = elemGuid;

	API_ElemInfo3D 	info3D;
	err = ACAPI_Element_Get3DInfo (elemHead, &amp;amp;info3D);
	if (DBERROR (err != NoError))
		return 0;

	Geometry::MultiPolygon2D projectedPolygon2DArray; 
	for (Int32 ibody = info3D.fbody; ibody &amp;lt;= info3D.lbody; ++ibody) {
		API_Component3D 	component = {};
		component.header.typeID = API_BodyID;
		component.header.index  = ibody;
		err = ACAPI_3D_GetComponent (&amp;amp;component);
		if (DBERROR (err != NoError))
			continue;

		Int32		nPgon = component.body.nPgon;
		API_Tranmat	tm = component.body.tranmat;

		for (Int32 iPgon = 1; iPgon &amp;lt;= nPgon; ++iPgon) {
			component.header.typeID = API_PgonID;
			component.header.index  = iPgon;
			err = ACAPI_3D_GetComponent (&amp;amp;component);
			if (DBERROR (err != NoError))
				continue;

			GS::Array&amp;lt;Coord&amp;gt;	pgonCoordsProjectedToFloorPlan;
			for (Int32 iEdge = component.pgon.fpedg; iEdge &amp;lt;= component.pgon.lpedg; ++iEdge) {
				component.header.typeID = API_EdgeID;
				component.header.index  = iEdge;
				err = ACAPI_3D_GetComponent (&amp;amp;component);
				if (DBERROR (err != NoError))
					continue;

				component.header.typeID = API_VertID;
				component.header.index  = component.edge.vert1;
				err = ACAPI_3D_GetComponent (&amp;amp;component);
				if (DBERROR (err != NoError))
					continue;

				Geometry::Coord3D	worldCoord;
				worldCoord.x = tm.tmx[0]*component.vert.x + tm.tmx[1]*component.vert.y + tm.tmx[2]*component.vert.z + tm.tmx[3];
				worldCoord.y = tm.tmx[4]*component.vert.x + tm.tmx[5]*component.vert.y + tm.tmx[6]*component.vert.z + tm.tmx[7];
				worldCoord.z = tm.tmx[8]*component.vert.x + tm.tmx[9]*component.vert.y + tm.tmx[10]*component.vert.z + tm.tmx[11];
				Geometry::Coord3D	projectedCoord = floorPlanPlane.ProjectToPlane (worldCoord);
				pgonCoordsProjectedToFloorPlan.PushNew (projectedCoord.x, projectedCoord.y);
			}

			Geometry::MultiPolygon2D polygon2DArray; 
			Geometry::Polygon2D::Create (pgonCoordsProjectedToFloorPlan, 0, polygon2DArray);
			projectedPolygon2DArray.Append (polygon2DArray);
		}
	}

	projectedPolygon2DArray.Unify (Geometry::WithoutHoles);
	for (const Geometry::Polygon2D&amp;amp; polygon2D : projectedPolygon2DArray)
		calculatedArea += polygon2D.CalcArea ();

	return calculatedArea;
}&lt;/PRE&gt;

This is based on Ralph's idea.</description>
      <pubDate>Thu, 23 Aug 2018 07:40:13 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-the-projected-area-through-API-function/m-p/236907#M4232</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2018-08-23T07:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the projected area through API function？</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-the-projected-area-through-API-function/m-p/236908#M4233</link>
      <description>Thanks Ralph and Tibor, &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_biggrin.gif" style="display : inline;" /&gt;  &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_biggrin.gif" style="display : inline;" /&gt;  &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_biggrin.gif" style="display : inline;" /&gt;  &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_biggrin.gif" style="display : inline;" /&gt;  &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_biggrin.gif" style="display : inline;" /&gt;  &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_biggrin.gif" style="display : inline;" /&gt;</description>
      <pubDate>Thu, 23 Aug 2018 08:14:01 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-the-projected-area-through-API-function/m-p/236908#M4233</guid>
      <dc:creator>leilei</dc:creator>
      <dc:date>2018-08-23T08:14:01Z</dc:date>
    </item>
  </channel>
</rss>

