Skip to content

maya_zen_tools.menu

show_about

show_about() -> None

Show a window with information about, and button to update/upgrade or uninstall, ZenTools.

Source code in src/maya_zen_tools/menu.py
 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
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
def show_about() -> None:
    """
    Show a window with information about, and button to update/upgrade or
    uninstall, ZenTools.
    """
    if cmds.window(ABOUT_WINDOW, exists=True):
        cmds.deleteUI(ABOUT_WINDOW)
    cmds.window(
        ABOUT_WINDOW,
        title="About ZenTools",
    )
    column_layout: str = cmds.columnLayout(
        parent=ABOUT_WINDOW,
        margins=15,
    )
    version: str = get_maya_zen_tools_package_info()["version"]
    cmds.text(
        label=(
            f"ZenTools {version} © "
            f"{datetime.now(tz=timezone.utc).year} by David Belais\n"
        ),
        align="left",
        parent=column_layout,
    )
    debugging: bool = get_tool_option(  # type: ignore
        "general", "debugging", False
    )
    row_layout: str
    # If debugging is enabled, or if ZenTools is installed as an editable
    # package, show an option to enable/disable debugging
    with contextlib.suppress(Exception):
        package_info: dict[str, str] = get_maya_zen_tools_package_info()
        if debugging or (
            package_info.get("editable_project_location") is not None
        ):
            cmds.checkBox(
                label="Enable Debugging",
                parent=column_layout,
                value=debugging,  # type: ignore
                onCommand=(
                    "from maya_zen_tools import options\n"
                    "options.set_tool_option("
                    "'general', 'debugging', "
                    "True)\n"
                    "from maya_zen_tools import _utilities\n"
                    "_utilities.reload()"
                ),
                offCommand=(
                    "from maya_zen_tools import options\n"
                    "options.set_tool_option("
                    "'general', 'debugging', "
                    "False)\n"
                    "from maya_zen_tools import _utilities\n"
                    "_utilities.reload()"
                ),
                height=30,
            )
    row_layout = cmds.rowLayout(
        parent=column_layout,
        numberOfColumns=2,
    )
    cmds.button(
        label="Update ZenTools",
        parent=row_layout,
        command=(
            "from maya import cmds\n"
            "from maya_zen_tools import upgrade\nupgrade.main()\n"
            f"cmds.deleteUI('{ABOUT_WINDOW}')"
        ),
    )
    cmds.button(
        label="Uninstall ZenTools",
        command=(
            "from maya import cmds\n"
            "from maya_zen_tools import _ui\n"
            "_ui.show_confirmation_dialogue("
            f'"Are you certain you want to uninstall ZenTools?", '
            f'yes_command="from maya_zen_tools import uninstall\\n'
            'uninstall.main()", title="Uninstall ZenTools?")\n'
            f"cmds.deleteUI('{ABOUT_WINDOW}')"
        ),
    )
    cmds.showWindow(ABOUT_WINDOW)

create_menu

create_menu() -> None

Create the main ZenTools menu

