Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Unread
    • Recent
    • Tags
    • Users
    • Register
    • Register
    • Login

    How to deselect item in a fieldList

    Cinema 4D SDK
    r20 r21 python
    3
    7
    1.1k
    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.
    • S
      sandidolsak @ferdinand
      last edited by Manuel

      edit :
      new question, forked from this thread

      Hey @zipit,

      Thanks for the detailed explanation about type, will try following it from now on.

      Tested FIeldLists implementation and it seems to work very well so far, the only thing I struggle is with "half selected" (bold orange) elements in fieldlists, is there a way to deselect them all like with volumebuilder, where you simply call:

          for i in xrange(0, obj.GetListEntryCount()):
              obj.SetSelected(i, 0)
      

      Thanks again,

      Sandi

      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by ferdinand

        Hi,

        you could try your luck with BaseList2D.DelBit(), but I wouldn't hold my breath, since FieldLists are presented in a very specialized GUI gadget. Something like this (I did not try this):

        for layer in get_field_layers(my_fieldlist):
            layer.DelBit(c4d.BIT_ACTIVE)
            layer.Message(c4d.MSG_UPDATE)
        my_fieldlist.Message(c4d.MSG_UPDATE)
        c4d.EventAdd()
        

        Cheers
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        S 1 Reply Last reply Reply Quote 0
        • ManuelM
          Manuel
          last edited by

          hello,

          I've forked the other thread as this is a new question.

          I'm not sure what you are talking about "half selected" element. Are you talking about the field object in the object manager ?

          A screenshot showing what you mean by that would be apreciate.

          Cheers,
          Manuel

          MAXON SDK Specialist

          MAXON Registered Developer

          S 1 Reply Last reply Reply Quote 0
          • S
            sandidolsak @Manuel
            last edited by

            @m_magalhaes I am talking about the bold orange Highlight on selected field object when it is not actually selected in the OM but trough the field list

            selected_01.JPG

            I would like to remove this, deselect everything inside Field list, if possible.

            Thanks.

            1 Reply Last reply Reply Quote 0
            • S
              sandidolsak @ferdinand
              last edited by sandidolsak

              @zipit Thanks for this, I tried, doesn't seem to work with DelBit(), it does change the state, so if I read it back with GetBit() it says false, but it doesn't reflect in OM or AM.

              But thanks anyway, this is more a visual thing anyway, would be cool to fix but it works without it too, just more confusing 🙂

              1 Reply Last reply Reply Quote 0
              • ManuelM
                Manuel
                last edited by Manuel

                hello,

                you have to set back the field list like so:

                Warning : I discovered that GetSelected is actually bugged and if you set the includeChildren to False, it will crash.
                I've opened a bug report for that.
                you can use this with children or retrieves the layer using your own function as you can do with an object hierarchy (fieldlayer are BaseList2D)

                import c4d
                
                
                def main():
                    if op is None:
                        raise TypeError("no object selected")
                    
                
                    data = op.GetDataInstance()
                    # Retrieves the fieldlist
                    fl = data.GetCustomDataType(c4d.FIELDS)
                    if fl is None:
                        raise ValueError("no field list found")
                    
                    
                    root = fl.GetLayersRoot()
                    
                    sel = list()
                    # Retrieves the selected layers.
                    fl.GetSelected(sel, True)
                    
                    for layer in sel:
                        layer.SetStrength(0.5)
                        layer.DelBit(c4d.BIT_ACTIVE)
                        
                    # Sets back the field list to update its content.
                    op.SetParameter(c4d.FIELDS, fl, c4d.DESCFLAGS_SET_NONE)
                    c4d.EventAdd()
                    
                
                
                if __name__=='__main__':
                   main()
                

                The linked object is still selected, but that reproduce what the "select none" popup menu does.

                Cheers,
                Manuel

                MAXON SDK Specialist

                MAXON Registered Developer

                S 1 Reply Last reply Reply Quote 0
                • S
                  sandidolsak @Manuel
                  last edited by

                  @m_magalhaes Hey!

                  Added the code you provided and it works nicely, thanks so much!

                  Cheers,

                  Sandi

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