Skip to content

maya_zen_tools.startup

This module is designed to be imported at Maya startup, and should be added to your userSetup.py script by running mayapy -m maya_zen_tools.install.

set_selection_priority

set_selection_priority() -> None

This sets selection priority needed for manipulating deformers effectively

Source code in src/maya_zen_tools/startup.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
def set_selection_priority() -> None:
    """
    This sets selection priority needed for manipulating deformers effectively
    """
    surface_selection_priority: int = (
        cmds.selectPriority(
            query=True,
            nurbsSurface=True,
        )
        or 0
    )
    curve_selection_priority: int = (
        cmds.selectPriority(
            query=True,
            nurbsCurve=True,
        )
        or 0
    )
    polymesh_selection_priority: int = (
        cmds.selectPriority(
            query=True,
            polymesh=True,
        )
        or 0
    )
    locator_selection_priority: int = (
        cmds.selectPriority(
            query=True,
            locatorXYZ=True,
        )
        or 0
    )
    # Surface selection should be higher priority than polymesh selection
    if surface_selection_priority <= polymesh_selection_priority:
        surface_selection_priority = polymesh_selection_priority + 1
        cmds.selectPriority(
            nurbsSurface=surface_selection_priority,
        )
    # Curve selection should be higher priority than surface selection
    if curve_selection_priority <= surface_selection_priority:
        curve_selection_priority = surface_selection_priority + 1
        cmds.selectPriority(
            nurbsCurve=curve_selection_priority,
        )
    # Locator selection priority should be higher than curve selection
    if locator_selection_priority <= curve_selection_priority:
        locator_selection_priority = curve_selection_priority + 1
        cmds.selectPriority(
            locatorXYZ=locator_selection_priority,
        )

main

main() -> None

The main entry point for maya-zen-tools startup.

Source code in src/maya_zen_tools/startup.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
def main() -> None:
    """
    The main entry point for `maya-zen-tools startup`.
    """
    # Don't raise errors if the upgrade fails, just continue to use the
    # installed version
    with contextlib.suppress(Exception):
        upgrade()
    # Set selection preferences to track selection order
    cmds.selectPref(
        trackSelectionOrder=True,
    )
    set_selection_priority()
    create_menu()