Source code in src/maya_zen_tools/menu.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
def create_menu() -> None:
    """
    Create the main ZenTools menu
    """
    if cmds.menu(MENU, exists=True):
        cmds.deleteUI(MENU)
    cmds.menu(
        MENU, label="ZenTools", tearOff=True, visible=True, parent=MAYA_WINDOW
    )
    cmds.menuSet(MENU_SET, addMenu=MENU)
    # Selection
    cmds.menuItem(label="Selection", parent=MENU, divider=True)
    cmds.menuItem(
        label=SELECT_EDGES_BETWEEN_VERTICES_LABEL,
        command=(
            "from maya_zen_tools import loop\n"
            "loop.do_select_edges_between_vertices()"
        ),
        annotation=(
            "Selects an edge path containing the fewest edges necessary to "
            "connect selected vertices."
        ),
        parent=MENU,
    )
    cmds.menuItem(
        optionBox=True,
        command=(
            "from maya_zen_tools import loop\n"
            "loop.show_select_edges_between_vertices_options()"
        ),
        parent=MENU,
    )
    cmds.menuItem(
        label=SELECT_EDGES_BETWEEN_UVS_LABEL,
        command=(
            "from maya_zen_tools import loop\n"
            "loop.do_select_edges_between_uvs()"
        ),
        annotation=(
            "Selects an edge path containing the fewest edges necessary to "
            "connect selected UVs."
        ),
        parent=MENU,
    )
    cmds.menuItem(
        optionBox=True,
        command=(
            "from maya_zen_tools import loop\n"
            "loop.show_select_edges_between_uvs_options()"
        ),
        parent=MENU,
    )
    cmds.menuItem(
        label=SELECT_UVS_BETWEEN_UVS_LABEL,
        command=(
            "from maya_zen_tools import loop\n" "loop.do_select_between_uvs()"
        ),
        annotation=(
            "Selects path containing the fewest UVs necessary to "
            "connect selected UVs."
        ),
        parent=MENU,
    )
    cmds.menuItem(
        optionBox=True,
        command=(
            "from maya_zen_tools import loop\n"
            "loop.show_select_between_uvs_options()"
        ),
        parent=MENU,
    )
    cmds.menuItem(
        label="Flood Select",
        command="from maya_zen_tools import flood\nflood.flood_select()",
        annotation=(
            "Selected Edges will define a selection border, selected vertices "
            "or faces will determine the portion of the mesh to be selected."
        ),
        parent=MENU,
    )
    # Modeling
    cmds.menuItem(label="Modeling", parent=MENU, divider=True)
    cmds.menuItem(
        label=CURVE_DISTRIBUTE_BETWEEN_VERTICES_LABEL,
        command=(
            "from maya_zen_tools import loop\n"
            "loop.do_curve_distribute_vertices()"
        ),
        annotation="Align edge loop along a curve based on vertex selection.",
        parent=MENU,
    )
    cmds.menuItem(
        optionBox=True,
        command=(
            "from maya_zen_tools import loop\n"
            "loop.show_curve_distribute_vertices_options()"
        ),
        parent=MENU,
    )
    cmds.menuItem(
        label=LOFT_DISTRIBUTE_VERTICES_BETWEEN_EDGES_LABEL,
        command=(
            "from maya_zen_tools import loft\n"
            "loft.do_loft_distribute_vertices_between_edges()"
        ),
        annotation=(
            "Distribute vertices between two or more parallel edge loops."
        ),
        parent=MENU,
    )
    cmds.menuItem(
        optionBox=True,
        command=(
            "from maya_zen_tools import loft;"
            "loft.show_loft_distribute_vertices_between_edges_options()"
        ),
        parent=MENU,
    )
    # Texturing
    cmds.menuItem(label="Texturing", parent=MENU, divider=True)
    cmds.menuItem(
        label=CURVE_DISTRIBUTE_BETWEEN_UVS_LABEL,
        command=(
            "from maya_zen_tools import loop\n"
            "loop.do_curve_distribute_uvs()"
        ),
        annotation="Align edge loop along a curve based on vertex selection.",
        parent=MENU,
    )
    cmds.menuItem(
        optionBox=True,
        command=(
            "from maya_zen_tools import loop\n"
            "loop.show_curve_distribute_uvs_options()"
        ),
        parent=MENU,
    )
    cmds.menuItem(
        label=LOFT_DISTRIBUTE_UVS_BETWEEN_EDGES_OR_UVS_LABEL,
        command=(
            "from maya_zen_tools import loft\n"
            "loft.do_loft_distribute_uvs_between_edges_or_uvs()"
        ),
        annotation=("Distribute UVs between two or more parallel edge loops."),
        parent=MENU,
    )
    cmds.menuItem(
        optionBox=True,
        command=(
            "from maya_zen_tools import loft;"
            "loft.show_loft_distribute_uvs_between_edges_or_uvs_options()"
        ),
        parent=MENU,
    )
    cmds.menuItem(label="Help", parent=MENU, divider=True)
    cmds.menuItem(
        label="About ZenTools",
        command=(
            "import maya_zen_tools.menu\nmaya_zen_tools.menu.show_about()"
        ),
        parent=MENU,
    )
    cmds.menuItem(
        label="ZenTools Documentation",
        command=(
            "import webbrowser\n"
            "webbrowser.open('https://maya-zen-tools.enorganic.org')"
        ),
        parent=MENU,
    )
    cmds.menuItem(
        label="Reset ZenTools Options",
        command=(
            "import maya_zen_tools.options\nmaya_zen_tools.options.reset()"
        ),
        parent=MENU,
    )
    if get_tool_option("general", "debugging", False):
        # Only show these menu items if `maya-zen-tools` is an
        # editable installation (indicating it is installed for
        cmds.menuItem(label="Debugging", parent=MENU, divider=True)
        # development/testing)
        cmds.menuItem(
            label=CREATE_CURVE_FROM_EDGES_LABEL,
            command=(
                "from maya_zen_tools import loop\n"
                "loop.create_curve_from_edges()"
            ),
            annotation="Create a curve from a contiguous edge selection.",
            parent=MENU,
        )
        cmds.menuItem(
            label=CREATE_UV_CURVE_FROM_EDGES_LABEL,
            command=(
                "from maya_zen_tools import loop\n"
                "loop.create_uv_curve_from_edges()"
            ),
            annotation=(
                "Create a curve from a contiguous edge selection in UV "
                "space"
            ),
            parent=MENU,
        )
        cmds.menuItem(
            label="Reload ZenTools",
            command=(
                "from maya_zen_tools import _utilities\n_utilities.reload()"
            ),
            parent=MENU,
        )