<?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 mesh from scratch using the API in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-mesh-from-scratch-using-the-API/m-p/14929#M6399</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;Hi. I'm supposed to write a function that generates a mesh starting from a (x,y,z) coord set. So far the correct usage of the mesh element's memo has eluded me. Could someone help me with a piece of souce code that correctly creates a mesh so that I might get some clues about it? Thank you!&lt;/DIV&gt;</description>
    <pubDate>Fri, 04 Aug 2023 14:12:05 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-08-04T14:12:05Z</dc:date>
    <item>
      <title>Creating a mesh from scratch using the API</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-mesh-from-scratch-using-the-API/m-p/14929#M6399</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi. I'm supposed to write a function that generates a mesh starting from a (x,y,z) coord set. So far the correct usage of the mesh element's memo has eluded me. Could someone help me with a piece of souce code that correctly creates a mesh so that I might get some clues about it? Thank you!&lt;/DIV&gt;</description>
      <pubDate>Fri, 04 Aug 2023 14:12:05 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-mesh-from-scratch-using-the-API/m-p/14929#M6399</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-04T14:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a mesh from scratch using the API</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-mesh-from-scratch-using-the-API/m-p/14930#M6400</link>
      <description>&lt;BLOCKQUOTE&gt;Marius wrote:&lt;BR /&gt;Hi. I'm supposed to write a function that generates a mesh starting from a (x,y,z) coord set. So far the correct usage of the mesh element's memo has eluded me. Could someone help me with a piece of souce code that correctly creates a mesh so that I might get some clues about it? Thank you!&lt;/BLOCKQUOTE&gt;
Have you looked at the documentation for ACAPI_Element_GetMemo and API_Polygon? Although it doesn't describe the contents of meshPolyZ, meshLevelCoords, and meshLevelEnds, their meaning echoes the equivalent structures for API_Polygon.</description>
      <pubDate>Fri, 25 Jan 2008 17:48:28 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-mesh-from-scratch-using-the-API/m-p/14930#M6400</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2008-01-25T17:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a mesh from scratch using the API</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-mesh-from-scratch-using-the-API/m-p/14931#M6401</link>
      <description>I too am trying to create a mesh from scratch.  From what i can tell from the documentation this should be enough info to create a mesh?  It is returning the APIERR_BADPOLY error.  This same exact poly definition works when i create a polyline but not in a mesh.  Heres my code.&lt;BR /&gt;
&lt;BR /&gt;
BNZeroMemory(&amp;amp;element,sizeof(API_Element)); &lt;BR /&gt;
   BNZeroMemory(&amp;amp;memo,sizeof(API_ElementMemo)); &lt;BR /&gt;
&lt;BR /&gt;
   element.header.typeID = API_MeshID; &lt;BR /&gt;
   err = ACAPI_Element_GetDefaults (&amp;amp;element, &amp;amp;memo);&lt;BR /&gt;
   element.header.layer = 1; &lt;BR /&gt;
&lt;BR /&gt;
     &lt;BR /&gt;
   element.mesh.poly.nArcs = 0;     //no arcs &lt;BR /&gt;
   element.mesh.poly.nSubPolys = 1; //no holes &lt;BR /&gt;
   element.mesh.poly.nCoords = 5;   //rectangle&lt;BR /&gt;
   &lt;BR /&gt;
    &lt;BR /&gt;
 BMAllocateHandle(sizeof(long) * (6), ALLOCATE_CLEAR, 0); &lt;BR /&gt;
   &lt;BR /&gt;
   memo.meshPolyZ = (double **) BMAllocateHandle(sizeof(double) * 6, ALLOCATE_CLEAR, 0); &lt;BR /&gt;
     &lt;BR /&gt;
      //allocate space for 4points + final point to close shape + space for storing max vertID = 5 &lt;BR /&gt;
   memo.vertexIDs = (unsigned long **) BMAllocateHandle(sizeof(long) * (6), ALLOCATE_CLEAR, 0); &lt;BR /&gt;
   (*memo.vertexIDs)[0] = 4; //max vertexID &lt;BR /&gt;
