This file contains hidden or 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 sys | |
from joint import Joint | |
from transform import Transform | |
from unicode_delegate import UnicodeDelegate | |
from dag_node import DagNode | |
from curve import Curve | |
REGISTERED_NODES = {} | |
This file contains hidden or 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 | |
platform = cmds | |
class EventService(object): | |
def __init__(self): | |
self.events = [] | |
self.event_log = [] | |
def add_event(self, event): |
This file contains hidden or 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 | |
cmds.refresh(suspend=True) | |
selection_edges = cmds.filterExpand(cmds.polyListComponentConversion(te=1), sm=32, ex=1) | |
curve_transforms = [] | |
for edge in selection_edges: | |
vertices = cmds.ls(cmds.polyListComponentConversion(edge, fe=1, tv=1), fl=1) | |
created_curve = cmds.curve(d=1, p=[cmds.pointPosition(vertex) for vertex in vertices]) |
This file contains hidden or 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
""" | |
Stolen from: | |
https://bytes.com/topic/python/answers/751180-how-memoize-cache-property-access | |
""" | |
class cached(property): | |
'Convert a method into a cached attribute' | |
def __init__(self, method): | |
private = '_' + method.__name__ | |
def fget(s): | |
try: |
This file contains hidden or 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 sys | |
from PySide2.QtWidgets import * | |
import maya.standalone as ms | |
import maya.cmds as mc | |
class Window(QWidget): | |
def __init__(self): | |
super(Window, self).__init__() | |
self.setupUI() |
This file contains hidden or 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
# Delegator | |
class Delegate(object): | |
def __init__(self): | |
pass | |
def name(self): | |
print 'yo' | |
class HasDelegate(object): | |
def __init__(self): |
This file contains hidden or 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
class MayaElement(AbstractElement): | |
def __init__(self, | |
group_top='', | |
group_model='', | |
group_joint='', | |
group_nodes='', | |
group_world='', | |
parent='', | |
scale=1.0, | |
**kwargs): |
This file contains hidden or 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 mc | |
file = "D:/dev/procedural_rigging/assets/komodo/model/komodo_model.mb" | |
new_nodes = mc.file(file, i=True, returnNewNodes=True) | |
print cmds.ls(new_nodes, assemblies=True)[0] |
This file contains hidden or 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.api.OpenMaya as om | |
import maya.cmds as mc | |
mpoint_to_point = lambda mpoint: [float(p) for p in mpoint][:3] | |
loc_at_mpoint = lambda point: mc.xform(mc.spaceLocator(), t=point, ws=True) | |
dag_iterator = om.MItDag(om.MItDag.kDepthFirst, om.MFn.kInvalid) | |
def get_dag_path(xform): | |
selectionList = om.MSelectionList() | |
try: |
This file contains hidden or 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 mc | |
import math | |
def mesh_verts_distance_from_point(point, transform_with_shape): | |
distance_between = lambda p1, p2: math.sqrt(sum([(a - b) ** 2 for a, b in zip(p1, p2)])) | |
shapes = mc.listRelatives(transform_with_shape, s=True, c=True, type='mesh') | |
distances = {} | |
if shapes: | |
mesh_verts = mc.ls("{MESH}.vtx[*]".format(MESH=shapes[0]), fl=True) |