<?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: Getting list materials used in project missed a few &amp;amp in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Getting-list-materials-used-in-project-missed-a-few-quot-GDLM/m-p/254277#M4007</link>
    <description>&lt;BLOCKQUOTE&gt;Ralph wrote:&lt;BR /&gt;&lt;BLOCKQUOTE&gt;IanTr wrote:&lt;BR /&gt;
I'm trying to get a list of all materials used in the project. The following code catches most materials, however there seems to be some type of material which isn't caught [...]	&lt;BR /&gt;
Is there a way for me to get all the materials including GDLM materials without looping through all the meshes?&lt;/BLOCKQUOTE&gt;
I think the origin of the problem is the dynamic nature of these materials. They're defined by scripts, so are subject to sudden change from one view to another.&lt;BR /&gt;
&lt;BR /&gt;
There is a way you may be able to us the ModelerAPI to avoid iterating through the entire model, but I haven't tried it myself. If you have an instance of a &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;Model&lt;E&gt;&lt;/E&gt; object, you can find the highest material index by calling its &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;GetMaterialNum&lt;E&gt;&lt;/E&gt; method. You could iterator through every value from 1 to this value calling the &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;GetMaterial&lt;E&gt;&lt;/E&gt; method, but I doubt you could assume that every index would return a valid (current) material. Worth a try though – someone from GS might be able to confirm.&lt;/BLOCKQUOTE&gt;

Ralph is right, you can get the materials defined in GDL scripts that way, and right again that not all indexes are valid.&lt;BR /&gt;
&lt;BR /&gt;
So going through the 3D materials is an option; here are a few 'buts':&lt;BR /&gt;
- materials used in element default settings (do you consider these 'used' materials?)&lt;BR /&gt;
- materials which depend on conditions in GDL scripts, view settings etc.&lt;BR /&gt;
&lt;BR /&gt;
Best, Ákos</description>
    <pubDate>Fri, 05 Jan 2018 13:11:46 GMT</pubDate>
    <dc:creator>Akos Somorjai</dc:creator>
    <dc:date>2018-01-05T13:11:46Z</dc:date>
    <item>
      <title>Getting list materials used in project missed a few "GDLM"</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Getting-list-materials-used-in-project-missed-a-few-quot-GDLM/m-p/254275#M4005</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I'm trying to get a list of all materials used in the project. The following code catches most materials, however there seems to be some type of material which isn't caught:&lt;BR /&gt;
&lt;PRE&gt;short nMaterials = 0;
ACAPI_Attribute_GetNum (API_MaterialID, &amp;amp;nMaterials);

for ( short i = 1; i &amp;lt;= nMaterials; i++ )
{
		BNZeroMemory( &amp;amp;attrib, sizeof ( API_Attribute ) );
		attrib.header.typeID = API_MaterialID;
		attrib.header.index = i;
		GSErrCode err2 = ACAPI_Attribute_Get( &amp;amp;attrib );
		...
}&lt;/PRE&gt;
The materials which aren't caught begin with "GDLM", for example: GDLM33_builtInMatAppleTop. They are only found when iterating through the meshes like this:&lt;BR /&gt;
&lt;PRE&gt;	...
	BNZeroMemory ( &amp;amp;component, sizeof ( component ) );
	component.header.typeID = API_BodyID;
	component.header.index  = ibody;
	err = ACAPI_3D_GetComponent (&amp;amp;component);
	
	API_Component3D material;
	BNZeroMemory ( &amp;amp;material, sizeof ( material ) );
	material.header.typeID = API_UmatID;
	material.header.index  = (GS::Int32)component.body.iumat;

	GS::UniString uniStringName;
	material.umat.mater.head.uniStringNamePtr = &amp;amp;uniStringName;

	GSErrCode err = ACAPI_3D_GetComponent ( &amp;amp;material );
	if ( err == NoError )
	{
	...									//
	}&lt;/PRE&gt;
&lt;BR /&gt;Is there a way for me to get all the materials including GDLM materials without looping through all the meshes?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Ian&lt;/DIV&gt;</description>
      <pubDate>Tue, 06 Dec 2022 12:47:09 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Getting-list-materials-used-in-project-missed-a-few-quot-GDLM/m-p/254275#M4005</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-06T12:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Getting list materials used in project missed a few &amp;quo</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Getting-list-materials-used-in-project-missed-a-few-quot-GDLM/m-p/254276#M4006</link>
      <description>&lt;BLOCKQUOTE&gt;IanTr wrote:&lt;BR /&gt;
I'm trying to get a list of all materials used in the project. The following code catches most materials, however there seems to be some type of material which isn't caught [...]	&lt;BR /&gt;
Is there a way for me to get all the materials including GDLM materials without looping through all the meshes?&lt;/BLOCKQUOTE&gt;
I think the origin of the problem is the dynamic nature of these materials. They're defined by scripts, so are subject to sudden change from one view to another.&lt;BR /&gt;
&lt;BR /&gt;
There is a way you may be able to us the ModelerAPI to avoid iterating through the entire model, but I haven't tried it myself. If you have an instance of a &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;Model&lt;E&gt;&lt;/E&gt; object, you can find the highest material index by calling its &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;GetMaterialNum&lt;E&gt;&lt;/E&gt; method. You could iterator through every value from 1 to this value calling the &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;GetMaterial&lt;E&gt;&lt;/E&gt; method, but I doubt you could assume that every index would return a valid (current) material. Worth a try though – someone from GS might be able to confirm.</description>
      <pubDate>Thu, 21 Dec 2017 14:47:29 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Getting-list-materials-used-in-project-missed-a-few-quot-GDLM/m-p/254276#M4006</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2017-12-21T14:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: Getting list materials used in project missed a few &amp;amp</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Getting-list-materials-used-in-project-missed-a-few-quot-GDLM/m-p/254277#M4007</link>
      <description>&lt;BLOCKQUOTE&gt;Ralph wrote:&lt;BR /&gt;&lt;BLOCKQUOTE&gt;IanTr wrote:&lt;BR /&gt;
I'm trying to get a list of all materials used in the project. The following code catches most materials, however there seems to be some type of material which isn't caught [...]	&lt;BR /&gt;
Is there a way for me to get all the materials including GDLM materials without looping through all the meshes?&lt;/BLOCKQUOTE&gt;
I think the origin of the problem is the dynamic nature of these materials. They're defined by scripts, so are subject to sudden change from one view to another.&lt;BR /&gt;
&lt;BR /&gt;
There is a way you may be able to us the ModelerAPI to avoid iterating through the entire model, but I haven't tried it myself. If you have an instance of a &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;Model&lt;E&gt;&lt;/E&gt; object, you can find the highest material index by calling its &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;GetMaterialNum&lt;E&gt;&lt;/E&gt; method. You could iterator through every value from 1 to this value calling the &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;GetMaterial&lt;E&gt;&lt;/E&gt; method, but I doubt you could assume that every index would return a valid (current) material. Worth a try though – someone from GS might be able to confirm.&lt;/BLOCKQUOTE&gt;

Ralph is right, you can get the materials defined in GDL scripts that way, and right again that not all indexes are valid.&lt;BR /&gt;
&lt;BR /&gt;
So going through the 3D materials is an option; here are a few 'buts':&lt;BR /&gt;
- materials used in element default settings (do you consider these 'used' materials?)&lt;BR /&gt;
- materials which depend on conditions in GDL scripts, view settings etc.&lt;BR /&gt;
&lt;BR /&gt;
Best, Ákos</description>
      <pubDate>Fri, 05 Jan 2018 13:11:46 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Getting-list-materials-used-in-project-missed-a-few-quot-GDLM/m-p/254277#M4007</guid>
      <dc:creator>Akos Somorjai</dc:creator>
      <dc:date>2018-01-05T13:11:46Z</dc:date>
    </item>
  </channel>
</rss>

