Skip to content

yeti

create_yeti_variable(yeti_shape_node, attr_name, value=None, force_value=False)

Get user defined yeti user variables for a pgYetiMaya shape node.

Parameters:

Name Type Description Default
yeti_shape_node str

The pgYetiMaya shape node.

required
attr_name str

The fully qualified yeti variable name, e.g. "yetiVariableF_myfloat" or "yetiVariableV_myvector"

required
value object

The value to set (must match the type of the attribute) When value is None it will ignored and not be set.

None
force_value bool

Whether to set the value if the attribute already exists or not.

False

Returns:

Name Type Description
bool bool

Whether the attribute value was set or not.

Source code in client/ayon_maya/api/yeti.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def create_yeti_variable(yeti_shape_node: str,
                         attr_name: str,
                         value=None,
                         force_value: bool = False) -> bool:
    """Get user defined yeti user variables for a `pgYetiMaya` shape node.

    Arguments:
        yeti_shape_node (str): The `pgYetiMaya` shape node.
        attr_name (str): The fully qualified yeti variable name, e.g.
            "yetiVariableF_myfloat" or "yetiVariableV_myvector"
        value (object): The value to set (must match the type of the attribute)
            When value is None it will ignored and not be set.
        force_value (bool): Whether to set the value if the attribute already
            exists or not.

    Returns:
        bool: Whether the attribute value was set or not.

    """
    exists = cmds.attributeQuery(attr_name, node=yeti_shape_node, exists=True)
    if not exists:
        if attr_name.startswith("yetiVariableV_"):
            _create_vector_yeti_user_variable(yeti_shape_node, attr_name)
        if attr_name.startswith("yetiVariableF_"):
            _create_float_yeti_user_variable(yeti_shape_node, attr_name)

    if value is not None and (not exists or force_value):
        plug = "{}.{}".format(yeti_shape_node, attr_name)
        if (
                isinstance(value, (list, tuple))
                and attr_name.startswith("yetiVariableV_")
        ):
            cmds.setAttr(plug, *value, type="double3")
        else:
            cmds.setAttr(plug, value)

        return True
    return False

get_yeti_user_variables(yeti_shape_node)

Get user defined yeti user variables for a pgYetiMaya shape node.

Parameters:

Name Type Description Default
yeti_shape_node str

The pgYetiMaya shape node.

required

Returns:

Name Type Description
list List[str]

Attribute names (for a vector attribute it only lists the top parent attribute, not the attribute per axis)

Source code in client/ayon_maya/api/yeti.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def get_yeti_user_variables(yeti_shape_node: str) -> List[str]:
    """Get user defined yeti user variables for a `pgYetiMaya` shape node.

    Arguments:
        yeti_shape_node (str): The `pgYetiMaya` shape node.

    Returns:
        list: Attribute names (for a vector attribute it only lists the top
            parent attribute, not the attribute per axis)
    """

    attrs = cmds.listAttr(yeti_shape_node,
                          userDefined=True,
                          string=("yetiVariableV_*",
                                  "yetiVariableF_*")) or []
    valid_attrs = []
    for attr in attrs:
        attr_type = cmds.attributeQuery(attr, node=yeti_shape_node,
                                        attributeType=True)
        if attr.startswith("yetiVariableV_") and attr_type == "double3":
            # vector
            valid_attrs.append(attr)
        elif attr.startswith("yetiVariableF_") and attr_type == "double":
            valid_attrs.append(attr)

    return valid_attrs