&lt;BR /&gt;
   //allocate space for pends. no holes, so the 5th vert is the only endpoint. &lt;BR /&gt;
   memo.pends = (long **) BMAllocateHandle(sizeof(long) * 2, ALLOCATE_CLEAR, 0); &lt;BR /&gt;
   (*memo.pends)[0] = 0; //required &lt;BR /&gt;
   (*memo.pends)[1] = 5; //5th vert closes &lt;BR /&gt;
&lt;BR /&gt;
   //allocate space for the coord array. 5 vertices + the dummy . &lt;BR /&gt;
   memo.coords = (API_Coord **) BMAllocateHandle(sizeof(API_Coord) * 6, ALLOCATE_CLEAR, 0); &lt;BR /&gt;
   (*memo.coords)[0].x = -1.0;  //polylines start with a "dummy" coord of -1,0 &lt;BR /&gt;
   (*memo.coords)[0].y = 0.0; &lt;BR /&gt;
   (*memo.meshPolyZ)[0] = 0.0; //&lt;BR /&gt;
   //setup complete....add vertices. &lt;BR /&gt;
&lt;BR /&gt;
   //1st point: &lt;BR /&gt;
   (*memo.coords)[1].x = nHouseMinx; &lt;BR /&gt;
   (*memo.coords)[1].y = nHouseMiny; &lt;BR /&gt;
   (*memo.meshPolyZ)[1] = 2; //&lt;BR /&gt;
   (*memo.vertexIDs)[1] = 1; &lt;BR /&gt;
&lt;BR /&gt;
   //2nd point: &lt;BR /&gt;
   (*memo.coords)[2].x = nHouseMinx; &lt;BR /&gt;
   (*memo.coords)[2].y = nHouseMaxy; &lt;BR /&gt;
   (*memo.meshPolyZ)[2] = 1; //&lt;BR /&gt;
   (*memo.vertexIDs)[2] = 2; &lt;BR /&gt;
&lt;BR /&gt;
   //3rd point: &lt;BR /&gt;
   (*memo.coords)[3].x = nHouseMaxx; &lt;BR /&gt;
   (*memo.coords)[3].y = nHouseMaxy; &lt;BR /&gt;
   (*memo.meshPolyZ)[3] = 2; //&lt;BR /&gt;
   (*memo.vertexIDs)[3] = 3; &lt;BR /&gt;
&lt;BR /&gt;
   //4th point. Same as point 1. &lt;BR /&gt;
   (*memo.coords)[4].x = nHouseMaxx; &lt;BR /&gt;
   (*memo.coords)[4].y = nHouseMiny; &lt;BR /&gt;
   (*memo.meshPolyZ)[4] = 1; //&lt;BR /&gt;
   (*memo.vertexIDs)[4] = 4; &lt;BR /&gt;
	&lt;BR /&gt;
   //4th point. Same as point 1.&lt;BR /&gt;
   (*memo.coords)[5].x = nHouseMinx; &lt;BR /&gt;
   (*memo.coords)[5].y = nHouseMiny; &lt;BR /&gt;
   (*memo.meshPolyZ)[5] = 1; //&lt;BR /&gt;
   (*memo.vertexIDs)[5] = 1; &lt;BR /&gt;
&lt;BR /&gt;
 err = ACAPI_Element_Create(&amp;amp;element,&amp;amp;memo); &lt;BR /&gt;
   if (err != NoError){&lt;BR /&gt;
		WriteReport (ErrID_To_Name(err));&lt;BR /&gt;
		}&lt;BR /&gt;
   //handle return code... &lt;BR /&gt;
   ACAPI_DisposeElemMemoHdls(&amp;amp;memo); &lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance.</description>
      <pubDate>Thu, 03 Apr 2008 08:58:26 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-mesh-from-scratch-using-the-API/m-p/14931#M6401</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-04-03T08:58:26Z</dc:date>
    </item>
  </channel>
</rss>

