Last active
March 7, 2017 14:57
-
-
Save giuliom95/d0798703f99524833f6c41a45a99e6c6 to your computer and use it in GitHub Desktop.
Generating irregular stairs in Maya
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
"""Little PyMEL script for generating irregular or worn out stairs. | |
Needs a curve that defines the profile of each step and a bunch of curves to extrude the profile on. | |
""" | |
# Import PyMEL and random modules | |
import pymel.core as pmc | |
import random | |
# Select the profile curve and then run this command | |
profile = pmc.ls(sl=True)[0] | |
# Select the extrude curves and then run this command | |
sides = pmc.ls(sl=True) | |
for i in range(10): | |
# Select a random extrude curve | |
next_side = random.choice(sides) | |
# Occasionally mirror it on the X axis to add some variance | |
next_side.setScale([random.choice([-1,1]),1,1]) | |
# Select the profile and the extrude curve | |
pmc.select([profile, next_side]) | |
# Extrude and call the result 'step' | |
step = pmc.extrude(n=‘step’)[0] | |
# Move the freshly generated step to its place | |
step.setTranslation([0,2*i,2*i]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment