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 pymel.core as pm | |
obj, trg = pm.selected() | |
obj_mtx = obj.getMatrix(worldSpace=True) | |
trg_mtx = trg.getMatrix(worldSpace=True) | |
new_axes = [] | |
trg_axes = [ | |
pm.dt.Vector(trg_mtx[0][:3]).normal(), |
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
""" | |
copy component tags between two identical shape | |
here: from intermediate to final shape | |
""" | |
import pymel.core as pm | |
obj = pm.selected()[0] | |
shp = obj.getShape() | |
shp_intm = [shp for shp in obj.getShapes() if shp.isIntermediate()][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 pymel.core as pm | |
jnt = pm.selected()[0] | |
mtx = jnt.getMatrix(worldSpace=False) | |
rot = mtx.rotate.asEulerRotation() | |
rot.unit = 'degrees' | |
jnt.rotate.set([0,0,0]) | |
jnt.jointOrient.set(rot) |
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 ToolSettings: | |
""" | |
Usage: | |
tool_settings = ToolSettings() | |
tool_settings.output_dir_path = 'c:/out_dir/' | |
""" | |
OrganizationName = "MyOrganization" | |
ApplicationName = "MyApplication" | |
def __getattr__(self, name): |
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 tkinter as tk | |
from PIL import ImageGrab | |
import ctypes | |
class ScreenCapture: | |
def __init__(self): | |
self.start_point = None | |
self.end_point = None | |
self.current_rectangles = [] | |
self.root = tk.Tk() |
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 | |
import maya.api.OpenMaya as om2 | |
import numpy as np | |
from scipy.optimize import minimize | |
from scipy.spatial.distance import cdist | |
def get_curve_cvs(curve): | |
curve_fn = om2.MFnNurbsCurve(get_dag_path(curve)) | |
cvs = curve_fn.cvPositions(om2.MSpace.kWorld) | |
return np.array([[cv.x, cv.y, cv.z] for cv in cvs]) |
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 om2 | |
import pymel.core as pm | |
def getVertexAtUV(obj, u, v): | |
""" | |
:param obj: geometry to search | |
:param u: search U | |
:param v: search V | |
:return: vertex object |
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 pymel.core as pm | |
def build_hierarchy(hmap): | |
''' | |
hmap = 'root' \ | |
' controllers_GRP' \ | |
' leftHand_CTR_GRP' \ | |
' rightHand_CTR_GRP' \ | |
' setup_GRP' \ | |
' rig_GRP' \ |
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
"""Select latticed geometry and run script""" | |
import pymel.core as pm | |
sel = pm.selected()[0] | |
lattice = sel.history(type='lattice')[0] | |
cps = lattice.controlPoints | |
n = pm.getAttr(cps, size=True) | |
main_grp = pm.group(empty=True, name='{}_tweak_GRP'.format(sel.name())) | |
for i in range(n): | |
t = cps[i].get() |
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
"""Restore bind pose on selected transform node if stored""" | |
import pymel.core as pm | |
for obj in pm.selected(dag=True): | |
if hasattr(obj, 'bindPose'): | |
bp = obj.bindPose.get() | |
if bp is not None: | |
obj.setMatrix(bp, worldSpace=True) |