<?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: Line Error in AddOn in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Line-Error-in-AddOn/m-p/262491#M2067</link>
    <description>Here's the code -- standard copied code.&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;
static GSErrCode MenuCommandHandler (const API_MenuParams *menuParams)
{
	GS::ErrCode err;
	return ACAPI_CallUndoableCommand("Element Test API Function",
		[&amp;amp;]() -&amp;gt; GSErrCode {

		switch (menuParams-&amp;gt;menuItemRef.menuResID) {
		case AddOnMenuID:
			switch (menuParams-&amp;gt;menuItemRef.itemIndex) {

			case 1:
			{
				err = Do_PlaceKeySymbol("part");
			}
			break;
			case 2:
			{
				Do_CreateLabel();
			}
			break;
			
			case 3:
			{
				Do_CreateLine(APINULLGuid);
			}
			break;
			default: break;
			}	
		}
		return err;
	});
}

&lt;/PRE&gt;

Note that the first function that just creates a library Part works OK.&lt;BR /&gt;
&lt;BR /&gt;
EDIT: I have no idea why this works but your comment caused me to look at the returns. I change the void returns to return a error code and all works now. Very strange because I copied the code one for one from Element_test???&lt;BR /&gt;
&lt;BR /&gt;
Thanks for the Help!! -- Again</description>
    <pubDate>Tue, 27 Apr 2021 10:40:12 GMT</pubDate>
    <dc:creator>poco2013</dc:creator>
    <dc:date>2021-04-27T10:40:12Z</dc:date>
    <item>
      <title>Line Error in AddOn</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Line-Error-in-AddOn/m-p/262489#M2065</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;I am trying to create a simple line in a new Add-On. I copied directly the line create function from the Element.Test Example. Create Line works Ok in Element test but will not work in my new addon -- yes - I did wrap it in the undoable command. my other function in the new addon works ok.&lt;BR /&gt;&lt;BR /&gt;Any thoughts?? Would appreciate some help or any suggestions?&lt;BR /&gt;&lt;BR /&gt;For anyone interested here is the video:&lt;BR /&gt;&lt;BR /&gt;&lt;IFRAME src="https://www.youtube.com/embed/-T1H64Oc1nw" width="640" height="360" frameborder="0" allowfullscreen="allowfullscreen" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"&gt;&lt;/IFRAME&gt;&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;void	Do_CreateLine(API_Guid guid)
	{
		API_Coord			c;
		API_GetLineType		clickInfo;
		API_Element			element;
		GSErrCode			err;

		// input the coordinates
		BNZeroMemory(&amp;amp;clickInfo, sizeof(API_GetLineType));
		if (!ClickAPoint("Click the line start point", &amp;amp;c))
			return;

		CHCopyC("Click the line end point", clickInfo.prompt);

		clickInfo.startCoord.x = c.x;
		clickInfo.startCoord.y = c.y;
		err = ACAPI_Interface(APIIo_GetLineID, &amp;amp;clickInfo, nullptr);
		if (err != NoError) {
			ErrorBeep("APIIo_GetLineID", err);
			return;
		}

		// real work
		BNZeroMemory(&amp;amp;element, sizeof(API_Element));
		element.header.typeID = API_LineID;
		ACAPI_Element_GetDefaults(&amp;amp;element, nullptr);
		if (err != NoError) {
			ErrorBeep("ACAPI_Element_GetDefaults (Line)", err);
			return;
		}

		element.header.renovationStatus = API_DemolishedStatus;
		element.line.begC.x = clickInfo.startCoord.x;
		element.line.begC.y = clickInfo.startCoord.y;
		element.line.endC.x = clickInfo.pos.x;
		element.line.endC.y = clickInfo.pos.y;
		err = ACAPI_Element_Create(&amp;amp;element, nullptr);
		if (err != NoError) {
			ErrorBeep("ACAPI_Element_Create (Line)", err);
			ACAPI_WriteReport("Create Error = %s", true, ErrID_To_Name(err));
			return;
		}
		else
			ACAPI_WriteReport("Create Success - %s", true, "No Error");
			
		

		ACAPI_WriteReport("GUID of the Line: %s", true, APIGuidToString(element.header.guid).ToCStr().Get());
		guid = element.header.guid;		// store it for later use

		ACAPI_KeepInMemory(true);

		return;
	}		// Do_CreateLine

&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Sep 2021 07:39:24 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Line-Error-in-AddOn/m-p/262489#M2065</guid>
      <dc:creator>poco2013</dc:creator>
      <dc:date>2021-09-14T07:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: Line Error in AddOn</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Line-Error-in-AddOn/m-p/262490#M2066</link>
      <description>It's strange. Could you please share the code where you wrap the function with &lt;B&gt;ACAPI_CallUndoableCommand&lt;/B&gt;?</description>
      <pubDate>Tue, 27 Apr 2021 07:05:11 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Line-Error-in-AddOn/m-p/262490#M2066</guid>
      <dc:creator>Viktor Kovacs</dc:creator>
      <dc:date>2021-04-27T07:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Line Error in AddOn</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Line-Error-in-AddOn/m-p/262491#M2067</link>
      <description>Here's the code -- standard copied code.&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;
static GSErrCode MenuCommandHandler (const API_MenuParams *menuParams)
{
	GS::ErrCode err;
	return ACAPI_CallUndoableCommand("Element Test API Function",
		[&amp;amp;]() -&amp;gt; GSErrCode {

		switch (menuParams-&amp;gt;menuItemRef.menuResID) {
		case AddOnMenuID:
			switch (menuParams-&amp;gt;menuItemRef.itemIndex) {

			case 1:
			{
				err = Do_PlaceKeySymbol("part");
			}
			break;
			case 2:
			{
				Do_CreateLabel();
			}
			break;
			
			case 3:
			{
				Do_CreateLine(APINULLGuid);
			}
			break;
			default: break;
			}	
		}
		return err;
	});
}

&lt;/PRE&gt;

Note that the first function that just creates a library Part works OK.&lt;BR /&gt;
&lt;BR /&gt;
EDIT: I have no idea why this works but your comment caused me to look at the returns. I change the void returns to return a error code and all works now. Very strange because I copied the code one for one from Element_test???&lt;BR /&gt;
&lt;BR /&gt;
Thanks for the Help!! -- Again</description>
      <pubDate>Tue, 27 Apr 2021 10:40:12 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Line-Error-in-AddOn/m-p/262491#M2067</guid>
      <dc:creator>poco2013</dc:creator>
      <dc:date>2021-04-27T10:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: Line Error in AddOn</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Line-Error-in-AddOn/m-p/262492#M2068</link>
      <description>It's because your err variable is not initialized, so it will contain some uninitialized value. If the ACAPI_CallUndoableCommand returns anything else than NoError, the whole operation will be aborted. I think this happened in your case.</description>
      <pubDate>Tue, 27 Apr 2021 14:18:36 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Line-Error-in-AddOn/m-p/262492#M2068</guid>
      <dc:creator>Viktor Kovacs</dc:creator>
      <dc:date>2021-04-27T14:18:36Z</dc:date>
    </item>
  </channel>
</rss>

