<?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: API hide all layers in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152869#M6809</link>
    <description>Ben, I can't believe you didn't ask me first!</description>
    <pubDate>Wed, 06 Jan 2010 06:07:35 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2010-01-06T06:07:35Z</dc:date>
    <item>
      <title>API hide all layers</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152862#M6802</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Total C++ newbie here, but I am making slow progress.... I am loving the God like powers of the API, but the learning curve is massive. Currently I am stuck on the following...&lt;BR /&gt;I am trying to hide all layers in my addon (before turning specific layers on). Turning on specific layers has been fairly easy using the ACAPI_Attribute_Search function but creating a loop and hiding all layers so far is not working. Here is my code&lt;BR /&gt;&lt;BR /&gt;static void Do_HideLayers (void)&lt;BR /&gt;{&lt;BR /&gt;API_Attribute attrib;&lt;BR /&gt;short count, i;&lt;BR /&gt;GSErrCode err;&lt;BR /&gt;&lt;BR /&gt;err = ACAPI_Attribute_GetNum (API_LayerID, &amp;amp;count);&lt;BR /&gt;if (err) {&lt;BR /&gt;WriteReport_Err ("ACAPI_Attribute_GetNum", err);&lt;BR /&gt;return;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;for (i = 1; i &amp;lt;= count; i++) {&lt;BR /&gt;BNZeroMemory (&amp;amp;attrib, sizeof (API_Attribute));&lt;BR /&gt;attrib.header.typeID = API_LayerID;&lt;BR /&gt;attrib.header.index = i;&lt;BR /&gt;&lt;BR /&gt;attrib.layer.head.flags = APILay_Hidden;&lt;BR /&gt;&lt;BR /&gt;err = ACAPI_Attribute_Modify (&amp;amp;attrib, NULL);&lt;BR /&gt;if (err != NoError) {&lt;BR /&gt;WriteReport_Err ("Unable to modify the layer", err);&lt;BR /&gt;return;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;return;&lt;BR /&gt;} // Do_HideLayers&lt;BR /&gt;&lt;BR /&gt;I think the problem is in attrib.layer.head.flags but I cant work out what the problem is. Any help is much appreciated.&lt;/DIV&gt;</description>
      <pubDate>Thu, 03 Aug 2023 11:17:50 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152862#M6802</guid>
      <dc:creator>Ben Cohen</dc:creator>
      <dc:date>2023-08-03T11:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: API hide all layers</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152863#M6803</link>
      <description>hi ben,&lt;BR /&gt;
&lt;BR /&gt;
it is better and fast way if you create a layer combo "API_HideAllLayers" and set that combo.&lt;BR /&gt;
&lt;BR /&gt;
other wise try using fallowing way.&lt;BR /&gt;
&lt;BR /&gt;
static void Do_HideLayers (void) &lt;BR /&gt;
{ &lt;BR /&gt;
API_Attribute attrib; &lt;BR /&gt;
short count, i; &lt;BR /&gt;
GSErrCode err; &lt;BR /&gt;
&lt;BR /&gt;
err = ACAPI_Attribute_GetNum (API_LayerID, &amp;amp;count); &lt;BR /&gt;
if (err) { &lt;BR /&gt;
WriteReport_Err ("ACAPI_Attribute_GetNum", err); &lt;BR /&gt;
return; &lt;BR /&gt;
} &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
for (i = 2; i &amp;lt;= count; i++) //I starts from 2 because 1 is Archicad layer&lt;BR /&gt;
{ &lt;BR /&gt;
BNZeroMemory (&amp;amp;attrib, sizeof (API_Attribute)); &lt;BR /&gt;
attrib.header.typeID = API_LayerID; &lt;BR /&gt;
attrib.header.index = i; &lt;BR /&gt;
err = ACAPI_Attribute_Get(&amp;amp;attrib);&lt;BR /&gt;
if(!err &amp;amp;&amp;amp; attrib.later.head.flags != APILay_Hidden)&lt;BR /&gt;
{&lt;BR /&gt;
       attrib.layer.head.flags |= APILay_Hidden; // you should add ‘|’ because flags has another bit of information (APILay_Locked)&lt;BR /&gt;
&lt;BR /&gt;
       err = ACAPI_Attribute_Modify (&amp;amp;attrib, NULL); &lt;BR /&gt;
       if (err != NoError) { &lt;BR /&gt;
              WriteReport_Err ("Unable to modify the layer", err); &lt;BR /&gt;
              return; &lt;BR /&gt;
       } &lt;BR /&gt;
}&lt;BR /&gt;
} &lt;BR /&gt;
&lt;BR /&gt;
return; &lt;BR /&gt;
} // Do_HideLayers</description>
      <pubDate>Mon, 07 Dec 2009 06:33:06 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152863#M6803</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-12-07T06:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: API hide all layers</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152864#M6804</link>
      <description>Thanks for the quick reply Ranga&lt;BR /&gt;
