Created
June 1, 2021 22:22
-
-
Save JustinPedersen/ae42742c09b0262a9df5798086daad49 to your computer and use it in GitHub Desktop.
This file contains 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
import maya.cmds as cmds | |
# Capture the user selection | |
user_selection = cmds.ls(selection=True) | |
# Create a duplicate of it | |
new_geo = cmds.duplicate(user_selection[0]) | |
# Create a twist deformed and two bend deformers. | |
twist_def, twist_handle = cmds.nonLinear(new_geo[0], type='twist') | |
bend_def_01, bend_handle_01 = cmds.nonLinear(new_geo[0], type='bend') | |
bend_def_02, bend_handle_02 = cmds.nonLinear(new_geo[0], type='bend') | |
""" | |
NOTE: The nonLinear cmd will return a list of 2 items so | |
we capture them here like this. The handles are what you | |
will move around and the defs are what you can use to add | |
some twist or bend before you start. | |
eg: cmds.setAttr('{}.startAngle'.format(twist_def), 45.0) | |
""" | |
# Rotating the second bend deformer | |
cmds.rotate(0, 90, 0, bend_handle_02, relative=True) | |
""" | |
NOTE: If you would like to rotate any of the other | |
deformers you can do that here too. Rotations given as X, Y, Z | |
eg: cmds.rotate(0, 90, 0, twist_handle, relative=True) | |
""" | |
# Grouping the deformers and the duplicated Geo | |
all_transforms = [new_geo[0], | |
twist_handle, | |
bend_handle_01, | |
bend_handle_02] | |
final_grp = cmds.group(all_transforms) | |
""" | |
NOTE: If you want to name the group you can pass it to the name flag | |
like this: final_grp = cmds.group(all_transforms, name='hair_grp') | |
""" | |
# The group should already be selected once its created but | |
# for sake of example you can select it like this. | |
cmds.select(final_grp, replace=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment