Last active
March 14, 2016 15:50
-
-
Save JFlynnXYZ/a4d4e3a65f9c3fe95142 to your computer and use it in GitHub Desktop.
UsefulMayaLibrary
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
MERGE_FACE_DIRECTION = {"+x":0, "-x":1, "+y":2, "-y":3, "+z":4, "-z":5} | |
def getBoundaryEdges(obj=None): | |
if obj == None: | |
obj = pm.selected()[0] | |
objType = type(obj) | |
if objType == pm.nt.Mesh: | |
edges = obj.edges | |
elif objType == pm.nt.Transform: | |
edges = obj.getShape().edges | |
else: | |
raise ValueError("Selected object is not a mesh or the transform of a mesh") | |
bounds = [] | |
for e in edges: | |
if e.isOnBoundary(): | |
bounds.append(e) | |
pm.select(obj) | |
pm.selectMode(co=True) | |
pm.select(bounds) | |
return bounds | |
def transferTranslate(objs=()): | |
if objs == (): | |
objs = pm.selected() | |
if len(objs) <= 1: | |
raise ValueError("Not enough objects have been selected or passed to transfer translte to") | |
tran = objs[0].translate.get() | |
for t in objs[1:]: | |
t.translate.set(tran) | |
def toggleWireSelectionPersp(): | |
pm.modelEditor("modelPanel4", e=True, sel=not pm.modelEditor("modelPanel4", q=True, sel=True)) | |
def mirrorFaceSegment(axis=("+y","+z")): | |
pm.polyMirrorFace(ws=True, direction=MERGE_FACE_DIRECTION[axis[0]], mergeMode=1, ch=1, mergeThreshold=0.00001) | |
pm.polyMirrorFace(ws=True, direction=MERGE_FACE_DIRECTION[axis[1]], mergeMode=1, ch=1, mergeThreshold=0.00001) |
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
def cutMeshMirror(obj=None, pc=(0,0,0), ro=(-90,0,90), delete=True): | |
if obj == None: | |
obj = pm.selected()[0] | |
if type(obj) == pm.nt.Transform: | |
obj = obj.getShape() | |
pm.polyCut(obj.faces, ch=True, pc=pc, ro=ro) | |
if delete: | |
rightSideFaces = [] | |
for f in obj.faces: | |
for p in f.getPoints(space="world"): | |
if p.x > 0: | |
rightSideFaces.append(f) | |
break | |
pm.delete(rightSideFaces) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment