<?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 Can Archicad Api control  visibility of one Element? in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Can-Archicad-Api-control-visibility-of-one-Element/m-p/270986#M3228</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;Hi.&lt;BR /&gt;Is there any method to control the visibility of one element by Archicad Api？&lt;/DIV&gt;</description>
    <pubDate>Thu, 29 Sep 2022 07:59:01 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-09-29T07:59:01Z</dc:date>
    <item>
      <title>Can Archicad Api control  visibility of one Element?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Can-Archicad-Api-control-visibility-of-one-Element/m-p/270986#M3228</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi.&lt;BR /&gt;Is there any method to control the visibility of one element by Archicad Api？&lt;/DIV&gt;</description>
      <pubDate>Thu, 29 Sep 2022 07:59:01 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Can-Archicad-Api-control-visibility-of-one-Element/m-p/270986#M3228</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-29T07:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: Can ArchiCad Api control  visibility of one Element?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Can-Archicad-Api-control-visibility-of-one-Element/m-p/270987#M3229</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Yes.&lt;BR /&gt;
For example if you move the element to an invisible layer, that way the element will become invisible. If your element is on an invisible layer, then you can move it to a visible layer to make the element visible also:
&lt;PRE&gt;GS::Array&amp;lt;API_Guid&amp;gt; walls;
ACAPI_Element_GetElemList (API_WallID, &amp;amp;walls);

const API_AttributeIndex hiddenLayerIndex = GetIndexOfHiddenNotLockedLayer ();

if (walls.GetSize () &amp;gt; 0 &amp;amp;&amp;amp; hiddenLayerIndex &amp;gt; 0) {
	ACAPI_CallUndoableCommand (GS::UniString ("Move walls to an invisible layer"), [&amp;amp;] () -&amp;gt; GSErrCode {
		API_Element newParameters = {};
		API_Element newParametersMask = {};

		newParameters.header.layer = hiddenLayerIndex;
		ACAPI_ELEMENT_MASK_SET (newParametersMask, API_Elem_Head, layer);

		return ACAPI_Element_ChangeMore (walls, &amp;amp;newParameters, nullptr, &amp;amp;newParametersMask, 0, true);
	});
}

//------------------------------------------------------

static API_AttributeIndex GetIndexOfHiddenNotLockedLayer ()
{
	API_AttributeIndex	count;
	ACAPI_Attribute_GetNum (API_LayerID, &amp;amp;count);

	for (API_AttributeIndex ii = 1; ii &amp;lt;= count; ++ii) {
		API_Attribute attr = {};
		attr.header.typeID = API_LayerID;
		attr.header.index = ii;
		if (ACAPI_Attribute_Get (&amp;amp;attr) == NoError) {
			const bool isHidden = (attr.layer.head.flags &amp;amp; APILay_Hidden) != 0;
			const bool isLocked = (attr.layer.head.flags &amp;amp; APILay_Locked) != 0;
			if (isHidden &amp;amp;&amp;amp; !isLocked)
				return attr.header.index;
		}
	}

	return -1;
}&lt;/PRE&gt;

Please note, that if you want to highlight elements in 3D, then you can use APIIo_HighlightElementsID method. That function highlights the given elements with the given color and the other (non-highlighted) elements can be switched to wireframed mode:
&lt;PRE&gt;GS::Array&amp;lt;API_Guid&amp;gt; walls;
ACAPI_Element_GetElemList (API_WallID, &amp;amp;walls);

if (walls.GetSize () &amp;gt; 0) {
	GS::HashTable&amp;lt;API_Guid, API_RGBAColor&amp;gt;	highlightedElements;
	API_RGBAColor	highlightColor = { 0.0, 0.5, 0.75, 0.5 };
	for (const API_Guid&amp;amp; wallGuid : walls) {
		highlightedElements.Add (wallGuid, highlightColor);
		highlightColor.f_red += 0.2;
		if (highlightColor.f_red &amp;gt; 1.0)
			highlightColor.f_red = 0.0;
	}

	bool showNotHighlightedElementsWithWireframe = true;
	ACAPI_Interface (APIIo_HighlightElementsID, &amp;amp;highlightedElements, &amp;amp;showNotHighlightedElementsWithWireframe);
}&lt;/PRE&gt;

You can switch off the highlight with the following line:
&lt;PRE&gt;ACAPI_Interface (APIIo_HighlightElementsID);&lt;/PRE&gt;

