<?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: Creating a Slab from scratch in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Slab-from-scratch/m-p/100100#M7808</link>
    <description>&lt;BLOCKQUOTE&gt;lciscon wrote:&lt;BR /&gt;...I am having a problem creating a slab "from scratch" (rather than modify an existing slab element).  &lt;BR /&gt;
...but no matter what I do I get a  APIERR_BADPOLY error out of the create call.&lt;/BLOCKQUOTE&gt;
It's difficult to say at what point your code is failing without more information. Perhaps you could describe your slab creation in pseudo-code?&lt;BR /&gt;
&lt;BR /&gt;
You need to do something along the following lines:
&lt;PRE&gt;Initialise an API_Polygon structure (nSubPolys, nCoords, nArcs)
Allocate handles for the relevant fields of an API_ElementMemo structure (vertexIDs, coords, parcs, pends)
For each polygon (perimeter, then holes) {
	For each vertex in the current polygon {
		Fill in the vertex coordinate (coords)
		Fill in the vertex ID (vertexIDs - optional)
		If the vertex is the end of an arc
			Fill in the arc end details (parcs)
	}
	Fill in the polygon end details (pends)
}&lt;/PRE&gt;

Make sure you allocate handles for the memo structures, not pointers. Contact me privately if you're still getting bogged down and I'll take a quick look at your source.</description>
    <pubDate>Mon, 23 Aug 2004 22:32:09 GMT</pubDate>
    <dc:creator>Ralph Wessel</dc:creator>
    <dc:date>2004-08-23T22:32:09Z</dc:date>
    <item>
      <title>Creating a Slab from scratch</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Slab-from-scratch/m-p/100097#M7805</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hello!&lt;BR /&gt;&lt;BR /&gt;I am new to this forum, so please forgive me if this topic has been covered before... I am developing a plugin for ArchiCAD, and I am having a problem creating a slab "from scratch" (rather than modify an existing slab element). &lt;BR /&gt;&lt;BR /&gt;I've read the documentation on the ACAPI_Element_Create() routine, API_SlabType, and API_Polygon (several times). And I *believe* I'm creating and filling the element and memo fields correctly...&lt;BR /&gt;&lt;BR /&gt;...but no matter what I do I get a APIERR_BADPOLY error out of the create call.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Is there some sample code that demonstrates *creating* a slab element?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I appreciate any suggestions, references, or samples.&lt;BR /&gt;&lt;BR /&gt;Thanks again. &lt;BR /&gt;&lt;BR /&gt;-larry&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;p.s. Everything else I've used in the API has worked fine (i.e. creating walls, reading data, manipulating elements, etc. etc.)&lt;BR /&gt;&lt;BR /&gt;p.p.s. I would include my code...but at this point it's a bit of a mess with all of the experiments I've tried to get it to work... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 07 Aug 2023 10:17:48 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Slab-from-scratch/m-p/100097#M7805</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-07T10:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Slab from scratch</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Slab-from-scratch/m-p/100098#M7806</link>
      <description>&lt;BLOCKQUOTE&gt;lciscon wrote:&lt;BR /&gt;Is there some sample code that demonstrates *creating* a slab element?&lt;/BLOCKQUOTE&gt;

I haven't done it, so don't have any code to share ...  The Element Manager example project's Element_Basics.cpp file has a lot of sample calls to ACAPI_Element_Create (but no slab).  The only reference to API_SlabType in the example source files is in this same example's Element_Modify.cpp file.&lt;BR /&gt;
&lt;BR /&gt;
Hopefully someone else can help ... or you can weed out your code so that you can post it...  Ralph and Oleg will be waking up soon. &lt;E&gt;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/E&gt;&lt;BR /&gt;
&lt;BR /&gt;
Karl</description>
      <pubDate>Thu, 19 Aug 2004 04:29:47 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Slab-from-scratch/m-p/100098#M7806</guid>
      <dc:creator>Karl Ottenstein</dc:creator>
      <dc:date>2004-08-19T04:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Slab from scratch</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Slab-from-scratch/m-p/100099#M7807</link>
      <description>You can also take a look at the code which creates a library part out of the selection while it works. Or any other code which picks up the API_Element and the API_Element_Memo of an existing slab element.&lt;BR /&gt;
&lt;BR /&gt;
APIERR_BADPOLY is returned usually if you haven't filled the &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;coords&lt;E&gt;&lt;/E&gt;, &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;parcs&lt;E&gt;&lt;/E&gt;, and &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;pends&lt;E&gt;&lt;/E&gt; fields of API_ElementMemo correctly.&lt;BR /&gt;
&lt;BR /&gt;
Also, you might take a look at the description of AP_Polygon.&lt;BR /&gt;
&lt;BR /&gt;
HTH,&lt;BR /&gt;
&lt;BR /&gt;
Akos</description>
      <pubDate>Mon, 23 Aug 2004 15:38:59 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Slab-from-scratch/m-p/100099#M7807</guid>
      <dc:creator>Akos Somorjai</dc:creator>
      <dc:date>2004-08-23T15:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Slab from scratch</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Slab-from-scratch/m-p/100100#M7808</link>
      <description>&lt;BLOCKQUOTE&gt;lciscon wrote:&lt;BR /&gt;...I am having a problem creating a slab "from scratch" (rather than modify an existing slab element).  &lt;BR /&gt;
...but no matter what I do I get a  APIERR_BADPOLY error out of the create call.&lt;/BLOCKQUOTE&gt;
It's difficult to say at what point your code is failing without more information. Perhaps you could describe your slab creation in pseudo-code?&lt;BR /&gt;
&lt;BR /&gt;
You need to do something along the following lines:
&lt;PRE&gt;Initialise an API_Polygon structure (nSubPolys, nCoords, nArcs)
Allocate handles for the relevant fields of an API_ElementMemo structure (vertexIDs, coords, parcs, pends)
For each polygon (perimeter, then holes) {
	For each vertex in the current polygon {
		Fill in the vertex coordinate (coords)
		Fill in the vertex ID (vertexIDs - optional)
		If the vertex is the end of an arc
			Fill in the arc end details (parcs)
	}
	Fill in the polygon end details (pends)
}&lt;/PRE&gt;

Make sure you allocate handles for the memo structures, not pointers. Contact me privately if you're still getting bogged down and I'll take a quick look at your source.</description>
      <pubDate>Mon, 23 Aug 2004 22:32:09 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-Slab-from-scratch/m-p/100100#M7808</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2004-08-23T22:32:09Z</dc:date>
    </item>
  </channel>
</rss>

