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
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
# 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
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
""" | |
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 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
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 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 mc | |
""" | |
I have two lists: | |
1. Materials | |
2. Locators | |
I want to compare each list and if the locator has the same name as the material then: | |
getAttr transforms from the locator and setAttr color to the material. | |
If I define the name of the material and locator as 'someMaterial', it works. |
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
from functools import wraps | |
def verify_inputs(filterers=None, validators=None): | |
""" Verify the inputs going into any function with equal length lists of: | |
filterers (for filtering out objects we do not care about) and | |
validators (to check the object itself is valid). | |
""" | |
filterers = filterers if filterers is not None else [] | |
validators = validators if validators is not None else [] |