Regards,&lt;BR /&gt;
Tibor</description>
      <pubDate>Tue, 12 Nov 2019 15:58:38 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Can-Archicad-Api-control-visibility-of-one-Element/m-p/270987#M3229</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2019-11-12T15:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can ArchiCad Api control  visibility of one Element?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Can-Archicad-Api-control-visibility-of-one-Element/m-p/270988#M3230</link>
      <description>&lt;BLOCKQUOTE&gt;Tibor wrote:&lt;BR /&gt;
Hi,&lt;BR /&gt;
&lt;BR /&gt;
Yes.&lt;BR /&gt;
For example if you move the element to an invisible layer, that way the element will become invisible. If your element is on an invisible layer, then you can move it to a visible layer to make the element visible also:
&lt;PRE&gt;GS::Array&amp;lt;API_Guid&amp;gt; walls;
ACAPI_Element_GetElemList (API_WallID, &amp;amp;walls);

const API_AttributeIndex hiddenLayerIndex = GetIndexOfHiddenNotLockedLayer ();

if (walls.GetSize () &amp;gt; 0 &amp;amp;&amp;amp; hiddenLayerIndex &amp;gt; 0) {
	ACAPI_CallUndoableCommand (GS::UniString ("Move walls to an invisible layer"), [&amp;amp;] () -&amp;gt; GSErrCode {
		API_Element newParameters = {};
		API_Element newParametersMask = {};

		newParameters.header.layer = hiddenLayerIndex;
		ACAPI_ELEMENT_MASK_SET (newParametersMask, API_Elem_Head, layer);

		return ACAPI_Element_ChangeMore (walls, &amp;amp;newParameters, nullptr, &amp;amp;newParametersMask, 0, true);
	});
}

//------------------------------------------------------

static API_AttributeIndex GetIndexOfHiddenNotLockedLayer ()
{
	API_AttributeIndex	count;
	ACAPI_Attribute_GetNum (API_LayerID, &amp;amp;count);

	for (API_AttributeIndex ii = 1; ii &amp;lt;= count; ++ii) {
		API_Attribute attr = {};
		attr.header.typeID = API_LayerID;
		attr.header.index = ii;
		if (ACAPI_Attribute_Get (&amp;amp;attr) == NoError) {
			const bool isHidden = (attr.layer.head.flags &amp;amp; APILay_Hidden) != 0;
			const bool isLocked = (attr.layer.head.flags &amp;amp; APILay_Locked) != 0;
			if (isHidden &amp;amp;&amp;amp; !isLocked)
				return attr.header.index;
		}
	}

	return -1;
}&lt;/PRE&gt;

Please note, that if you want to highlight elements in 3D, then you can use APIIo_HighlightElementsID method. That function highlights the given elements with the given color and the other (non-highlighted) elements can be switched to wireframed mode:
&lt;PRE&gt;GS::Array&amp;lt;API_Guid&amp;gt; walls;
ACAPI_Element_GetElemList (API_WallID, &amp;amp;walls);

if (walls.GetSize () &amp;gt; 0) {
	GS::HashTable&amp;lt;API_Guid, API_RGBAColor&amp;gt;	highlightedElements;
	API_RGBAColor	highlightColor = { 0.0, 0.5, 0.75, 0.5 };
	for (const API_Guid&amp;amp; wallGuid : walls) {
		highlightedElements.Add (wallGuid, highlightColor);
		highlightColor.f_red += 0.2;
		if (highlightColor.f_red &amp;gt; 1.0)
			highlightColor.f_red = 0.0;
	}

	bool showNotHighlightedElementsWithWireframe = true;
	ACAPI_Interface (APIIo_HighlightElementsID, &amp;amp;highlightedElements, &amp;amp;showNotHighlightedElementsWithWireframe);
}&lt;/PRE&gt;

You can switch off the highlight with the following line:
&lt;PRE&gt;ACAPI_Interface (APIIo_HighlightElementsID);&lt;/PRE&gt;

Regards,&lt;BR /&gt;
Tibor
&lt;/BLOCKQUOTE&gt;

Thank you very much.</description>
      <pubDate>Thu, 14 Nov 2019 03:41:09 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Can-Archicad-Api-control-visibility-of-one-Element/m-p/270988#M3230</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-14T03:41:09Z</dc:date>
    </item>
  </channel>
</rss>

