<?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: Roof creation in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Roof-creation/m-p/181931#M5967</link>
    <description>Hi Tibor,&lt;BR /&gt;
&lt;BR /&gt;
Thanks very much, really helpful.&lt;BR /&gt;
&lt;BR /&gt;
Andor</description>
    <pubDate>Tue, 01 Jul 2014 13:05:07 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-07-01T13:05:07Z</dc:date>
    <item>
      <title>Roof creation</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Roof-creation/m-p/181929#M5965</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi All,&lt;BR /&gt;&lt;BR /&gt;Do you have any sample code how to create a roof from a set of points on a single plane?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Andor&lt;/DIV&gt;</description>
      <pubDate>Tue, 01 Aug 2023 12:52:04 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Roof-creation/m-p/181929#M5965</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-01T12:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Roof creation</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Roof-creation/m-p/181930#M5966</link>
      <description>Hi Andor,  &lt;BR /&gt;
  &lt;BR /&gt;
I wrote a short sample code for you:  
&lt;PRE&gt;// -----------------------------------------------------------------------------  
// Create a Single-plane Roof  
// -----------------------------------------------------------------------------  
void	Do_CreatePlaneRoof (API_Coord centerPoint)  
{  
	API_Element element;  
	BNZeroMemory (&amp;amp;element, sizeof (API_Element));  
	element.header.typeID = API_RoofID;  
	element.roof.roofClass = API_PlaneRoofID;  
	GSErrCode err = ACAPI_Element_GetDefaults (&amp;amp;element, NULL);  
	if (err != NoError) {  
		ErrorBeep ("ACAPI_Element_GetDefaults (roof)", err);  
		return;  
	}  
  
	API_ElementMemo memo;  
	BNZeroMemory (&amp;amp;memo, sizeof (API_ElementMemo));  
  
	// constructing planeRoof data  
	element.roof.u.planeRoof.poly.nCoords	= 8;  
	element.roof.u.planeRoof.poly.nSubPolys	= 2;  
	element.roof.u.planeRoof.poly.nArcs		= 2;  
  
	memo.coords = reinterpret_cast&amp;lt;API_Coord**&amp;gt; (BMAllocateHandle ((element.roof.u.planeRoof.poly.nCoords + 1) * sizeof (API_Coord), ALLOCATE_CLEAR, 0));  
	memo.pends = reinterpret_cast&amp;lt;Int32**&amp;gt; (BMAllocateHandle ((element.roof.u.planeRoof.poly.nSubPolys + 1) * sizeof (Int32), ALLOCATE_CLEAR, 0));  
	memo.parcs = reinterpret_cast&amp;lt;API_PolyArc**&amp;gt; (BMAllocateHandle (element.roof.u.planeRoof.poly.nArcs * sizeof (API_PolyArc), ALLOCATE_CLEAR, 0));  
	if (memo.coords == NULL || memo.pends == NULL || memo.parcs == NULL) {  
		ErrorBeep ("Not enough memory to create roof polygon data", APIERR_MEMFULL);  
		ACAPI_DisposeElemMemoHdls (&amp;amp;memo);  
		return;  
	}  
  
	// contour points:  
	(*memo.coords)[1].x = centerPoint.x + 10.0;  
	(*memo.coords)[1].y = centerPoint.y + 10.0;  
	(*memo.coords)[2].x = centerPoint.x + 10.0;  
	(*memo.coords)[2].y = centerPoint.y - 10.0;  
	(*memo.coords)[3].x = centerPoint.x - 10.0;  
	(*memo.coords)[3].y = centerPoint.y - 10.0;  
	(*memo.coords)[4].x = centerPoint.x - 10.0;  
	(*memo.coords)[4].y = centerPoint.y + 10.0;  
	(*memo.coords)[5] = (*memo.coords)[1];  
	(*memo.pends)[1] = 5;  
	// hole points:  
	(*memo.coords)[6].x = centerPoint.x + 5.0;  
	(*memo.coords)[6].y = centerPoint.y + 0.0;  
	(*memo.coords)[7].x = centerPoint.x - 5.0;  
	(*memo.coords)[7].y = centerPoint.y + 0.0;  
	(*memo.coords)[8] = (*memo.coords)[6];  
	(*memo.pends)[2] = 8;  
	// arcs:  
	(*memo.parcs)[0].begIndex = 6;							// makes a circle-shaped hole  
	(*memo.parcs)[0].endIndex = 7;  
	(*memo.parcs)[0].arcAngle = PI;  
	(*memo.parcs)[1].begIndex = 7;  
	(*memo.parcs)[1].endIndex = 8;  
	(*memo.parcs)[1].arcAngle = PI;  
  
	// roof baseline  
	element.roof.u.planeRoof.baseLine.c1.x = (*memo.coords)[1].x;  
	element.roof.u.planeRoof.baseLine.c1.y = (*memo.coords)[1].y;  
	element.roof.u.planeRoof.baseLine.c2.x = (*memo.coords)[3].x;  
	element.roof.u.planeRoof.baseLine.c2.y = (*memo.coords)[3].y;  
  
	// roof angle  
	element.roof.u.planeRoof.angle = 5.0 * DEGRAD;  
  
	// create the roof element  
	err = ACAPI_Element_Create (&amp;amp;element, &amp;amp;memo);  
	if (err != NoError)  
		ErrorBeep ("ACAPI_Element_Create (roof)", err);  
  
	ACAPI_DisposeElemMemoHdls (&amp;amp;memo);  
  
	return;  
}		// Do_CreatePlaneRoof&lt;/PRE&gt;  &lt;BR /&gt;
  &lt;BR /&gt;
Sorry, I couldn't test it today. But hope it works, tomorrow I'll check it.  &lt;BR /&gt;
  &lt;BR /&gt;
Regards,  &lt;BR /&gt;
Tibor</description>
      <pubDate>Wed, 25 Jun 2014 14:24:13 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Roof-creation/m-p/181930#M5966</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2014-06-25T14:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: Roof creation</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Roof-creation/m-p/181931#M5967</link>
      <description>Hi Tibor,&lt;BR /&gt;
&lt;BR /&gt;
Thanks very much, really helpful.&lt;BR /&gt;
&lt;BR /&gt;
Andor</description>
      <pubDate>Tue, 01 Jul 2014 13:05:07 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Roof-creation/m-p/181931#M5967</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-07-01T13:05:07Z</dc:date>
    </item>
  </channel>
</rss>

