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
    • Login

    Undraw Slider in TreeView?

    Cinema 4D SDK
    windows python 2024
    2
    3
    386
    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.
    • gheyretG
      gheyret
      last edited by

      Hi Everyone!
      There's a Treeview with Slider for each item, but I don't want to draw slider for some of them, similar to Field List in Cinema, but in the Python Documentation it's just have silderInfo["state"] for activation of slider, but not draw or undraw.
      And Same question for DropDown menu in TreeView, So is that posible to do that?


      Filed List in Cinema
      60a008bb-d64e-46ec-8940-84f9a0e0fde9-image.png


      There is my test

      def GetFloatValue(self, root, userdata, obj, lColumn, sliderInfo):
              if lColumn == Slider_col:
                  if not obj.name== "Test02":
                      sliderInfo['minValue'] = 0.0
                      sliderInfo['maxValue'] = 2.0
                      sliderInfo['minNominalValue'] = 0.0
                      sliderInfo['maxNominalValue'] = 1000000.0
                      sliderInfo['increment'] = 1.0
                      sliderInfo['state'] = 1
                  else:
                      sliderInfo['state'] = 0
      

      ad6ec434-26f1-4000-afa3-c6b2a13e5287-image.png

      www.boghma.com

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

        Hello @gheyret,

        Thank you for reaching out to us. For my own clarity, what you want to do, is add an LV_SLIDER column to a TreeViewCustomGui but than have this column only being drawn on specific rows, right?

        You can reuse LV_CHECKBOX_HIDE for this, at least that is how we do it in C++. I have never tried this in Python but I do not see why it should not work there. Find a pseudo-code example below.

        Cheers,
        Ferdinand

        Code:

        """Demonstrates pattern to hide specific cells in a tree view that are not drawn by ourselves, using
        the flag LV_CHECKBOX_HIDE.
        
        THIS IS UNTESTED PSEUDO CODE.
        """
        
        import c4d
        import mxutils
        
        class TreeItem:
            """Represents a tree of items.
            """
            def __init__(self):
                self._children: list[TreeItem] = []
                self._noSlider: bool = False
        
        class MyFunctions (c4d.gui.TreeViewFunctions):
            def GetFloatValue(self, root: TreeItem, userdata: TreeItem, obj: TreeItem, lColumn: int, 
                              sliderInfo: dict) -> None:
                """Called for each slider in the tree view to get its float value and settings.
        
                We use it here to hide item that are noSLider == True. Similar things can be done in other 
                tree view methods such as IsChecked, GetDropDownMenu, etc.
                """
                # When the incoming #obj is a TreeItem and has _noSlider set to True, we hide the slider
                # by joining LV_CHECKBOX_HIDE into its "state" attribute (which is more a flag than a state).
                if mxutils.CheckType(obj, TreeItem)._noSlider == True:
                    sliderInfo["state"] |= c4d.LV_CHECKBOX_HIDE
        

        MAXON SDK Specialist
        developers.maxon.net

        gheyretG 1 Reply Last reply Reply Quote 1
        • gheyretG
          gheyret @ferdinand
          last edited by

          Hi!@ferdinand
          Yes , That's what i want to do!
          I never didn't know LV_CHECKBOX_HIDE would work with LV_SLIDER, I simply assumed that it would only work with LV_CHECKBOX and LV_CHECKBOXUSER.
          But anyway i test it in my code , and it works perfectly!
          Thank you so much for your reply.😁

          Cheers~

          www.boghma.com

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