<?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 Creating a Zone Element in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Zone-Element/m-p/175174#M5631</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Is it possible to create a Zone Element through the API? I've tried to create an Element with type API_ZoneID but nothing happens. From what I understand, I would need to create a Polygon for creating the zone, but I can't find any information or example on that. Here's my code:&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;API_Coord clickedPoint;
if (!ClickAPoint("Origem", &amp;amp;clickedPoint)) {
    return;
}
ACAPI_OpenUndoableSession("Do it!");

API_Element zoneElement;
API_ElementMemo zoneElementMemo;
BNZeroMemory(&amp;amp;zoneElement, sizeof(API_Element));	
BNZeroMemory(&amp;amp;zoneElementMemo, sizeof(API_ElementMemo));

zoneElement.header.typeID = API_ZoneID;
ACAPI_Element_GetDefaults(&amp;amp;zoneElement, &amp;amp;zoneElementMemo);

zoneElement.zone.manual = true;
// Code to create Polygon???

ACAPI_Element_Create(&amp;amp;zoneElement, &amp;amp;zoneElementMemo);
ACAPI_CloseUndoableSession();
&lt;/PRE&gt;
Is that even possible? Any help would be appreciated!&lt;/DIV&gt;</description>
    <pubDate>Wed, 02 Aug 2023 14:22:24 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-08-02T14:22:24Z</dc:date>
    <item>
      <title>Creating a Zone Element</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Zone-Element/m-p/175174#M5631</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Is it possible to create a Zone Element through the API? I've tried to create an Element with type API_ZoneID but nothing happens. From what I understand, I would need to create a Polygon for creating the zone, but I can't find any information or example on that. Here's my code:&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;API_Coord clickedPoint;
if (!ClickAPoint("Origem", &amp;amp;clickedPoint)) {
    return;
}
ACAPI_OpenUndoableSession("Do it!");

API_Element zoneElement;
API_ElementMemo zoneElementMemo;
BNZeroMemory(&amp;amp;zoneElement, sizeof(API_Element));	
BNZeroMemory(&amp;amp;zoneElementMemo, sizeof(API_ElementMemo));

zoneElement.header.typeID = API_ZoneID;
ACAPI_Element_GetDefaults(&amp;amp;zoneElement, &amp;amp;zoneElementMemo);

zoneElement.zone.manual = true;
// Code to create Polygon???

ACAPI_Element_Create(&amp;amp;zoneElement, &amp;amp;zoneElementMemo);
ACAPI_CloseUndoableSession();
&lt;/PRE&gt;
Is that even possible? Any help would be appreciated!&lt;/DIV&gt;</description>
      <pubDate>Wed, 02 Aug 2023 14:22:24 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Zone-Element/m-p/175174#M5631</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-02T14:22:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Zone Element</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Zone-Element/m-p/175175#M5632</link>
      <description>&lt;BLOCKQUOTE&gt;Andre wrote:&lt;BR /&gt;Hi,&lt;BR /&gt;
&lt;BR /&gt;
Is it possible to create a Zone Element through the API? I've tried to create an Element with type API_ZoneID but nothing happens. From what I understand, I would need to create a Polygon for creating the zone, but I can't find any information or example on that. Here's my code:&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;API_Coord clickedPoint;
if (!ClickAPoint("Origem", &amp;amp;clickedPoint)) {
    return;
}
ACAPI_OpenUndoableSession("Do it!");

API_Element zoneElement;
API_ElementMemo zoneElementMemo;
BNZeroMemory(&amp;amp;zoneElement, sizeof(API_Element));	
BNZeroMemory(&amp;amp;zoneElementMemo, sizeof(API_ElementMemo));

zoneElement.header.typeID = API_ZoneID;
ACAPI_Element_GetDefaults(&amp;amp;zoneElement, &amp;amp;zoneElementMemo);

zoneElement.zone.manual = true;
// Code to create Polygon???

ACAPI_Element_Create(&amp;amp;zoneElement, &amp;amp;zoneElementMemo);
ACAPI_CloseUndoableSession();
&lt;/PRE&gt;

