<?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 How to select elements of a particular ElementID or Classification in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-select-elements-of-a-particular-ElementID-or/m-p/305505#M1733</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ACAPI_Element_GetElemList() allows selection of all elements of a particular type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do we select elements of a particular ElementID or Classification?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Sep 2021 06:28:44 GMT</pubDate>
    <dc:creator>dushyant</dc:creator>
    <dc:date>2021-09-14T06:28:44Z</dc:date>
    <item>
      <title>How to select elements of a particular ElementID or Classification</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-select-elements-of-a-particular-ElementID-or/m-p/305505#M1733</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ACAPI_Element_GetElemList() allows selection of all elements of a particular type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do we select elements of a particular ElementID or Classification?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 06:28:44 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-select-elements-of-a-particular-ElementID-or/m-p/305505#M1733</guid>
      <dc:creator>dushyant</dc:creator>
      <dc:date>2021-09-14T06:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to select elements of a particular ElementID or Classification</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-select-elements-of-a-particular-ElementID-or/m-p/305698#M1734</link>
      <description>&lt;P&gt;Hi dushyant,&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Element ID Property&lt;/STRONG&gt;&lt;BR /&gt;You mean the Element ID property right? Unfortunately in that case, I don't think there's a single command to do that. My approach would be to make a candidate list of element GUIDs and then filter the matching ones yourself by accessing the property value similar to this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;API_Property prop;
ACAPI_Element_GetPropertyValue (elemGuid, elemIdGuid, prop);

auto value = prop.value.singleVariant.variant.uniStringValue;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where "elemGuid" is the GUID of the current element to test and "elemIdGuid" is the GUID of the "Element ID" property itself. I think that property GUID never changes and even is the same for different AC installs, but I'm not 100% sure. That's why I wrote myself the following function which you are free to copy:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;GSErrCode GetElemIdPropertyGuid (API_Guid&amp;amp; elemIdGuid)
{
	GSErrCode err = NoError;

	// This is our initial guess.
	elemIdGuid = GSGuid2APIGuid (GS::Guid ("B1B54D45-C951-42C9-9AF8-898F0BF212AB"));

	API_PropertyDefinition elemIdPropDef;
	elemIdPropDef.guid = elemIdGuid;
	err = ACAPI_Property_GetPropertyDefinition (elemIdPropDef);
	if (err != NoError) { return err; }

    // We check if it gives us the correct property.
	if (elemIdPropDef.name == "Element ID") { return NoError; }
	// Otherwise we have to search for it
	GS::Array&amp;lt;API_PropertyGroup&amp;gt; groups;
	err = ACAPI_Property_GetPropertyGroups (groups);
	if (err != NoError) { return err; }

	for (GS::USize i = 0; i &amp;lt; groups.GetSize(); ++i) {
		if (groups[i].name == "ID and Categories") {
			GS::Array&amp;lt;API_PropertyDefinition&amp;gt; definitions;
			err = ACAPI_Property_GetPropertyDefinitions (groups[i].guid, definitions);
			if (err != NoError) { return err; }

			for (GS::USize j = 0; j &amp;lt; definitions.GetSize (); ++j) {
				if (definitions[j].name == "Element ID") {
					elemIdGuid = definitions[j].guid;
					return NoError;
				}
			}
		}
	}

	return APIERR_GENERAL;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;U&gt;&lt;STRONG&gt;Classification&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;I didn't manipulate classifications yet with the AC API so I can only give rough guesses from what I gathered from the documentation. It seems like the function &lt;A href="https://archicadapi.graphisoft.com/documentation/acapi_element_getelementswithclassification" target="_blank" rel="noopener"&gt;ACAPI_Element_GetElementsWithClassification&lt;/A&gt; might do exactly what you want. Again there's the problem of figuring out what the GUID of the classification item is. My first idea was to use &lt;A href="https://archicadapi.graphisoft.com/documentation/acapi_classification_getclassificationsystem" target="_blank" rel="noopener"&gt;ACAPI_Classification_GetClassificationSystem&lt;/A&gt; then &lt;A href="https://archicadapi.graphisoft.com/documentation/acapi_classification_getclassificationsystemrootitems" target="_blank" rel="noopener"&gt;ACAPI_Classification_GetClassificationSystemRootItems&lt;/A&gt; and recursively iterate on the child items &lt;A href="https://archicadapi.graphisoft.com/documentation/acapi_classification_getclassificationitemchildren" target="_blank" rel="noopener"&gt;ACAPI_Classification_GetClassificationItemChildren&lt;/A&gt; until you get the desired classification item. In case you find an easier way let us know &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Sep 2021 11:55:46 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-select-elements-of-a-particular-ElementID-or/m-p/305698#M1734</guid>
      <dc:creator>BerndSchwarzenbacher</dc:creator>
      <dc:date>2021-09-11T11:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to select elements of a particular ElementID or Classification</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-select-elements-of-a-particular-ElementID-or/m-p/305746#M1735</link>
      <description>&lt;P&gt;Hi Bernd,&lt;/P&gt;&lt;P&gt;Yes, I had been following the method of getting a set of elements and filter them based on the criteria. I was only curious if I there was any single command available to select elements using a classification-item ID or element ID, like ACAPI_Element_GetElemList() which takes an element-typeID (API_ElemTypeID) as the filter.&lt;/P&gt;&lt;P&gt;So looks like there isn't any.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for sharing that info!!&lt;/P&gt;</description>
      <pubDate>Sun, 12 Sep 2021 12:39:00 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-select-elements-of-a-particular-ElementID-or/m-p/305746#M1735</guid>
      <dc:creator>dushyant</dc:creator>
      <dc:date>2021-09-12T12:39:00Z</dc:date>
    </item>
  </channel>
</rss>

