Why is button press req for Layer Solo? not others



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

    On 11/03/2012 at 01:19, xxxxxxxx wrote:

    All other Layer icons can be toggled (with effect) except for Solo

    why does it need the added Button click simulation

    import c4d
    from c4d import *
    def main() :
        doc = c4d.documents.GetActiveDocument()
        root = doc.GetLayerObjectRoot()#Gets the layer manager
        LayersList = root.GetChildren()
        toggled = 0
        for layers in LayersList:   
            #print layers.GetName()
            if layers.GetBit(c4d.BIT_ACTIVE) :# if the layer is selected
                layer_data = layers.GetLayerData(doc)
                layer_data['solo'] = not layer_data['solo']
                layers.SetLayerData(doc,layer_data)
                toggled=1
                c4d.EventAdd()
        if toggled == 0:
            gui.MessageDialog("Select a layer to use the script")
            return False
        CallButton(layers, 100004726) # why do we need this when other items in the layer list do not
    if __name__=='__main__':
        main()
    

    ie. all the other icons can be toggled and function without a button click?

    import c4d
    from c4d import gui
        
    def main() :
        #c4d.CallCommand(13957); # Clear console
        doc = c4d.documents.GetActiveDocument()
        root = doc.GetLayerObjectRoot()#Gets the layer manager
        LayersList = root.GetChildren()
        toggled = 0
        for layers in LayersList:        
            if layers.GetBit(c4d.BIT_ACTIVE) :# if the layer is selected           
                layer_data = layers.GetLayerData(doc)
                layer_data['view'] = not layer_data['view']
                layer_data['render'] = not layer_data['render']
                layer_data['manager'] = not layer_data['manager']
                layer_data['locked'] = not layer_data['locked']
                layer_data['generators'] = not layer_data['generators']
                layer_data['expressions'] = not layer_data['expressions']
                layer_data['animation'] = not layer_data['animation']
                layer_data['deformers'] = not layer_data['deformers']
                layers.SetLayerData(doc,layer_data)
                toggled=1
                c4d.EventAdd()
        if toggled == 0:
            gui.MessageDialog("Select a layer to use the script")
            return False
    if __name__=='__main__':
        main()
    


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

    On 11/03/2012 at 07:10, xxxxxxxx wrote:

    and to add to that 
    not sure if its a bug

    but
    layer_data['deformers'] = not layer_data['deformers']
    isn't working



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

    On 11/03/2012 at 11:04, xxxxxxxx wrote:

    I haven't seen anyone from Maxon post here in about a week. They might be at trade shows or something. So I don't know if you're going to get a reply to this anytime soon.

    This is my interpretation of how it works:
    In the C++ SDK it shows that Solo has it's own NBIT code to use to solo the object the layer is on.
    When the user physically clicks the solo icon in the LayerObject. It sends an NBIT message to the object the layer is on. And solos the object as expected.
    But if you change just the LayerObject's solo state with code, and not physically clicking on it. The ChangeNBit() message never gets sent to the object. So it doesn't do anything.

    Here's a C++ example showing LayerObject & ChangeNBit()working together to solo the object:

        GeListHead *list = NULL;  
      list = doc->GetLayerObjectRoot();      //Get the root and store it in the GeListHead variable called "list"  
      if(!list) return FALSE;  
      
      LayerObject *layer = (LayerObject* )list->GetFirst();   //Get the first layer     
      if(!layer) return TRUE;  
      
      const LayerData *data = layer->GetLayerData(doc,FALSE); //Get the layer's container  
      LayerData newdata(*data);                               //Adds a new custom entry into the layer's container  
      newdata.solo = TRUE;                                    //Set the SOLO option to on in memory  
      
      doc->StartUndo();  
      doc->AddUndo(UNDOTYPE_CHANGE,layer);  
      layer->SetLayerData(doc, newdata);                     //Execute the changes made to the layer  
       
      //The object in the OM needs it's bit set to SOLO  
      //The LayerObject alone will not make the object update by itself  
      doc->AddUndo(UNDOTYPE_BITS,doc);  
      doc->ChangeNBit(NBIT_SOLO_LAYER, NBITCONTROL_SET);    //Executes the NBIT_SOLO_LAYER option   
      doc->EndUndo();  
      EventAdd();
    

    I think you're your CallButton(layers, 100004726) code fools C4D into sending the ChangeNBit() message to the object. That's why it works.
    When the Maxon guys get back they can maybe shed better light on how it works if I've got it wrong.

    -ScottA



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

    On 11/03/2012 at 11:13, xxxxxxxx wrote:

    Thanks for your thoughts Scott.

    More code - always useful.

    Will try to get my hard around this.


Log in to reply