Enable/Disable parameters in the Attribute Manager by their parent Group ID
-
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.
-
Hi,
you could overwrite
GetDDescription
, there you could set theDESC_HIDE
flag of a description element. However, I do not think thatDESC_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 -
@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.
-
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 -
@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 methodThanks again.
-
Hello,
just for your information:
GetDEnabling()
gives you the description of the parameter with theitemdesc
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