&lt;BR /&gt;
I couldnt get your modified code to work, I still get the error.&lt;BR /&gt;
Your idea of creating a layer combo and then setting it, maybe a the way to go but there must be a way to set all layers to "hidden" fairly easily &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" style="display : inline;" /&gt;.</description>
      <pubDate>Mon, 07 Dec 2009 06:51:02 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152864#M6804</guid>
      <dc:creator>Ben Cohen</dc:creator>
      <dc:date>2009-12-07T06:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: API hide all layers</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152865#M6805</link>
      <description>&lt;BLOCKQUOTE&gt;Ben wrote:&lt;BR /&gt;creating a loop and hiding all layers so far is not working. &lt;/BLOCKQUOTE&gt;
You should first retrieve all the other attributes of the layer with &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;ACAPI_Attribute_Get&lt;E&gt;&lt;/E&gt; before you attempt to modify it. &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;ACAPI_Attribute_Modify&lt;E&gt;&lt;/E&gt; writes the entire attribute, so the entire data structure must be filled (otherwise, for example, it appears that you are trying to change the layer name to an empty string). Also, make sure you don't change the other layer status bits in the process:&lt;PRE&gt;attrib.layer.head.flags |= APILay_Hidden;&lt;/PRE&gt; not &lt;PRE&gt;attrib.layer.head.flags = APILay_Hidden;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Dec 2009 10:49:13 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152865#M6805</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2009-12-07T10:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: API hide all layers</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152866#M6806</link>
      <description>Thanks Ralph and Ranga&lt;BR /&gt;
&lt;BR /&gt;
I noticed before your post Ralph that the layer cleanup values had changed to 0, so changing the assignment to |= fixed that. I have now studied some more on bitset operators. &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_confused.gif" style="display : inline;" /&gt; &lt;BR /&gt;
I have since used Rangas suggestion of creating a layer combination to hide all the layers, then I just delete the layer combination once complete - the user will never know it existed. Seems a little backward but it gets the job done. (It would be nice to know what was wrong with the original code).&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your time  &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_biggrin.gif" style="display : inline;" /&gt;.</description>
      <pubDate>Mon, 07 Dec 2009 14:07:01 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152866#M6806</guid>
      <dc:creator>Ben Cohen</dc:creator>
      <dc:date>2009-12-07T14:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: API hide all layers</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152867#M6807</link>
      <description>&lt;BLOCKQUOTE&gt;Ben wrote:&lt;BR /&gt;It would be nice to know what was wrong with the original code&lt;/BLOCKQUOTE&gt;
The problem with the original code was not using ACAPI_Attribute_Get first.</description>
      <pubDate>Mon, 07 Dec 2009 14:37:51 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152867#M6807</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2009-12-07T14:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: API hide all layers</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152868#M6808</link>
      <description>Got it working. Cheers Ralph. You get my vote for "Forum Guy of the Year 2009".  I should start a poll!!&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Tue, 08 Dec 2009 00:24:32 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152868#M6808</guid>
      <dc:creator>Ben Cohen</dc:creator>
      <dc:date>2009-12-08T00:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: API hide all layers</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152869#M6809</link>
      <description>Ben, I can't believe you didn't ask me first!</description>
      <pubDate>Wed, 06 Jan 2010 06:07:35 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/API-hide-all-layers/m-p/152869#M6809</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-01-06T06:07:35Z</dc:date>
    </item>
  </channel>
</rss>

