Layer Manager [SOLVED]

On 14/10/2015 at 14:40, xxxxxxxx wrote:

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


I want to read out all Layers from the Layer Manager. Also I want to add new layers, remove and rename. I found the LayerSet in the SDK:

But I don't know how to use it? Does someone has an example for me?


On 14/10/2015 at 15:41, xxxxxxxx wrote:

No code but LayerData is where you want to begin.  You can get the root layer (a list head) of the Document using BaseDocument::GetLayerObjectRoot().  Search here for GetLayerObjectRoot for some topics and code.

On 14/10/2015 at 22:02, xxxxxxxx wrote:

Thank You,

I figured out how it works:

      GeListHead* layerList = NULL;  
      layerList = doc->GetLayerObjectRoot();      
      LayerObject *layer = (LayerObject* )layerList->GetFirst();   //Get the first layer  
      const LayerData *data = layer->GetLayerData(doc, FALSE);    //Get the layer's container   
      while (layer) {  
          layer = layer->GetNext();  

On 15/10/2015 at 01:14, xxxxxxxx wrote:


Layers are not just stored in a list but actually in a tree. So to get all layers you also need to check the child layers with GetDown().

Best wishes,