Last active
January 15, 2025 11:13
-
-
Save BigRoy/465ad29798b68725bc62d7be47a4c53b to your computer and use it in GitHub Desktop.
Maya Create rsMeshParameters per node in selection and add node name as suffix label
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Maya Create rsMeshParameters per node in selection and add node name as suffix label | |
import contextlib | |
from maya import cmds, mel | |
@contextlib.contextmanager | |
def maintained_selection(): | |
previous_selection = cmds.ls(selection=True) | |
try: | |
yield | |
finally: | |
if previous_selection: | |
cmds.select(previous_selection, | |
replace=True, | |
noExpand=True) | |
else: | |
cmds.select(clear=True) | |
def create_rs_mesh_parameters(nodes, name=None): | |
with maintained_selection(): | |
cmds.select(nodes, noExpand=True, replace=True) | |
parameters = mel.eval('redshiftCreateObjectSetForSelection("RedshiftMeshParameters");') | |
if name is not None: | |
cmds.rename(parameters, name) | |
# Create each separately | |
for node in cmds.ls(selection=True, type="dagNode"): | |
label = node.rsplit("|", 1)[-1].rsplit(":", 1)[-1] | |
create_rs_mesh_parameters(node, name=f"rsMeshParameters_{label}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment