Archicad C++ API
About Archicad add-on development using the C++ API.

[newbie] browsing through materials

stefan
Advisor
When I step through all the materials, one at a time, I can get all info from them. However, when I step through the geometry from the 3D-Window, I get some "iumat" short that should be an index into the materials.

When I use this "iumat" I can reach materials, but not the ones I was expecting:
material  =	component.pgon.iumat;
API_Attribute    attrib;
BNZeroMemory (&attrib, sizeof (API_Attribute));
attrib.header.typeID = API_MaterialID;
attrib.header.index = material;
err = ACAPI_Attribute_Get (&attrib);
if (err == NoError)
{
	sprintf(matBuffer, "%s",  attrib.header.name);
}

archicad.jpg
--- stefan boeykens --- bim-expert-architect-engineer-musician ---
Archicad28/Revit2024/Rhino8/Solibri/Zoom
MBP2023:14"M2MAX/Sequoia+Win11
Archicad-user since 1998
my Archicad Book
4 REPLIES 4
stefan
Advisor
And now the Radiance image (note that textures are ignored, but Sun Position, Camera Viewpoint and View Angle is fine).

The floor was using "Wood-Pine Shiny" and the rest is "Surface-Whitewash". In the export they are both wrong and turn to
"Brick Face" and "Surface Plaster Rough".
I don't think it's a coincidence that the last two materials have been the first two in the complete list of materials, which I generated as follows (based on the API-examples):
API_Attribute		attrib;
BNZeroMemory (&attrib, sizeof (API_Attribute));
err = ACAPI_Attribute_GetNum (API_MaterialID, &nAttr);
for (short i = 1; i <= nAttr && err == NoError; i++)
{
	attrib.header.typeID = API_MaterialID;
	attrib.header.index = i;
	err = ACAPI_Attribute_Get (&attrib);
	if (err == NoError)
	{
		char nameBuffer[64];
		sprintf(nameBuffer, "'%s'", attrib.header.name);
	}
}
--- stefan boeykens --- bim-expert-architect-engineer-musician ---
Archicad28/Revit2024/Rhino8/Solibri/Zoom
MBP2023:14"M2MAX/Sequoia+Win11
Archicad-user since 1998
my Archicad Book
Oleg
Expert
stefan wrote:
When I step through all the materials, one at a time, I can get all info from them. However, when I step through the geometry from the 3D-Window, I get some "iumat" short that should be an index into the materials.
I did not try, but I think iumat isnot material attribute index, it is API_UmatType components index of API_Component3D.
stefan
Advisor
And again a big thank you!
char matBuffer[64];
material = component.pgon.iumat;
API_Component3D component3D;
component3D.header.typeID = API_UmatID;
component3D.header.index = material;
err = ACAPI_3D_GetComponent(&component3D);
if (err == NoError)
{
	API_UmatType umatType = component3D.umat;
	sprintf(matBuffer, "%s",  umatType.mater.head.name);
}
Now I get the correct material from a 3D Polygon...
It seems the the "Attribute" Material and the "3DComponent" Material are reached in a complete different way!
rview2.jpg
--- stefan boeykens --- bim-expert-architect-engineer-musician ---
Archicad28/Revit2024/Rhino8/Solibri/Zoom
MBP2023:14"M2MAX/Sequoia+Win11
Archicad-user since 1998
my Archicad Book
Oleg
Expert
stefan wrote:
It seems the the "Attribute" Material and the "3DComponent" Material are reached in a complete different way!
I can only assume about the reason. Materials for polugons can be defined inside GDL script or binary section of object. They will not have the appropriate material attributes. Probably therefore there is this umat components.

PS: By the way, I am not sure, but it is possible that names of Umat materials are not unique and can be duplicated, if some objects will have various definitions of materials with an identical name. Though I did not try.