<?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: ACAPI_Element_Change Issue in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-Change-Issue/m-p/384855#M899</link>
    <description>&lt;P&gt;hello&lt;/P&gt;&lt;P&gt;without context it's hard to tell you, what's the problem, share more from the code but the ACAPI_Element_Create should look like this:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;	GSErrCode			err = NoError;

	// element
	API_Element			element;
	API_ElementMemo		memo;
	Int32				addParNum;
	API_AddParType**	addPars = nullptr;

	// libPart
	API_LibPart			libPart;
	double				a, b;
	Int32				nSystem;

	BNZeroMemory(&amp;amp;element, sizeof(API_Element));
	BNZeroMemory(&amp;amp;memo, sizeof(API_ElementMemo));

	element.header.type = API_ObjectID;

	err = ACAPI_Element_GetDefaults(&amp;amp;element, &amp;amp;memo);
	if (err != NoError)
	{
		ACAPI_DisposeElemMemoHdls(&amp;amp;memo);
		return err;
	}
	ACAPI_DisposeAddParHdl(&amp;amp;(memo.params));	// worth erase it
	memo.params = nullptr;

	// LibPart machinations
	BNClear(libPart);
	CHCopyC(objUNID, libPart.ownUnID);

	err = ACAPI_LibPart_Search(&amp;amp;libPart, false, false);
	if (libPart.location != nullptr)
		delete libPart.location;

	if (libPart.index == 0)
	{
		ACAPI_WriteReport("text", true);		// GDL object not found! Please add them in Library Manager.
		ACAPI_DisposeElemMemoHdls(&amp;amp;memo);
		return err;
	}

	err = ACAPI_LibPart_GetParams(libPart.index, &amp;amp;a, &amp;amp;b, &amp;amp;addParNum, &amp;amp;addPars);
	if (err != NoError)
	{
		ACAPI_WriteReport("ACAPI_LibPart_GetParams[%ld]", false, err);
		return err;
	}

	// set basic parameters
	memo.params = addPars;
	element.object.libInd = libPart.index;
	element.object.angle = 0.0;
	element.object.level = 0.0;
	element.object.xRatio = 1.0;
	element.object.yRatio = 1.0;

	// for loop for change parameters
	for (Int32 ii = 0; ii &amp;lt; addParNum; ii++)
	{
		// change something in memo
		if (CHEqualCStrings((*memo.params)[ii].name, "someParameter"))
		{
			((*memo.params)[ii].value.real) = 5.0;

		}
	} // for loop for change parameters ends

	// place something, .gsm in my case
	err = ACAPI_CallUndoableCommand("some text", [&amp;amp;]() -&amp;gt; GSErrCode	
		{
			err = ACAPI_Element_Create(&amp;amp;element, &amp;amp;memo);
			if (err != NoError)
			{
				return err;
			}

			err = ACAPI_Goodies(APIAny_RunGDLParScriptID, &amp;amp;element.header);
			return err;
		});
	if (err != NoError)
	{
		ACAPI_WriteReport("ACAPI_Element_Create failed", true);
		return err;
	}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jun 2023 07:21:49 GMT</pubDate>
    <dc:creator>Csanyi Bence</dc:creator>
    <dc:date>2023-06-22T07:21:49Z</dc:date>
    <item>
      <title>ACAPI_Element_Change Issue</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-Change-Issue/m-p/384186#M897</link>
      <description>&lt;P&gt;Hello everyone, I have encountered a very strange problem. I have two Archicad Pln files, the contents of which are the same except for a few object parameters. But when I change some object parameters, and call ACAPI_Element_Change at the end, one of the files can succeed, and the other file will always report an error at ACAPI_Element_Change? Does anyone know what the possible cause is and what are the key points when using API Element Change?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="4livesdragon_0-1687137492655.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/39133iEB926D46D635E5A2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="4livesdragon_0-1687137492655.png" alt="4livesdragon_0-1687137492655.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2023 01:18:34 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-Change-Issue/m-p/384186#M897</guid>
      <dc:creator>4livesdragon</dc:creator>
      <dc:date>2023-06-19T01:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: ACAPI_Element_Change Issue</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-Change-Issue/m-p/384199#M898</link>
      <description>&lt;P&gt;I think I found a possible reason. I found that in the unsuccessful file, ACAPI_Element_Create was not successfully called, nor did any errors occur, but after being called, no object was created. I wonder what are the conditions for ACAPI_Element_Create to be used successfully?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2023 02:09:33 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-Change-Issue/m-p/384199#M898</guid>
      <dc:creator>4livesdragon</dc:creator>
      <dc:date>2023-06-19T02:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: ACAPI_Element_Change Issue</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-Change-Issue/m-p/384855#M899</link>
      <description>&lt;P&gt;hello&lt;/P&gt;&lt;P&gt;without context it's hard to tell you, what's the problem, share more from the code but the ACAPI_Element_Create should look like this:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;	GSErrCode			err = NoError;

	// element
	API_Element			element;
	API_ElementMemo		memo;
	Int32				addParNum;
	API_AddParType**	addPars = nullptr;

	// libPart
	API_LibPart			libPart;
	double				a, b;
	Int32				nSystem;

	BNZeroMemory(&amp;amp;element, sizeof(API_Element));
	BNZeroMemory(&amp;amp;memo, sizeof(API_ElementMemo));

	element.header.type = API_ObjectID;

	err = ACAPI_Element_GetDefaults(&amp;amp;element, &amp;amp;memo);
	if (err != NoError)
	{
		ACAPI_DisposeElemMemoHdls(&amp;amp;memo);
		return err;
	}
	ACAPI_DisposeAddParHdl(&amp;amp;(memo.params));	// worth erase it
	memo.params = nullptr;

	// LibPart machinations
	BNClear(libPart);
	CHCopyC(objUNID, libPart.ownUnID);

	err = ACAPI_LibPart_Search(&amp;amp;libPart, false, false);
	if (libPart.location != nullptr)
		delete libPart.location;

	if (libPart.index == 0)
	{
		ACAPI_WriteReport("text", true);		// GDL object not found! Please add them in Library Manager.
		ACAPI_DisposeElemMemoHdls(&amp;amp;memo);
		return err;
	}

	err = ACAPI_LibPart_GetParams(libPart.index, &amp;amp;a, &amp;amp;b, &amp;amp;addParNum, &amp;amp;addPars);
	if (err != NoError)
	{
		ACAPI_WriteReport("ACAPI_LibPart_GetParams[%ld]", false, err);
		return err;
	}

	// set basic parameters
	memo.params = addPars;
	element.object.libInd = libPart.index;
	element.object.angle = 0.0;
	element.object.level = 0.0;
	element.object.xRatio = 1.0;
	element.object.yRatio = 1.0;

	// for loop for change parameters
	for (Int32 ii = 0; ii &amp;lt; addParNum; ii++)
	{
		// change something in memo
		if (CHEqualCStrings((*memo.params)[ii].name, "someParameter"))
		{
			((*memo.params)[ii].value.real) = 5.0;

		}
	} // for loop for change parameters ends

	// place something, .gsm in my case
	err = ACAPI_CallUndoableCommand("some text", [&amp;amp;]() -&amp;gt; GSErrCode	
		{
			err = ACAPI_Element_Create(&amp;amp;element, &amp;amp;memo);
			if (err != NoError)
			{
				return err;
			}

			err = ACAPI_Goodies(APIAny_RunGDLParScriptID, &amp;amp;element.header);
			return err;
		});
	if (err != NoError)
	{
		ACAPI_WriteReport("ACAPI_Element_Create failed", true);
		return err;
	}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 07:21:49 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-Change-Issue/m-p/384855#M899</guid>
      <dc:creator>Csanyi Bence</dc:creator>
      <dc:date>2023-06-22T07:21:49Z</dc:date>
    </item>
  </channel>
</rss>

