Given a selection
comprised of:
- One or more polymesh faces, vertices, or UVs, and...
- A set of edges enclosing an area around the faces, vertices, or
UVs
...this function will expand the face, vertex, or UV selection to
encompass the area enclosed by the selected edges.
Source code in src/maya_zen_tools/flood.py
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146 | def flood_select(*selection: str) -> tuple[str, ...]:
"""
Given a `selection` comprised of:
- One or more polymesh faces, vertices, or UVs, and...
- A set of edges enclosing an area around the faces, vertices, or
UVs
...this function will expand the face, vertex, or UV selection to
encompass the area enclosed by the selected edges.
"""
cmds.waitCursor(state=True)
selection = selection or tuple(cmds.ls(selection=True, flatten=True))
selected_faces: tuple[str, ...] = tuple(
iter_selected_components("f", selection=selection)
)
selected_vertices: tuple[str, ...] = tuple(
iter_selected_components("vtx", selection=selection)
)
selected_uvs: tuple[str, ...] = tuple(
iter_selected_components("map", selection=selection)
)
selected_edges: tuple[str, ...] = tuple(
iter_selected_components("e", selection=selection)
)
# Raise an error if selected vertices span more than one mesh
get_components_shape(selected_faces + selected_vertices + selected_uvs)
selected_components: tuple[str, ...] = (
tuple(_iter_flood_select_vertices(selected_vertices, selected_edges))
+ tuple(_iter_flood_select_uvs(selected_uvs, selected_edges))
+ tuple(_iter_flood_select_faces(selected_faces, selected_edges))
)
cmds.select(
*selection,
deselect=True,
)
cmds.select(*selected_components, add=True)
# Grow the selection until
cmds.waitCursor(state=False)
return selected_components
|