attrtree#
- ENS_TOOL_CYLINDER.attrtree(all: int = 0, filter: list | None = None, exclude: list | None = None, include: list | None = None, group_exclude: list | None = None, group_include: list | None = None, insensitive: int = 1) dict #
Get detailed GUI information for attributes of this object.
This method is on MOST of the intrinsic objects, but not all of them. This method is used to generate a “visual” tree of an object’s attributes. The most common use would be to dynamically generate labels and hierarchy for a “property sheet” editor.
The method returns an object tree that describes the way attribute should be laid out. Each object has three attributes: attr, ‘hasdeps’ and name. All objects will have names and group objects will have an attr of -1. All objects can also be iterated for children objects of the same type. Only objects with an attr of -1 will have children. len() can be used to get the number of child objects. The top level object always has the name root. The ‘hasdeps’ attribute is the number of attributes in this attrtree() that have a dependency on this attr. This can be used to decide if a new sensitivity check is needed if a given attribute changes.
- Parameters:
- all
int
If set to 1 will include all attrs for the object, even if they are not in the group tables.
- filter
Optional
[list
] Should be set to an optional list of EnSight objects. The output will be filtered to include only the attributes in common between all of the objects (they do not need to be of the same type).
- include
Optional
[list
] Should be set to a list of attribute enums. Only the enums in the list will be included in the output object tree. Note: passing an empty list via this keyword, all the enums will be initially excluded. This is useful with the group_include= keyword.
- exclude
Optional
[list
] Should be set to a list of attribute enums. Any enums in the list will be removed from the output object tree.
- group_exclude
Optional
[list
] Should be set to a list of attribute enums. For any enum in this list, exclude the enum and all the other enums in the same groups as the passed enums. Think of this as a shortcut for exclude= that requires you to only pass a single enum in the group you want to suppress.
- group_include
Optional
[list
] Should be set to a list of attribute enums. For any enum in this list, include the enum and all the other enums in the same groups as the passed enums. Think of this as a shortcut for include= that requires you to only pass a single enum in the group you want to include. Note: it may be necessary to pass include=[] (the empty list) to start with an empty list of enums.
- insensitive
int
If this keyword is set to 0, attrtree() will call foo.issensitive() on each filtered attr and if the attr is not currently sensitive, it will remove it from the output. The default value for this keyword is 1 which disables all sensitivity filtering.
- all
Examples
>>> def walk_tree(part,obj,s): >>> a = obj.attr >>> if (a == -1): >>> print("{}Group={}".format(s, obj.name))) >>> else: >>> = part.attrinfo(a) >>> t = enum_to_name(a) >>> d = info['desc'] >>> print("{}Attr={} - '{}' ({:d} deps)".format(s, t, d, obj.hasdeps)) >>> for i in obj: >>> walk_tree(part,i,s+" ") >>> walk_tree(session.ensight.core.PARTS[0],session.ensight.core.PARTS[0].attrtree(),"")