Skip to content

Instantly share code, notes, and snippets.

@gregoiredehame
gregoiredehame / collision.py
Last active September 21, 2024 16:28
native maya mesh collision solver
from __future__ import annotations
import maya.cmds as cmds
class Solver(object):
""" class object that will initialize and create a native maya collision solver using pfxToon.
the solver has an option to create an HUD slider that can dynamically update solver width on viewport.
Args:
slider: (bool): - True will create an interactive slider on viewport.
import maya.cmds as mc
def resetSkinCluster(skinClusterNode):
'''
Originaly created by Macaronikazoo - edited by Steffano
Splats the current pose of the skeleton into the skinCluster
The current pose is becomes the bindpose
'''
numInputs= len(mc.listConnections(skinClusterNode + '.matrix',destination=False))
@KentMrng
KentMrng / proximityWrap.py
Created February 7, 2022 08:56
Create proximityWrap and add driver from python
from maya import cmds
def proximityWrap(driven, drivers, name=''):
from maya.internal.nodes.proximitywrap import node_interface
kwargs = {'type': 'proximityWrap'}
if name:
kwargs['name'] = name
pw = cmds.deformer(driven, **kwargs)
pwni = node_interface.NodeInterface(pw[0])
@MongoWobbler
MongoWobbler / proximity_wrap.py
Last active April 21, 2025 07:56
Function for creating a proximity wrap deformer in Maya with the given source driving the given target
import maya.cmds as cmds
import maya.internal.nodes.proximitywrap.node_interface as node_interface
def createProximityWrap(source, target):
"""
Creates a proximity with the given source and target transforms.
Args:
source (pm.nodetypes.Transform): Transform with skinned mesh that will drive given target.
# Python version of findRelatedSkinCluster.mel
# Based in findRelatedSkinCluster.mel MEL script file found in Maya 2020
import maya.cmds
def find_related_skin_cluster(skin_obj):
skin_shape = None
skin_shape_with_path = None
hidden_shape = None
"""
Functions for generating spline weights.
Usage:
This modules functions each take curve parameters and output control point weights. The weights are generated using
a modified version of de Boor's algorithm. These weights can be used to create a weighted sum to find a point or
tangent on a spline.
While these functions are written for usage in Autodesk Maya, they don't actually have any Maya-specific libraries.
Additionally none of these functions actually care about the data type of provided control points. This way these
@redglasses67
redglasses67 / modelPanelScripts.py
Last active February 20, 2025 11:57
Maya_ModelPanel_Scripts
# -*- coding: utf-8 -*-
import maya.cmds as mc
import maya.mel as mel
# 33 のビュー変換で使用する名前の一覧クラス. 変更時に文字列指定するので事前にこのように用意しておくと楽そう
class ViewTransformName():
ACES_RRT_v_0_7 = "ACES RRT v0.7"
ACES_RRT_v_1_0 = "ACES RRT v1.0"
Log = "Log"
@kamilabianchi
kamilabianchi / constraints
Created October 23, 2020 10:13
Maya constraints using matrices
import pymel.core as pm
import maya.cmds as cmds
import maya.api.OpenMaya as om
def parent_constraint(parent, child, offset=True, scale=True, rotation=True, translation=True):
parent_pn = pm.PyNode(parent)
child_pn = pm.PyNode(child)
mmatrix = pm.createNode('multMatrix')
dmatrix = pm.createNode('decomposeMatrix')
parent_wim = om.MMatrix(parent_pn.worldInverseMatrix[0].get())
@yohawing
yohawing / maya_fbx_export.bat
Created September 24, 2020 07:25
Mayaファイルをバッチ処理でFBXExportするさせる
SET MAYABATCH="C:\Program Files\Autodesk\Maya2020\bin\mayabatch.exe"
SET mayafile=%1
SET outfile=%2
SET VER=FBXExportFileVersion -v FBX201800;
SET TRI=FBXExportTriangulate -v true;
SET PROPS=%VER%%TRI%
%MAYABATCH% -file %mayafile% -command "%PROPS%FBXExport -f ""%outfile%"";"
from shiboken2 import wrapInstance
from PySide2 import QtGui, QtCore, QtUiTools, QtWidgets
import maya.OpenMayaUI as omui
from maya.app.general.mayaMixin import MayaQWidgetDockableMixin
def maya_main_window():
"""
This function gets the pointer to the Maya's Main window.
Our window will be parented under this.