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
    • Recent
    • Tags
    • Users
    • Login

    Adding to a Layer Object

    Scheduled Pinned Locked Moved SDK Help
    5 Posts 0 Posters 445 Views
    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 Offline
      Helper
      last edited by

      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

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

        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

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

          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

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

            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

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

              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

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