Last active
November 19, 2018 15:33
-
-
Save rondreas/27910a45d8fc3a9d530ca7fcfc85f080 to your computer and use it in GitHub Desktop.
hardsurface modelling script to set normals for all vertices on a face.
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 pymel.core as pm | |
def faceNormal(): | |
""" """ | |
# Store old selection, | |
selection = pm.selected() | |
# Convert selection to faces, | |
pm.mel.ConvertSelectionToFaces() | |
# Iterate over each face in a flattened list of active selection, | |
for face in pm.selected(flatten = True): | |
# Get the face normal and list of vertices. | |
normal = face.getNormal() | |
pm.select(face) | |
pm.mel.ConvertSelectionToVertices() | |
# set their normal to normal of face. | |
for vertex in pm.selected(flatten = True): | |
# FIX: previously set normals will be overwritten by the latest operation, | |
pm.polyNormalPerVertex( vertex, xyz = normal ) | |
# Restore previous selection, | |
pm.select(selection) | |
if __name__ == "__main__": | |
faceNormal() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment