2 weeks ago - last edited 2 weeks ago
I have a program to create a custom API_Attribute with a specific color. Now i want to assign a texture to it. I have found a list of images using LibraryManager::FindLibParts but when i assign the texture to the API_MaterialType in API_Attribute it is like it is not saved.
API_Attribute material;
BNZeroMemory(&material, sizeof(API_Attribute));
auto libParts = libraryManager->FindLibParts(
[](const ACAPI::Library::LibPart &libPart) {
return ACAPI::Library::v1::SelectImageLibParts(libPart);
});
auto libPart = libParts[0];
IO::Location fLoc;
BNZeroMemory(&fLoc, sizeof(IO::Location));
auto tmp = libPart.GetLocation().Unwrap();
memcpy((void *)&fLoc, (void *)&tmp, sizeof(IO::Location));
then i am assigning it to my API_Attribute like this:
material.material.texture.fileLoc = &fLoc;
memcpy(material.material.texture.texName, libPart.GetName()->ToCStr(),
256);
material.material.texture.status = 4096;
material.material.texture.xSize = 250;
material.material.texture.ySize = 250;
Please help me, thanks in advance!
2 weeks ago
Very good question Mats.
2 weeks ago
I even tried this but it didn't work.
material.material.texture.fileLoc = new IO::Location(
"/Applications/Graphisoft/Archicad 28/Archicad "
"bibliotekspaket/Surface Catalog.libpack/Surface Catalog.lcf/Surface "
"Catalog/[Timg] Textures/Concrete/Concrete - 02 -opt.jpg");
unsigned char binaryData[] = {66, 101, 116, 111, 110, 103, 32, 45,
32, 48, 50, 32, 45, 111, 112, 116};
for (int i = 0; i < 16; i++) {
material.material.texture.texName[i] = binaryData[i];
}
material.material.texture.ySize = 250;
material.material.texture.xSize = 250;
material.material.texture.withoutExtension = false;
2 weeks ago