Skip to content

Instantly share code, notes, and snippets.

@Onefabis
Onefabis / frame_selected.py
Created October 9, 2015 13:23
frames selected in maya in a "right" way :)
import pymel.core as pc
pann = pc.getPanel(wf=1)
if (pann == 'graphEditor1'):
fsfr = pc.findKeyframe(ts=1, w='first')
lsfr = pc.findKeyframe(ts=1, w='last')
graphEditorSelection = pc.selectionConnection('graphEditor1FromOutliner',q=1,obj=1)
st = pc.playbackOptions(q=1,minTime=1)
en = pc.playbackOptions(q=1,maxTime=1)
if (fsfr>st):
st=fsfr
@Onefabis
Onefabis / frame_all.py
Created October 9, 2015 13:36
Frames all objects in active window inside maya
import pymel.core as pc
pann = pc.getPanel(wf=1)
if (pann == 'graphEditor1'):
fsfr = pc.findKeyframe(ts=1, w='first')
lsfr = pc.findKeyframe(ts=1, w='last')
graphEditorSelection = pc.selectionConnection('graphEditor1FromOutliner',q=1,obj=1)
pc.selectKey(clear=1)
pc.selectKey(graphEditorSelection,add=1,k=1,t=(str(fsfr) + ":" + str(lsfr)))
elif(pann == 'hyperGraphPanel1' or pann == 'hyperGraphPanel2'):
pc.hyperGraph(pann+'HyperGraphEd',e=1,fg=1)
@Onefabis
Onefabis / gist:712c5e5ae45507d6203c
Created November 15, 2015 15:49 — forked from oglops/gist:90ea08309483db07b615
improved maya ref parser
class MayaRefParser(object):
'''
This parses .ma file and get refrenced files info, store them in itself
'''
def __init__(self , maFile=None):
self.header = ''
self.refHeader = ''
self.otherHeader = ''
self.contents = ''
self.contentsLineNum = 0
@Onefabis
Onefabis / renamer.py
Created November 15, 2015 15:50 — forked from jakecraige/renamer.py
Maya - Joint Hierarchy Alphabetical Renamer
import maya.cmds as mc
window = mc.window(title="Joint Hierarchy Renamer", widthHeight=(500, 55))
mc.columnLayout(adjustableColumn=True)
mc.text(label="Instructions: select top of joint hierarchy")
textField = mc.textFieldButtonGrp(label="New name prefix:", buttonLabel="Rename", buttonCommand="rename_joints()")
mc.showWindow(window)
def rename_joints():
@Onefabis
Onefabis / Lazy_selection.py
Created November 15, 2015 15:51 — forked from SEVEZ/Lazy_selection.py
Select object objects, closest to cursor
import maya.cmds as cmds
from pymel.core import *
from pymel.core.datatypes import *
import maya.OpenMaya as om
import maya.OpenMayaUI as omui
class SamsClass():
ctx = cmds.currentCtx()
cto = cmds.contextInfo(ctx,c=1)
print cto
@Onefabis
Onefabis / reverse_subd.py
Created November 15, 2015 15:52
Reverse subdivision
from pymel.all import *
import maya.mel as mel
import maya.OpenMaya as om
'''
def makeUnique( lst ):
result = list()
map( lambda x: not x in result and result.append(x), lst )
return result
@Onefabis
Onefabis / MAYA_findFlippedUVs.py
Created January 20, 2016 16:51 — forked from hmasato/MAYA_findFlippedUVs.py
[Maya, python] _findFlippedUVs
# -*- coding: utf-8 -*-
import maya.OpenMaya as om
import maya.cmds as cmds
def _findFlippedUVs(nodesOnly=True):
ret = []
selList = om.MSelectionList()
global proc string[] NinjaUV_CollectShells()
{
PolySelectConvert 4;
$Selection =`ls -sl -fl`;
string $UVs[] = `ls -sl -fl`;//base uv's
string $Test_UVs[] = `ls -sl -fl` ;
string $Shell[];
string $Shell_string;
string $Shell_array[];
for ($s = 0; $s < `size $UVs`; $s++)
@Onefabis
Onefabis / Referenced_toggle.py
Created April 12, 2016 12:36
Toggle all visible layers in 'layer editor' to Referenced/None state
layers = cmds.ls( type='displayLayer')
global chLayViz
#Checks if 'chLayViz' variable exists and if not - assign 'None'
try:
chLayViz
except NameError:
chLayViz = None
# Assign toggle value to 'chLayViz' var
@Onefabis
Onefabis / SaveMayaSceneWithRightNumber.py
Last active December 13, 2018 06:51
Saves the new version of the file with right numeric postfix. For instance, ex.ma will be saved as ex_01.ma. ex_02.ma will be saved as ex_03.ma, etc.
import maya.cmds as cmds
import re
import maya.mel as mel
def MSpress():
global initTS
initTS = cmds.timerX()
def MSrelease():
global initTS