<?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: First add-on questions in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/First-add-on-questions/m-p/260924#M2311</link>
    <description>Thank you Ralph.</description>
    <pubDate>Tue, 14 Jul 2020 10:44:29 GMT</pubDate>
    <dc:creator>julienK</dc:creator>
    <dc:date>2020-07-14T10:44:29Z</dc:date>
    <item>
      <title>First add-on questions</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/First-add-on-questions/m-p/260922#M2309</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi, I’m trying to write my first add-on for Archicad and after a few days of going through the API and exemples I have to admit I’m going nowhere. I’ve been writing GDL objects for years and a few simple programs in C++ but writing full fledge Add-Ons seems to be a different kind of beast.&lt;BR /&gt;&lt;BR /&gt;What I’m trying to do:&lt;BR /&gt;&lt;BR /&gt;I have a residential building with n numbers of apartments. Each apartment has a set of zones for each room with the same zone number.&lt;BR /&gt;&lt;BR /&gt;I want to write an add-on that would create a label or textbox that displays the sum of the surfaces for each apartment, ie each group of zones with the same zone number and place it on the floor plan.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The workflow I’m looking for would be either:&lt;BR /&gt;&lt;BR /&gt;- having the user select the zones in the project manually and the add-on would then do it’s thing&lt;BR /&gt;&lt;BR /&gt;- have a popup menu to set some criteria (specify layer or zone category) click a button and let the add-on look for the zones and do its thing.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So far all I got to manage is create my menu and palette in archicad.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;My first questions:&lt;BR /&gt;&lt;BR /&gt;1. In the .grc file in the interface_Functions exemple in the API you have :&lt;BR /&gt;&lt;BR /&gt;'STR#' 32500 "Strings for the Menu" {&lt;BR /&gt;/* [ ] */ "Test"&lt;BR /&gt;/* [ ] */ "Interface Functions"&lt;BR /&gt;/* [ 1] */ "Open Control Palette^ES^EE^EI^E3^ED^EW^EL"&lt;BR /&gt;/* [ 2] */ "Show Palette^ES^EE^EI^G^ED^EW^EL" /* grayed by default */&lt;BR /&gt;/* [ 3] */ "-"&lt;BR /&gt;/* [ 4] */ "Get a Point^ES^EE^EI^E3^ED^EW^EL^R" /* repeatable command */&lt;BR /&gt;/* [ 5] */ "Get a Line^ES^EE^EI^E3^ED^EW^EL^R"&lt;BR /&gt;/* [ 6] */ "Get an Arc^ES^EE^EI^E3^ED^EW^EL^R"&lt;BR /&gt;&lt;BR /&gt;What is this part : ^ES^EE^EI^E3^ED^EW^EL ? I'm assuming it has something to do with the user inputs expected after the menu is clicked, is that correct ?&lt;BR /&gt;Is it explained in the API ? I couldn't fin anything about it.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;2. How do you interact with elements already placed in your project? &lt;BR /&gt;&lt;BR /&gt;Depending on the workflow described above, that means: &lt;BR /&gt;&lt;BR /&gt;- What function in the API let the user select some elements on the floor plan, or what is the general process to ask the user to select some elements&lt;BR /&gt;&lt;BR /&gt;- If I want to do that automatically, how does the Add-On can search through the project to find zones in it ?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you in advance for the answers.&lt;/DIV&gt;</description>
      <pubDate>Wed, 15 Sep 2021 09:57:54 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/First-add-on-questions/m-p/260922#M2309</guid>
      <dc:creator>julienK</dc:creator>
      <dc:date>2021-09-15T09:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: First add-on questions</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/First-add-on-questions/m-p/260923#M2310</link>
      <description>&lt;BLOCKQUOTE&gt;juliencuadra wrote:&lt;BR /&gt;What is this part  : 1. ^ES^EE^EI^E3^ED^EW^EL  ?&lt;/BLOCKQUOTE&gt;
Anything starting with ^ in a menu item is specifying a context in which that menu is relevant. For example, "^E3" means "enabled in 3D window". You can find documentation on this here: &lt;A href="http://archicadapi.graphisoft.com/documentation/required-resources" target="_blank"&gt;&lt;LINK_TEXT text="http://archicadapi.graphisoft.com/docum ... -resources"&gt;http://archicadapi.graphisoft.com/documentation/required-resources&lt;/LINK_TEXT&gt;&lt;/A&gt;&lt;BR /&gt;

&lt;BLOCKQUOTE&gt;juliencuadra wrote:&lt;BR /&gt;What is this part  : 1. 2. How do you interact with elements already placed in your project? &lt;BR /&gt;
- What  function in the API let the user select some elements on the floor plan, or what is the general process to ask the user to select some elements&lt;BR /&gt;
- If I want to do that automatically,  how does the Add-On can search through the project to find  zones in it ?
&lt;/BLOCKQUOTE&gt;
The best approach generally is for the user to select some elements first and then select a menu to perform some action on the selection. That's how most tools already work in Archicad.&lt;BR /&gt;
&lt;BR /&gt;
Part of the problem getting started is that most of the API is just plain C, or a bit of "C with classes" rather than C++. We've written a modern C++ wrapper, so we collect editable, selected zones from the floor plan like this:&lt;PRE&gt;auto selectedZones = plan.getSelection({Drawing::Filter::isEditable, Zone::ID});&lt;/PRE&gt;

GS' sample code for collecting elements is much more verbose: &lt;A href="http://archicadapi.graphisoft.com/documentation/acapi_selection_get" target="_blank"&gt;&lt;LINK_TEXT text="http://archicadapi.graphisoft.com/docum ... ection_get"&gt;http://archicadapi.graphisoft.com/documentation/acapi_selection_get&lt;/LINK_TEXT&gt;&lt;/A&gt;
&lt;PRE&gt;GS::Array&amp;lt;API_Guid&amp;gt;&amp;amp; inds
GSErrCode            err;
API_SelectionInfo    selectionInfo;
API_Elem_Head        tElemHead;
GS::Array&amp;lt;API_Neig&amp;gt;  selNeigs;
err = ACAPI_Selection_Get (&amp;amp;selectionInfo, &amp;amp;selNeigs, true);
BMKillHandle ((GSHandle *) &amp;amp;selectionInfo.marquee.coords);
if (err == APIERR_NOSEL)
    err = NoError;
if (selectionInfo.typeID != API_SelEmpty) {
    // collect indexes of selected dimensions
    UInt32 nSel = BMGetHandleSize ((GSHandle) selNeigs) / sizeof (API_Neig);
    for (const API_Neig&amp;amp; selNeig : selNeigs) {
        tElemHead.typeID = Neig_To_ElemID (selNeig.neigID);
        if (tElemHead.typeID != API_DimensionID)
            continue;
        if (!ACAPI_Element_Filter (selNeig.guid, APIFilt_IsEditable))
            continue;
        tElemHead.guid = selNeig.guid;
        if (ACAPI_Element_GetHeader (&amp;amp;tElemHead) != NoError)
            continue;

        // Add dimension to the array
        inds.Push (tElemHead.guid);
    }
}&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Jul 2020 10:04:53 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/First-add-on-questions/m-p/260923#M2310</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2020-07-14T10:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: First add-on questions</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/First-add-on-questions/m-p/260924#M2311</link>
      <description>Thank you Ralph.</description>
      <pubDate>Tue, 14 Jul 2020 10:44:29 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/First-add-on-questions/m-p/260924#M2311</guid>
      <dc:creator>julienK</dc:creator>
      <dc:date>2020-07-14T10:44:29Z</dc:date>
    </item>
  </channel>
</rss>

