On 19/02/2018 at 12:41, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R19
Platform: Windows ;
Language(s) : C++ ;
---------
Hi,
I was trying to obtain the path to a texture from a material assigned to an object.
Used the following code in a CommandData, and only got the path to the texture from running Test 2.
In the first test I am calling GetAllTextures with an atomarray containing the object I want to get the texture path from. This fails, as the returned container is empty.
In the second test I am calling GetAllTextures with nullptr, which would return me texture paths for all objects in the scene. This works.
Why does the first one fail ?
// Test 1
{
GePrint("Test 1");
BaseDocument* doc = GetActiveDocument();
if (doc)
{
BaseObject* object = doc->GetActiveObject();
if (object)
{
// get all textures used by an object
AutoAlloc<AtomArray> ar;
if (ar)
{
ar->Append(object);
BaseContainer texbc = doc->GetAllTextures(ar);
BrowseContainer browse(&texbc);
Int32 id;
GeData* data;
GePrint("Used textures:");
while (browse.GetNext(&id, &data))
{
const Filename& filename = data->GetFilename();
GePrint(filename.GetFileString());
}
}
}
}
}
// Test 2
{
GePrint("Test 2");
BaseDocument* doc = GetActiveDocument();
if (doc)
{
BaseObject* object = doc->GetActiveObject();
if (object)
{
// get all textures
BaseContainer texbc = doc->GetAllTextures(nullptr);
BrowseContainer browse(&texbc);
Int32 id;
GeData* data;
GePrint("Used textures:");
while (browse.GetNext(&id, &data))
{
const Filename& filename = data->GetFilename();
GePrint(filename.GetFileString());
}
}
}
}