GetAllTextures() Changed in R12&R13



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 16/07/2012 at 11:45, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   12 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    GetAllTextures() now requires pointing to an array. So now the code examples posted in the archives no longer works for me.
    I can't get any textures to return from it using the old code:

        AutoAlloc<AtomArray> myArray;             //Create a new empty atom type array  
      if(myArray)  
       {  
        doc->GetActiveObjects(*myArray,FALSE); //Get any active objects and store them in the array (use GETACTIVEOBJECTFLAGS_0 for R13)  
        LONG cnt = myArray->GetCount();        //Returns the size of the array based on how many objects are selected  
        for(LONG i = 0L; i != cnt; ++i)  
        {  
          String name = static_cast<BaseObject*>(myArray->GetIndex(i))->GetName(); //Get the name of each selected object  
          GePrint(name);  
        }  
       }  
      ////// Great..Everything is working properly so far ///////  
      ////// Now lets check to see what textures are assigned to the selected objects ////////  
       BaseContainer bc = doc->GetAllTextures(myArray);  //Create a container pointing to the array of selected objects   
       BrowseContainer browse(&bc);                      //Create an instance of the BrowseContainer class  
       LONG cid;  
       GeData *data;  
       while(browse.GetNext(&cid, &data))  
       {  
           GePrint("found a texture");                 //<---I get nothing in the console...Even with this!?  
           Filename fn = data->GetFilename();  
           GePrint("Texture: " + fn.GetString());  
       }
    

    Could someone please post a working example of GetAllTextures() that works with R12 and/or R13?

    -ScottA



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 17/07/2012 at 14:22, xxxxxxxx wrote:

    I finally figured out how to make it work.
    This code gets all the textures in the scene. And prints the names of any selected objects:

        AutoAlloc<AtomArray> myArray;                            //Create a new empty atom type array  
      if(myArray)  
      {  
        BaseContainer bc = doc->GetAllTextures(myArray);       //Fill a new container with all the texures in the document  
        LONG counter = 0;  
        while(bc.GetIndexId(counter) != NOTOK)                 //Get all of the non-empty container items  
        {  
          counter++;  
          Filename fn = bc.GetFilename(counter,NULL);          //Get each container item that is a Filename type  
          GePrint(fn.GetString());  
        }  
        doc->GetActiveObjects(*myArray,FALSE);                 //Get any active objects and store them in the array(use GETACTIVEOBJECTFLAGS_0 for R13++)  
        LONG objcnt = myArray->GetCount();                     //Get the size of the array based on how nay objects are selected  
        for(LONG i = 0L; i<objcnt; ++i)  
        {  
          String name = static_cast<BaseObject*>(myArray->GetIndex(i))->GetName(); //Get the names of the selected objects  
          GePrint(name);  
        }  
      }
    

    -ScottA


Log in to reply