Is that even possible? Any help would be appreciated!&lt;/BLOCKQUOTE&gt;

Hello Andre,&lt;BR /&gt;
&lt;BR /&gt;
Yes, absolutely!&lt;BR /&gt;
&lt;BR /&gt;
Two places you can look at, both are in the Element_Basics.cpp source file in the Element_Test example:
&lt;UL&gt;&lt;LI&gt;-&amp;gt; Do_CreateSlab  shows you how you can assemble the appropriate  polygon&lt;BR /&gt;
-&amp;gt; Do_CreateAutoZone demonstrates how you can do it without supplying a polygon&lt;/LI&gt;&lt;/UL&gt;

Best, Akos</description>
      <pubDate>Wed, 08 Aug 2012 10:22:24 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Zone-Element/m-p/175175#M5632</guid>
      <dc:creator>Akos Somorjai</dc:creator>
      <dc:date>2012-08-08T10:22:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Zone Element</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Zone-Element/m-p/175176#M5633</link>
      <description>It worked, thanks a lot!&lt;BR /&gt;
&lt;BR /&gt;
For future reference, here's the code I've used:
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;ACAPI_OpenUndoableSession("Do It!");

API_Element zoneElement;
API_ElementMemo elementMemo;
BNZeroMemory(&amp;amp;zoneElement, sizeof(API_Element));	
BNZeroMemory(&amp;amp;elementMemo, sizeof(API_ElementMemo));

zoneElement.header.typeID = API_ZoneID;
zoneElement.header.layer = CriarLayer();
ACAPI_Element_GetDefaults(&amp;amp;zoneElement, &amp;amp;elementMemo);

zoneElement.zone.manual = true;
zoneElement.zone.pos.x = clickedPoint.x;
zoneElement.zone.pos.y = clickedPoint.x;
zoneElement.zone.refPos.x = clickedPoint.x;
zoneElement.zone.refPos.y = clickedPoint.x;

zoneElement.zone.poly.nCoords = 5;
zoneElement.zone.poly.nSubPolys = 1;
zoneElement.zone.poly.nArcs = 0;

elementMemo.coords = (API_Coord**) BMAllocateHandle ((zoneElement.zone.poly.nCoords + 1) * sizeof (API_Coord), ALLOCATE_CLEAR, 0);
elementMemo.pends  = (Int32**) BMAllocateHandle ((zoneElement.zone.poly.nSubPolys + 1) * sizeof (Int32), ALLOCATE_CLEAR, 0);
if (elementMemo.coords != NULL &amp;amp;&amp;amp; elementMemo.pends != NULL) {
	(*elementMemo.coords)[1].x = clickedPoint.x - 1.0;
	(*elementMemo.coords)[1].y = clickedPoint.y;
	(*elementMemo.coords)[2].x = clickedPoint.x;
	(*elementMemo.coords)[2].y = clickedPoint.y - 1.0;
	(*elementMemo.coords)[3].x = clickedPoint.x + 1.0;
	(*elementMemo.coords)[3].y = clickedPoint.y;
	(*elementMemo.coords)[4].x = clickedPoint.x;
	(*elementMemo.coords)[4].y = clickedPoint.y + 1.0;
	(*elementMemo.coords)[5].x = (*elementMemo.coords)[1].x;
	(*elementMemo.coords)[5].y = (*elementMemo.coords)[1].y;

	(*elementMemo.pends)[0] = 0;
	(*elementMemo.pends)[1] = zoneElement.zone.poly.nCoords;
}

GSErrCode err = ACAPI_Element_Create(&amp;amp;zoneElement, &amp;amp;elementMemo);
if (err != NoError)
	ErrorBeep ("ACAPI_Element_Create (Zone)", err);
ACAPI_DisposeElemMemoHdls (&amp;amp;elementMemo);
ACAPI_CloseUndoableSession();
&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Sep 2012 15:51:28 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Zone-Element/m-p/175176#M5633</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-09-28T15:51:28Z</dc:date>
    </item>
  </channel>
</rss>

