Skip to content

Instantly share code, notes, and snippets.

View BigRoy's full-sized avatar

Roy Nieterau BigRoy

View GitHub Profile
@BigRoy
BigRoy / inspect_file.py
Created October 27, 2015 10:56
Testing inspect filepath options for Pyblish plugins
cls.__path__ = None
if cls.__module__ != '__main__': # if not local (in-memory)
try:
cls.__path__ = inspect.getfile(cls)
except RuntimeError, e:
print e
import maya.cmds as mc
def offsets_to_input(mesh):
num_pts = mc.getAttr('{0}.pnts'.format(mesh), size=True)
for i in range(num_pts):
# Get the internal offset
offset = mc.getAttr('{0}.pnts[{1}]'.format(mesh, i))[0]
# Move the vertex position by the internal offset value (relative)
import maya.OpenMaya as om
import maya.cmds as mc
import uuid
def ensure_id(node):
"""Add a uuid attribute on the given node with a unique value.
Skips nodes that already have the attribute, unless when used upon duplicating.
Maya temporarily assigns the prefix '__PrenotatoPerDuplicare_' so we use that
import maya.OpenMaya as om
import maya.cmds as mc
import uuid
def get_name(node):
"""Get the long name from the MObject where appropriate"""
if node.hasFn(om.MFn.kDagNode):
return om.MFnDagNode(node).fullPathName()
else:
return om.MFnDependencyNode(node).name()
import maya.OpenMaya as om
import maya.cmds as mc
def callback(node, clientData):
fnDep = om.MFnDependencyNode(node)
node_name = fnDep.name()
print node_name
if __name__ == '__main__':
# Delete previous run (testing only)
import maya.OpenMaya as om
import maya.cmds as mc
import uuid
def get_name(node):
"""Get the long name from the MObject where appropriate"""
if node.hasFn(om.MFn.kDagNode):
return om.MFnDagNode(node).fullPathName()
else:
return om.MFnDependencyNode(node).name()
"""
maya.cmds.listHistory() will always include the node itself when history is returned.
Here we're testing whether it's always the first node returned, if not a RuntimeError is raised.
We're also checking whether all nodes in the scene will return a valid history list, which isn't True.
The 'defaultColorMgtGlobals' node returns None instead of an empty list.
"""
from maya import cmds