<?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 Drawing polyLines in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Drawing-polyLines/m-p/75702#M8058</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;I'm getting the error APIERR_REFUSEDCMD (-2130312312) when I try to create a polyline. The code below is much simplified and with extra comments...Am I missing something?
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;void	DrawPoly(void){
	API_ElementMemo		memo;
	API_ElementMemo*	pMemo = &amp;amp;memo;
	API_Element			newPoly;
	API_Element*		pNewPoly = &amp;amp;newPoly;
	GSErrCode			err;

	BNZeroMemory(pNewPoly,sizeof(API_Element));
	BNZeroMemory(pMemo,sizeof(API_ElementMemo));

	pNewPoly-&amp;gt;header.typeID = API_PolyLineID;
	pNewPoly-&amp;gt;header.layer = 1;
	pNewPoly-&amp;gt;header.floorInd = 1;

	pNewPoly-&amp;gt;polyLine.poly.nArcs = 0;     //no arcs
	pNewPoly-&amp;gt;polyLine.poly.nSubPolys = 1; //no holes
	pNewPoly-&amp;gt;polyLine.poly.nCoords = 4;   //a closed triangle

	//allocate space for 3points + final point to close shape + space for storing max vertID = 5
	pMemo-&amp;gt;vertexIDs = (unsigned long **) BMAllocateHandle(sizeof(long) * (5), ALLOCATE_CLEAR, 0);
	(*pMemo-&amp;gt;vertexIDs)[0] = 3; //max vertexID

	//allocate space for pends. no holes, so the 4th vert is the only endpoint.
	pMemo-&amp;gt;pends = (long **) BMAllocateHandle(sizeof(long) * 2, ALLOCATE_CLEAR, 0);
	(*pMemo-&amp;gt;pends)[0] = 0; //required
	(*pMemo-&amp;gt;pends)[1] = 4; //4th vert closes the shape

	//allocate space for the coord array. 4 vertices + the dummy coord.
	pMemo-&amp;gt;coords = (API_Coord **) BMAllocateHandle(sizeof(API_Coord) * 5, ALLOCATE_CLEAR, 0);
	(*pMemo-&amp;gt;coords)[0].x = -1.0;  //polylines start with a "dummy" coord of -1,0
	(*pMemo-&amp;gt;coords)[0].y = 0.0;
	//setup complete....add vertices.

	//1st point: 1,1
	(*pMemo-&amp;gt;coords)[1].x = 1;
	(*pMemo-&amp;gt;coords)[1].y = 1;
	(*pMemo-&amp;gt;vertexIDs)[1] = 1;

	//2nd point: 2,1
	(*pMemo-&amp;gt;coords)[2].x = 2;
	(*pMemo-&amp;gt;coords)[2].y = 1;
	(*pMemo-&amp;gt;vertexIDs)[2] = 2;

	//3rd point: 1,2
	(*pMemo-&amp;gt;coords)[3].x = 1;
	(*pMemo-&amp;gt;coords)[3].y = 2;
	(*pMemo-&amp;gt;vertexIDs)[3] = 3;

	//4th point. Same as point 1.
	(*pMemo-&amp;gt;coords)[4].x = 1;
	(*pMemo-&amp;gt;coords)[4].y = 1;
	(*pMemo-&amp;gt;vertexIDs)[4] = 1;

	err = ACAPI_Element_Create(pNewPoly,pMemo);
	//handle return code...
	ACAPI_DisposeElemMemoHdls(pMemo);
}&lt;/PRE&gt;
&lt;/DIV&gt;</description>
    <pubDate>Mon, 09 Sep 2024 08:44:12 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-09-09T08:44:12Z</dc:date>
    <item>
      <title>Drawing polyLines</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Drawing-polyLines/m-p/75702#M8058</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;I'm getting the error APIERR_REFUSEDCMD (-2130312312) when I try to create a polyline. The code below is much simplified and with extra comments...Am I missing something?
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;void	DrawPoly(void){
	API_ElementMemo		memo;
	API_ElementMemo*	pMemo = &amp;amp;memo;
	API_Element			newPoly;
	API_Element*		pNewPoly = &amp;amp;newPoly;
	GSErrCode			err;

	BNZeroMemory(pNewPoly,sizeof(API_Element));
	BNZeroMemory(pMemo,sizeof(API_ElementMemo));

	pNewPoly-&amp;gt;header.typeID = API_PolyLineID;
	pNewPoly-&amp;gt;header.layer = 1;
	pNewPoly-&amp;gt;header.floorInd = 1;

	pNewPoly-&amp;gt;polyLine.poly.nArcs = 0;     //no arcs
	pNewPoly-&amp;gt;polyLine.poly.nSubPolys = 1; //no holes
	pNewPoly-&amp;gt;polyLine.poly.nCoords = 4;   //a closed triangle

	//allocate space for 3points + final point to close shape + space for storing max vertID = 5
	pMemo-&amp;gt;vertexIDs = (unsigned long **) BMAllocateHandle(sizeof(long) * (5), ALLOCATE_CLEAR, 0);
	(*pMemo-&amp;gt;vertexIDs)[0] = 3; //max vertexID

	//allocate space for pends. no holes, so the 4th vert is the only endpoint.
	pMemo-&amp;gt;pends = (long **) BMAllocateHandle(sizeof(long) * 2, ALLOCATE_CLEAR, 0);
	(*pMemo-&amp;gt;pends)[0] = 0; //required
	(*pMemo-&amp;gt;pends)[1] = 4; //4th vert closes the shape

	//allocate space for the coord array. 4 vertices + the dummy coord.
	pMemo-&amp;gt;coords = (API_Coord **) BMAllocateHandle(sizeof(API_Coord) * 5, ALLOCATE_CLEAR, 0);
	(*pMemo-&amp;gt;coords)[0].x = -1.0;  //polylines start with a "dummy" coord of -1,0
	(*pMemo-&amp;gt;coords)[0].y = 0.0;
	//setup complete....add vertices.

	//1st point: 1,1
	(*pMemo-&amp;gt;coords)[1].x = 1;
	(*pMemo-&amp;gt;coords)[1].y = 1;
	(*pMemo-&amp;gt;vertexIDs)[1] = 1;

	//2nd point: 2,1
	(*pMemo-&amp;gt;coords)[2].x = 2;
	(*pMemo-&amp;gt;coords)[2].y = 1;
	(*pMemo-&amp;gt;vertexIDs)[2] = 2;

	//3rd point: 1,2
	(*pMemo-&amp;gt;coords)[3].x = 1;
	(*pMemo-&amp;gt;coords)[3].y = 2;
	(*pMemo-&amp;gt;vertexIDs)[3] = 3;

	//4th point. Same as point 1.
	(*pMemo-&amp;gt;coords)[4].x = 1;
	(*pMemo-&amp;gt;coords)[4].y = 1;
	(*pMemo-&amp;gt;vertexIDs)[4] = 1;

	err = ACAPI_Element_Create(pNewPoly,pMemo);
	//handle return code...
	ACAPI_DisposeElemMemoHdls(pMemo);
}&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 09 Sep 2024 08:44:12 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Drawing-polyLines/m-p/75702#M8058</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-09T08:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing polyLines</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Drawing-polyLines/m-p/75703#M8059</link>
      <description>Found the problem, updating for posterity's sake. &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" style="display : inline;" /&gt;&lt;BR /&gt;
&lt;BR /&gt;
I was searching my computer for other mentions of that error. The function ACAPI_Element_Link mentioned that the error I got is caused (in that case) by not having an undoable session open. I had used the undoable session in a earlier version of my code, but left it out "temporarily" when I rewrote the function..... Apparently I corrected my other problem(s), just needed that undo session.</description>
      <pubDate>Tue, 03 May 2005 14:27:15 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Drawing-polyLines/m-p/75703#M8059</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-05-03T14:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing polyLines</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Drawing-polyLines/m-p/75704#M8060</link>
      <description>Hi Ramblin,&lt;BR /&gt;
thank you for your excellent code!&lt;BR /&gt;
Yours faithfully,&lt;BR /&gt;
Pal.</description>
      <pubDate>Mon, 14 Aug 2006 10:03:26 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Drawing-polyLines/m-p/75704#M8060</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-08-14T10:03:26Z</dc:date>
    </item>
  </channel>
</rss>

