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

    Enable/Disable parameters in the Attribute Manager by their parent Group ID

    Cinema 4D SDK
    c++
    3
    6
    704
    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.
    • mfersaouiM
      mfersaoui
      last edited by

      Hello,

      Is it possible to enable/disable parameters in the Attribute Manager by their parent group id (enable/disable all the Description Resource inside an group). I don't want to do enable/disable parameters separately one by one in the NodeData::GetDEnabling().

      Thanks.

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

        Hi,

        you could overwrite GetDDescription, there you could set the DESC_HIDE flag of a description element. However, I do not think that DESC_HIDE is being parsed for containers and this also will actually hide the element and not just grey it out, which can lead to some funky behaviour if not applied cautiously.

        It seems far easier to use GetDEnabling. What is preventing you from defining a list or dictionary of elements to hide? You could also do this programmatically by parsing the description.

        Cheers
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        mfersaouiM 1 Reply Last reply Reply Quote 0
        • mfersaouiM
          mfersaoui @ferdinand
          last edited by

          @zipit
          Hi,

          I thought to use list or dictionary of elements to enable/disable them, I thought it was possible to automatically get all elements ids inside an group and then enable/disable them.

          Thank you for your help.

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

            @mfersaoui

            I thought it was possible to automatically get all elements ids inside an group and then enable/disable them.

            Hi,

            I am not sure if this is a question, but it is possible. I am too lazy to get up and get my laptop, but it could look something like this (in a sort of very detailed pseudo code):

            def get_group_children_data(node, groups_to_collect):
                ''' Returns group to element relations of the description of the
                 passed node as a dictionary.
                
                Args:
                    node (c4d.C4DAtom): The node to evaluate the description of.
                    groups_to_collect (list[c4d.DescID]): A list of DescIDs of
                     the groups we want to collect all children for.
                     
                Returns:
                    dict: A hash map of the group to children relations.
                        key (str): The string representation of the DescID of the group.
                        value (list): The DescIDs of all children.
                    
                '''
                data = {}
                # GetDescription() is a member of C4DAtom, returning the description
                # of a node. The Description type has a __iter__ implementation which
                # provides all we need in this case (the blanked out first element
                # of the __iter__ triple is the actual element description, but we
                # won't need it), desc_id is the DescID of an element and group_id the
                # DescID of the container it is parented to.
                for _, desc_id, group_id in node.GetDescription(c4d.DESCFLAGS_DESC_NONE):
                    # Step over group ids we are not interested in
                    if group_id not in groups_to_collect:
                        continue
                    # Initialize a bin when we encounter a group id the first time
                    if str(group_id) not in data:
                        # This is sort of an ugly hack here, almost all (all?) types of
                        # c4d are not hashable (do not implement __hash__()), which means
                        # that they cannot be use as keys in hash maps among other things.
                        # You could also use DescID.GetHashCode() instead of str() here.
                        data[str(group_id)] = []
                    # Add the element.
                    data[str(group_id)] += [desc_id]
                return data
                    
            def GetDEnabling(self, node, id, t_data, flags, itemdesc):
                    """
                    """
                    # _group_data is the result of the function above.
                    for group_id, element_ids in self._group_data.items():
                        if group_id == str(should_be_disabled_id) and id in element_ids:
                            return False
                    ...
            

            Cheers
            zipit

            MAXON SDK Specialist
            developers.maxon.net

            mfersaouiM 1 Reply Last reply Reply Quote 0
            • mfersaouiM
              mfersaoui @ferdinand
              last edited by

              @zipit

              Hi,

              Sorry I forgot to mention that I'm working in C++.
              Never mind, after testing the Classic Method I noticed that is simple and not take lot of lines of code. So, I will just use the classic method

              Thanks again.

              1 Reply Last reply Reply Quote 0
              • S
                s_bach
                last edited by

                Hello,

                just for your information: GetDEnabling() gives you the description of the parameter with the itemdesc parameter. From that BaseContainer, you should be able to read the ID of the parameter's parent group (see Description Settings Manual - Groups).

                best wishes,
                Sebastian

                MAXON SDK Specialist

                Development Blog, MAXON Registered Developer

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