Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    GetAllTextures not working

    SDK Help
    0
    3
    865
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      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());  
                    }  
                }  
            }  
        }  
      
      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 20/02/2018 at 01:59, xxxxxxxx wrote:

        Hi Daniel,

        basically GetAllTextures() works via MSG_GETALLASSETS. But this message is not forwarded from objects to tags to materials. So, in the end you will need to get the materials from the texture tags yourself and then add the materials to the AtomArray passed to GetAllTextures(). On objects this will only work for special ones like the Displacer deformer, if a texture is used in there directly.

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 20/02/2018 at 03:16, xxxxxxxx wrote:

          I see.
          Adding the materials to the AtomArray ... Really? Wow!
          So the word "objects" in the method description "Gets all used textures for the objects in ar." isn't only referring to BaseObjects. Nice!
          Thanks Andreas.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post