Adding to a Layer Object



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

    On 22/05/2011 at 18:24, xxxxxxxx wrote:

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

    ---------
    I am able to add a layer to the layer browser through the following code:

      
      
     LayerObject *layer = NULL;  
       layer = LayerObject::Alloc();  
       if (!layer) return FALSE;  
      
       GeListHead *layerlist = NULL;  
       layerlist = doc->GetLayerObjectRoot();  
       if (!layerlist) return FALSE;  
      
      layer->SetName("My TEST Layer");  
      
       layerlist->Insert(layer, NULL, NULL);  
      
       layerlist->Message(MSG_UPDATE);  
      
    

    Now I would like to add various objects from my plugin to that layer.  I tried doing

      
      
    myObject->SetLayerObject(layer);  
      
    

    but it doesn't seem to work.

    Any ideas on how to do this?

    Thanks,

    ~Shawn



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

    On 23/05/2011 at 02:44, xxxxxxxx wrote:

    Not sure what's going wrong there. Here it's working.

    My code:

      
    Bool MenuTest::Execute(BaseDocument *doc)  
    {  
      BaseObject *op = NULL;  
      op = doc->GetActiveObject();  
      if (!op) return FALSE;  
      
      GeListHead *layerlist = NULL;  
      layerlist = doc->GetLayerObjectRoot();  
      if (!layerlist) return FALSE;  
      
      LayerObject *layer = NULL;  
      layer = LayerObject::Alloc();  
      if (!layer) return FALSE;  
      
      layerlist->Insert(layer, NULL, NULL);  
      layer->Message(MSG_UPDATE);  
      
      if (!op->SetLayerObject(layer)) return FALSE;  
      op->Message(MSG_UPDATE);  
      
      EventAdd();  
      
      return TRUE;  
    }  
    

    cheers,
    Matthias



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

    On 23/05/2011 at 03:08, xxxxxxxx wrote:

    Well the only difference between my code and yours is that my LayerObject is a member variable and is initialized in Init() then the call to add an object to that l layer is in a different function...

    Do you think think that this is the reason it is not working?

    Thanks,

    Shawn



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

    On 23/05/2011 at 03:15, xxxxxxxx wrote:

    As long as you make sure the layer object is valid and inserted into the layer list there shouldn't be a problem.

    cheers,
    Matthias



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

    On 23/05/2011 at 03:20, xxxxxxxx wrote:

    Okay I will tinker some more with it ..  Thanks Matthias.

    ~Shawn


Log in to reply