Skip to content

Instantly share code, notes, and snippets.

View masqu3rad3's full-sized avatar

Arda Kutlu masqu3rad3

View GitHub Profile
@masqu3rad3
masqu3rad3 / shelf_creation_snippet.py
Created February 1, 2023 13:59
shelf, shelf button, and shelf button pop-up menu creation snippet for Maya
import maya.cmds as mc
def _null(*args):
pass
class _shelf():
'''A simple class to build shelves in maya. Since the build method is empty,
it should be extended by the derived class to build the necessary shelf elements.
@masqu3rad3
masqu3rad3 / create_hud.py
Created December 8, 2021 11:49
Creates a custom hud from a function or static value
from maya import cmds
def create_hud(label, separation=0, data=None, size="large"):
"""Creates a hud with given arguments
Args:
label: (String) Name of the HUD as it will be visible to user
separation: (Int) Margin from the top
data: (multiple) This can be any value or function.
size: (string) size of the label and data. Acceptable arguments are 'large', 'medium' and 'small'
@masqu3rad3
masqu3rad3 / patch_maker.py
Created July 22, 2021 14:50
Quick and easy way to create patch objects from folder full of images with correct ratios.
#patch maker
from glob import glob
import os
from maya import cmds
image_folder = "/your/image/folder/"
shader_type = "blinn"
@masqu3rad3
masqu3rad3 / get_inbetween_values.py
Last active June 26, 2021 21:47
find the in-between target values on a given base shape
from maya import cmds
import maya.OpenMayaAnim as oa
import maya.OpenMaya as om
def get_inbetween_values(blendshape_node, target_name):
# get the bs api mobject
bs_sel = om.MSelectionList()
bs_sel.add(blendshape_node)
@masqu3rad3
masqu3rad3 / get_selected_vertices.py
Created February 23, 2021 10:47
Small gist to get all the selected vertex id's
def get_selected_vertices():
sel = cmds.ls(sl=True)
for x in sel:
if ":" not in x:
yield int(x[s.find("[")+1:x.find("]")])
else:
start_v = int(x[x.index("[") + 1: x.index(":")])
end_v = int(x[x.index(":") + 1:x.index("]")])
for v in range(start_v, end_v+1):
yield v
@masqu3rad3
masqu3rad3 / frustrum_visualizer.py
Created December 3, 2020 11:40
Slightly modified version of THOMAS HOLLIER's Maya Camera Frustrum Visualizer
## Author: THOMAS HOLLIER
## Modified: Arda Kutlu
## http://relentlessplay.com/maya-frustum-visualizer/
import maya.cmds as cmds
import math, sys
#--------- Gather relevant camera attributes
import maya.cmds as cmds
import math, sys
@masqu3rad3
masqu3rad3 / obj_merge.py
Created October 24, 2020 17:11
Obj Merge / Alternative combine method for polyUnite by exporting & importing obj files.
import os
import uuid
from maya import cmds
def obj_merge(obj_list, name=None, delete_originals=True):
# get the temp export location
if not name:
name = "%s_m" %obj_list[0]
unique_ns = "om%s" %str(uuid.uuid1()).lower().replace("-", "_")
@masqu3rad3
masqu3rad3 / whip.py
Created August 19, 2020 10:55
quick dirty whip kind of overlapping animation
from maya import cmds
def whip(node_list, attr_holder=None, offset=5, diminish=0.8, attr_list=["rx", "ry", "rz"]):
if type(node_list) is not list:
cmds.error("node_list must be a list variable. duh...")
if len(node_list) < 2:
cmds.error("node_list must contain at least 2 elements. duh...")
if not attr_holder:
attr_holder = node_list[0]
@masqu3rad3
masqu3rad3 / get_texture_info.py
Created June 30, 2020 15:17
Accepts object or shading group as input. Collects information about all connected nodes.
import pymel.core as pm
from pprint import pprint
def get_file_info(obj=None, sg=None):
"""
Collects file node informations in a list of dictionaries
one of the obj or sg flags need to be defined.
obj: (String or PyMel Node) Transform object of the mesh. If this is defined, all shading groups
@masqu3rad3
masqu3rad3 / get_visible_meshes.py
Created June 30, 2020 15:15
Gets the visible meshes in the scene
from maya import cmds
def get_visible_meshes():
meshes = cmds.ls(type="mesh", o=True, ni=True)
visible_meshes = list(meshes)
for mesh in meshes:
checklist = cmds.ls(mesh, long=True)[0].split('|')[1:-1] + [mesh]
for parent in checklist:
if (cmds.getAttr("%s.v" % parent) == 0):