<?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 Attribute index in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Attribute-index/m-p/287145#M3617</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;I am trying to obtain the attribute index (Font) by typeID and name in the attribute header. ACAPI_Attribute_Search(...)&lt;BR /&gt;&lt;BR /&gt;Can't figure out the code to set the name -- my 'C' is not so good.&lt;BR /&gt;&lt;BR /&gt;The name can be set either by the attribute name[API_AttrNameLen] or *uniStringNamePtr;&lt;BR /&gt;&lt;BR /&gt;What is the line code to set either --- attr.name = "Courier New" does not work nor attr.uniStringNamePtr = &amp;amp;uniString&lt;BR /&gt;&lt;BR /&gt;pardon my ignorance of 'C'&lt;/DIV&gt;</description>
    <pubDate>Tue, 04 Oct 2022 14:36:40 GMT</pubDate>
    <dc:creator>poco2013</dc:creator>
    <dc:date>2022-10-04T14:36:40Z</dc:date>
    <item>
      <title>Attribute index</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Attribute-index/m-p/287145#M3617</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;I am trying to obtain the attribute index (Font) by typeID and name in the attribute header. ACAPI_Attribute_Search(...)&lt;BR /&gt;&lt;BR /&gt;Can't figure out the code to set the name -- my 'C' is not so good.&lt;BR /&gt;&lt;BR /&gt;The name can be set either by the attribute name[API_AttrNameLen] or *uniStringNamePtr;&lt;BR /&gt;&lt;BR /&gt;What is the line code to set either --- attr.name = "Courier New" does not work nor attr.uniStringNamePtr = &amp;amp;uniString&lt;BR /&gt;&lt;BR /&gt;pardon my ignorance of 'C'&lt;/DIV&gt;</description>
      <pubDate>Tue, 04 Oct 2022 14:36:40 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Attribute-index/m-p/287145#M3617</guid>
      <dc:creator>poco2013</dc:creator>
      <dc:date>2022-10-04T14:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute index</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Attribute-index/m-p/287146#M3618</link>
      <description>Here is an example for you (copied from Attribute_Test.cpp, part of the Attribute_Test example Add-On):
&lt;PRE&gt;API_Attribute	attrib;
GSErrCode	err;

BNZeroMemory (&amp;amp;attrib, sizeof (API_Attribute));
attrib.header.typeID = API_LayerID;
strcpy (attrib.header.name, "2D Drafting - General");

err = ACAPI_Attribute_Search (&amp;amp;attrib.header);		/* search by name: index returned in header */
if (err != NoError) {
	WriteReport_Err ("Layer \"2D Drafting - General\" was not found", err);
	return;
}&lt;/PRE&gt;

&lt;BR /&gt;
But if you already have the name in a GS::UniString object, then I recommend you to search by using the uniStringNamePtr member:
&lt;PRE&gt;short GetAttributeIndex (const API_AttrTypeID typeID, const GS::UniString&amp;amp; attributeName)
{
	API_Attribute	attrib;
	GSErrCode	err;

	BNZeroMemory (&amp;amp;attrib, sizeof (API_Attribute));
	attrib.header.typeID = typeID;
	attrib.header.uniStringNamePtr = &amp;amp;attributeName;

	err = ACAPI_Attribute_Search (&amp;amp;attrib.header);		/* search by unistring name: index returned in header */
	if (err != NoError)
		return -1;
	return attrib.header.index;
}

// You can simply call this function:
GetAttributeIndex (API_LayerID, "2D Drafting - General");&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Feb 2019 09:10:29 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Attribute-index/m-p/287146#M3618</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2019-02-22T09:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute index</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Attribute-index/m-p/287147#M3619</link>
      <description>There is some nice example code bundled with the API that can be really when the documentation isn't completely clear. In this case, there is an example for &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_Search&lt;E&gt;&lt;/E&gt; in the Attribute_Test project:
&lt;PRE&gt;API_Attribute	attrib;
GSErrCode			err;

BNZeroMemory (&amp;amp;attrib, sizeof (API_Attribute));
attrib.header.typeID = API_LayerID;
strcpy (attrib.header.name, "2D Drafting - General");

err = ACAPI_Attribute_Search (&amp;amp;attrib.header);		/* search by name: index returned in header  &lt;/PRE&gt;
This particular case is looking up a layer, but the same principle applies for any attribute type.&lt;BR /&gt;
&lt;BR /&gt;
Edit: I see Tibor beat me to it  &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" style="display : inline;" /&gt;</description>
      <pubDate>Fri, 22 Feb 2019 09:29:22 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Attribute-index/m-p/287147#M3619</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2019-02-22T09:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute index</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Attribute-index/m-p/287148#M3620</link>
      <description>Thanks Ralph --That's what I thought -- But I was having trouble with the compiler. Tried it again this morning and all worked OK. Don't know what combination I must of been using late,late last night, but probably old eyes and bad fingers ?&lt;BR /&gt;
&lt;BR /&gt;
Thanks again and I will compile and look at the attribute example.</description>
      <pubDate>Fri, 22 Feb 2019 14:11:10 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Attribute-index/m-p/287148#M3620</guid>
      <dc:creator>poco2013</dc:creator>
      <dc:date>2019-02-22T14:11:10Z</dc:date>
    </item>
  </channel>
</rss>

