<?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 Slab poly fom List of Coords in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Slab-poly-fom-List-of-Coords/m-p/241971#M4259</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;I'm trying to encapsulate Creating Slab out of given List of Coords. Unfortunately, I got stuck. Mostly I got Err that passed polygon is wrong. I triple checked with related docs, examples and tried different options but it doesn't work. I have also tried it out of fuction.. the same result. Please Help.&lt;BR /&gt;My last attempt:&lt;BR /&gt;
&lt;PRE&gt;		
		//Quick list
		GS::Array&amp;lt;API_Coord&amp;gt; myLis;
		API_Coord myPt;	myPt.x = 0.0;	myPt.y = 0.0; myLis.Push(myPt);
		myPt;	myPt.x = 0.0;	myPt.y = 1.0; myLis.Push(myPt);
		myPt;	myPt.x = 1.0;	myPt.y = 1.0; myLis.Push(myPt);
		myPt;	myPt.x = 0.0;	myPt.y = 1.0; myLis.Push(myPt);
		SlabDo(myLis);


static void SlabDo(GS::Array&amp;lt;API_Coord&amp;gt;&amp;amp; ptList) {
	
		API_Element		elem;
		API_ElementMemo	mem;
		BNZeroMemory(&amp;amp;elem, sizeof(API_Element));
		BNZeroMemory(&amp;amp;mem, sizeof(API_ElementMemo));
				
		elem.header.typeID = API_SlabID;
		ACAPI_Element_GetDefaults(&amp;amp;elem, nullptr); // &amp;amp;mem?
		int ptListSize = ptList.GetSize();
		
		elem.slab.poly.nCoords = ptListSize + 1;

		elem.slab.poly.nSubPolys = 1;
		elem.slab.poly.nArcs = 0;

		mem.coords = (API_Coord**)BMAllocateHandle((elem.detail.poly.nCoords + 1) * sizeof(API_Coord), ALLOCATE_CLEAR, 0);     //Works but gives Wrong Poligon Error when doing Slab
		mem.pends = (Int32**)BMAllocateHandle((elem.detail.poly.nSubPolys + 1) * sizeof(Int32), ALLOCATE_CLEAR, 0);
		mem.parcs = reinterpret_cast&amp;lt;API_PolyArc**&amp;gt; (BMAllocateHandle(elem.slab.poly.nArcs * sizeof(API_PolyArc), ALLOCATE_CLEAR, 0));  // Gives eerro - not enougth memory

		if (mem.coords == nullptr || mem.pends == nullptr || mem.parcs == nullptr) {
			ACAPI_WriteReport("Not enough memory to create slab polygon data", true);
			ACAPI_DisposeElemMemoHdls(&amp;amp;mem);
			return;
		}

		Int32 iCoord = 1;
		for (int ii=0; ii &amp;lt; ptListSize; ii++) {
			
			ACAPI_WriteReport(GS::ValueToString(ii), true);
			(*mem.coords)[iCoord].x = ptList[ii].x;
			ACAPI_WriteReport(GS::ValueToString(ptList[ii].x), true);

			(*mem.coords)[iCoord].y = ptList[ii].y;

			ACAPI_WriteReport(GS::ValueToString(ptList[ii].y), true);

			++iCoord;
		}

		(*mem.coords)[iCoord] = (*mem.coords)[1];
		(*mem.pends)[0] = 0;
		(*mem.pends)[1] = iCoord;
		
		const GSErrCode err = ACAPI_Element_Create(&amp;amp;elem, &amp;amp;mem);
		if (err != NoError) {
			ACAPI_WriteReport(GS::ValueToString(err), true);
		}
		ACAPI_DisposeElemMemoHdls(&amp;amp;mem);
	}
&lt;/PRE&gt;
&lt;/DIV&gt;</description>
    <pubDate>Tue, 04 Jul 2023 12:08:23 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-07-04T12:08:23Z</dc:date>
    <item>
      <title>Slab poly fom List of Coords</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Slab-poly-fom-List-of-Coords/m-p/241971#M4259</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;I'm trying to encapsulate Creating Slab out of given List of Coords. Unfortunately, I got stuck. Mostly I got Err that passed polygon is wrong. I triple checked with related docs, examples and tried different options but it doesn't work. I have also tried it out of fuction.. the same result. Please Help.&lt;BR /&gt;My last attempt:&lt;BR /&gt;
