Last active
September 17, 2019 13:10
-
-
Save tokejepsen/4ba7aadd260e857648b83738f78474ae to your computer and use it in GitHub Desktop.
Mirror Meshes
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
""" | |
Select all meshes that needs to be mirrored. | |
Script produces a mirror locator with a plane for visualizing. | |
""" | |
import pymel.core as pm | |
selection = pm.ls(selection=True) | |
# Create mirror locator/plane. | |
locator = pm.spaceLocator() | |
mirror_plane = pm.polyPlane()[0] | |
pm.parent(mirror_plane, locator) | |
mirror_plane.rotateZ.set(-90) | |
pm.rename(mirror_plane, "mirror_visualizer") | |
for node in selection: | |
# Duplicate mesh. | |
duplicate = pm.duplicate(node) | |
# Blendshape to original mesh in worldspace and zero out transforms. | |
blendshape = pm.blendShape(node, duplicate)[0] | |
pm.blendShape(blendshape, edit=True, weight=[(0, 1)]) | |
blendshape.origin.set(0) | |
pm.makeIdentity(duplicate) | |
# Parent to mirror locator. | |
pm.parent(duplicate, locator) | |
# Duplicate blendshape as instance. Set x scale to -1. | |
instance = pm.instance(duplicate)[0] | |
instance.scaleX.set(-1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment