<?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 an window on wall using C++ code in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-an-window-on-wall-using-C-code/m-p/399859#M8718</link>
    <description>&lt;P&gt;Hi Team,&lt;BR /&gt;I was trying to create a wall and window using and Add-on. I was able to create a wall but when I added the code for window nothing got rendered.&lt;BR /&gt;I have added the code below&lt;BR /&gt;&amp;nbsp;archiCAD 25, IDE XCode&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;static GSErrCode CreateWallElement (double begX, double begY, double endX, double endY, API_Guid&amp;amp; placedWallGuid)
{
	GSErrCode err = NoError;

	API_Element wallElement = {};
	SetAPIElementType (wallElement, API_WallID);
	err = ACAPI_Element_GetDefaults (&amp;amp;wallElement, nullptr);
	if (err != NoError) {
		return err;
	}

	wallElement.wall.begC = { begX, begY };
	wallElement.wall.endC = { endX, endY };
	wallElement.wall.referenceLineLocation = APIWallRefLine_Center;
	err = ACAPI_Element_Create (&amp;amp;wallElement, nullptr);
	if (err != NoError) {
		return err;
	}

	placedWallGuid = wallElement.header.guid;
	return NoError;
}

static GSErrCode CreateWindowElement (double x, double y, API_Guid&amp;amp; placedWindowGuid, API_Guid&amp;amp; placedWallGuidLeft) {
    GSErrCode err = NoError;

    API_Element windowElement = {};
    SetAPIElementType (windowElement, API_WindowID);
    err = ACAPI_Element_GetDefaults (&amp;amp;windowElement, nullptr);
    if (err != NoError) {
        return err;
    }

    windowElement.window.startPoint.x = x;
    windowElement.window.startPoint.y = y;
    windowElement.window.openingBase.width = 0.3;
    windowElement.window.openingBase.height = 0.3;
    windowElement.window.jambDepth = 0.1;
    
    windowElement.window.owner = placedWallGuidLeft;
    
    err = ACAPI_Element_Create (&amp;amp;windowElement, nullptr);
    if (err != NoError) {
        return err;
    }

    placedWindowGuid = windowElement.header.guid;
    return NoError;
}

main function() {
    GS::Array&amp;lt;API_Guid&amp;gt; placedElementGuids;
    
    API_Guid placedWallGuidLeft;
    CreateWallElement (0, 0, 0, 10, placedWallGuidLeft);
    placedElementGuids.Push (placedWallGuidLeft);

    API_Guid placedWindowGuid;
    err = CreateWindowElement(10, 10, placedWindowGuid, placedWallGuidLeft);
    placedElementGuids.Push(placedWindowGuid);

    err = ElementGroup_Create (placedElementGuids);
    if (err != NoError) {
        return APIERR_CANCEL;
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Sep 2024 10:47:03 GMT</pubDate>
    <dc:creator>roni</dc:creator>
    <dc:date>2024-09-17T10:47:03Z</dc:date>
    <item>
      <title>Creating an window on wall using C++ code</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-an-window-on-wall-using-C-code/m-p/399859#M8718</link>
      <description>&lt;P&gt;Hi Team,&lt;BR /&gt;I was trying to create a wall and window using and Add-on. I was able to create a wall but when I added the code for window nothing got rendered.&lt;BR /&gt;I have added the code below&lt;BR /&gt;&amp;nbsp;archiCAD 25, IDE XCode&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;static GSErrCode CreateWallElement (double begX, double begY, double endX, double endY, API_Guid&amp;amp; placedWallGuid)
{
	GSErrCode err = NoError;

	API_Element wallElement = {};
	SetAPIElementType (wallElement, API_WallID);
	err = ACAPI_Element_GetDefaults (&amp;amp;wallElement, nullptr);
	if (err != NoError) {
		return err;
	}

	wallElement.wall.begC = { begX, begY };
	wallElement.wall.endC = { endX, endY };
	wallElement.wall.referenceLineLocation = APIWallRefLine_Center;
	err = ACAPI_Element_Create (&amp;amp;wallElement, nullptr);
	if (err != NoError) {
		return err;
	}

	placedWallGuid = wallElement.header.guid;
	return NoError;
}

static GSErrCode CreateWindowElement (double x, double y, API_Guid&amp;amp; placedWindowGuid, API_Guid&amp;amp; placedWallGuidLeft) {
    GSErrCode err = NoError;

    API_Element windowElement = {};
    SetAPIElementType (windowElement, API_WindowID);
    err = ACAPI_Element_GetDefaults (&amp;amp;windowElement, nullptr);
    if (err != NoError) {
        return err;
    }

    windowElement.window.startPoint.x = x;
    windowElement.window.startPoint.y = y;
    windowElement.window.openingBase.width = 0.3;
    windowElement.window.openingBase.height = 0.3;
    windowElement.window.jambDepth = 0.1;
    
    windowElement.window.owner = placedWallGuidLeft;
    
    err = ACAPI_Element_Create (&amp;amp;windowElement, nullptr);
    if (err != NoError) {
        return err;
    }

    placedWindowGuid = windowElement.header.guid;
    return NoError;
}

main function() {
    GS::Array&amp;lt;API_Guid&amp;gt; placedElementGuids;
    
    API_Guid placedWallGuidLeft;
    CreateWallElement (0, 0, 0, 10, placedWallGuidLeft);
    placedElementGuids.Push (placedWallGuidLeft);

    API_Guid placedWindowGuid;
    err = CreateWindowElement(10, 10, placedWindowGuid, placedWallGuidLeft);
    placedElementGuids.Push(placedWindowGuid);

    err = ElementGroup_Create (placedElementGuids);
    if (err != NoError) {
        return APIERR_CANCEL;
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 10:47:03 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-an-window-on-wall-using-C-code/m-p/399859#M8718</guid>
      <dc:creator>roni</dc:creator>
      <dc:date>2024-09-17T10:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Creating an window on wall using C++ code</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-an-window-on-wall-using-C-code/m-p/399902#M8719</link>
      <description>&lt;P&gt;HI Team,&lt;BR /&gt;Getting this error in debug console&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;err GS::GSErrCode -2130313112&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;This&amp;nbsp;&lt;A href="https://archicadapi.graphisoft.com/documentation/error-codes" target="_blank" rel="noopener"&gt;link&lt;/A&gt;&amp;nbsp;shows the error as&amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;The passed parameters are inconsistent.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;I am thinking some of the mandatory parameters was missing or not provided correctly, but the error message to general.&lt;BR /&gt;Any comments?&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 27 Sep 2023 11:36:42 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-an-window-on-wall-using-C-code/m-p/399902#M8719</guid>
      <dc:creator>roni</dc:creator>
      <dc:date>2023-09-27T11:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Creating an window on wall using C++ code</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-an-window-on-wall-using-C-code/m-p/570701#M8720</link>
      <description>&lt;P&gt;Hi Roni!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are missing the ElementMemo data structure. It's necessary for a lot of elements and especially for elements based on library parts. For such elements, it includes the values for the GDL-Object parameters. Here are some additional &amp;amp; adapted lines you'd need:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;API_ElementMemo windowMemo{};

// Disposes the handles at the end of the lifetime of 'memoDisposer'.
// So in this case when exiting the function.
GS::OnExit memoDisposer ([&amp;amp;windowMemo] {ACAPI_DisposeElemMemoHdls (&amp;amp;windowMemo); });

// ...

// Get memo from defaults here
err = ACAPI_Element_GetDefaults (&amp;amp;windowElement, &amp;amp;windowMemo);
if (err != NoError) { return err; }

// ...

// and use when creating the window here
err = ACAPI_Element_Create (&amp;amp;windowElement, &amp;amp;windowMemo);
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;Also next time please post this in the Archicad C++ API Subforum. I think all of us programmers missed it here ^^&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope that helps!&lt;/P&gt;
&lt;P&gt;Bernd&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 04:57:23 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-an-window-on-wall-using-C-code/m-p/570701#M8720</guid>
      <dc:creator>BerndSchwarzenbacher</dc:creator>
      <dc:date>2023-10-13T04:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating an window on wall using C++ code</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-an-window-on-wall-using-C-code/m-p/570883#M8721</link>
      <description>&lt;P&gt;Topic moved to proper forum.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Oct 2023 17:38:24 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-an-window-on-wall-using-C-code/m-p/570883#M8721</guid>
      <dc:creator>Laszlo Nagy</dc:creator>
      <dc:date>2023-10-15T17:38:24Z</dc:date>
    </item>
  </channel>
</rss>