&lt;PRE&gt;		
		//Quick list
		GS::Array&amp;lt;API_Coord&amp;gt; myLis;
		API_Coord myPt;	myPt.x = 0.0;	myPt.y = 0.0; myLis.Push(myPt);
		myPt;	myPt.x = 0.0;	myPt.y = 1.0; myLis.Push(myPt);
		myPt;	myPt.x = 1.0;	myPt.y = 1.0; myLis.Push(myPt);
		myPt;	myPt.x = 0.0;	myPt.y = 1.0; myLis.Push(myPt);
		SlabDo(myLis);


static void SlabDo(GS::Array&amp;lt;API_Coord&amp;gt;&amp;amp; ptList) {
	
		API_Element		elem;
		API_ElementMemo	mem;
		BNZeroMemory(&amp;amp;elem, sizeof(API_Element));
		BNZeroMemory(&amp;amp;mem, sizeof(API_ElementMemo));
				
		elem.header.typeID = API_SlabID;
		ACAPI_Element_GetDefaults(&amp;amp;elem, nullptr); // &amp;amp;mem?
		int ptListSize = ptList.GetSize();
		
		elem.slab.poly.nCoords = ptListSize + 1;

		elem.slab.poly.nSubPolys = 1;
		elem.slab.poly.nArcs = 0;

		mem.coords = (API_Coord**)BMAllocateHandle((elem.detail.poly.nCoords + 1) * sizeof(API_Coord), ALLOCATE_CLEAR, 0);     //Works but gives Wrong Poligon Error when doing Slab
		mem.pends = (Int32**)BMAllocateHandle((elem.detail.poly.nSubPolys + 1) * sizeof(Int32), ALLOCATE_CLEAR, 0);
		mem.parcs = reinterpret_cast&amp;lt;API_PolyArc**&amp;gt; (BMAllocateHandle(elem.slab.poly.nArcs * sizeof(API_PolyArc), ALLOCATE_CLEAR, 0));  // Gives eerro - not enougth memory

		if (mem.coords == nullptr || mem.pends == nullptr || mem.parcs == nullptr) {
			ACAPI_WriteReport("Not enough memory to create slab polygon data", true);
			ACAPI_DisposeElemMemoHdls(&amp;amp;mem);
			return;
		}

		Int32 iCoord = 1;
		for (int ii=0; ii &amp;lt; ptListSize; ii++) {
			
			ACAPI_WriteReport(GS::ValueToString(ii), true);
			(*mem.coords)[iCoord].x = ptList[ii].x;
			ACAPI_WriteReport(GS::ValueToString(ptList[ii].x), true);

			(*mem.coords)[iCoord].y = ptList[ii].y;

			ACAPI_WriteReport(GS::ValueToString(ptList[ii].y), true);

			++iCoord;
		}

		(*mem.coords)[iCoord] = (*mem.coords)[1];
		(*mem.pends)[0] = 0;
		(*mem.pends)[1] = iCoord;
		
		const GSErrCode err = ACAPI_Element_Create(&amp;amp;elem, &amp;amp;mem);
		if (err != NoError) {
			ACAPI_WriteReport(GS::ValueToString(err), true);
		}
		ACAPI_DisposeElemMemoHdls(&amp;amp;mem);
	}
&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 04 Jul 2023 12:08:23 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Slab-poly-fom-List-of-Coords/m-p/241971#M4259</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-07-04T12:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: Slab poly fom List of Coords</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Slab-poly-fom-List-of-Coords/m-p/241972#M4260</link>
      <description>ok I got to the point where I have APIERR_IRREGULARPOLY error. Should I try  ACPI_Goodies(API_RegularizePolyID)  or there is still something wrong with poly it self ?</description>
      <pubDate>Tue, 11 Sep 2018 20:59:55 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Slab-poly-fom-List-of-Coords/m-p/241972#M4260</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-11T20:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Slab poly fom List of Coords</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Slab-poly-fom-List-of-Coords/m-p/241973#M4261</link>
      <description>Ok. Moved back a bit and it's working. I got nCords and number of iterations wrong.</description>
      <pubDate>Wed, 12 Sep 2018 10:23:03 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Slab-poly-fom-List-of-Coords/m-p/241973#M4261</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-12T10:23:03Z</dc:date>
    </item>
  </channel>
</rss>

