Pages

Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Monday, 4 December 2023

Getting Maya version - it might be confusing, the return value is unicode (sort of string). So for comparing version, it's ideal to convert to INT first.


import maya.cmds as mc
mayaVersion = int( mc.about(v=True) )

if mayaVersion > 2020:
dosomething()

Tuesday, 10 May 2022

Little hint for Autodesk Maya to edit keyframe node values using keyframe command :









mc.keyframe('r_tread_jt_02_path_uValue',e=True,index=(0,0), floatChange=0.05)

mc.keyframe('r_tread_jt_02_path_uValue',e=True,index=(1,1), floatChange=1.1)


mc.keyframe('r_tread_jt_02_path_uValue',e=True,index=(0,0), valueChange=0.1)

mc.keyframe('r_tread_jt_02_path_uValue',e=True,index=(1,1), valueChange=2.5)

Friday, 23 August 2019

Maya - get FramesPerSecond setting by script

Here is small script snippet to get Maya settinsg for Frames Per Second playback settings. This is actually not straightforward.

Here is example how to get this in python:

import maya.cmds as mc

framesRateInSecondStr = mc.currentUnit( q = True, time = True )
    framesRateInSecondOptions = { 'game':15, 'film':24, 'pal':25, 'ntsc':30, 'show':48, 'palf':50, 'ntscf':60 }
    if 'fps' in framesRateInSecondStr:
       
        fpsStr = framesRateInSecondStr.replace( 'fps', '' )
        framesRateInSecond = float( fpsStr )
       
    else:
       
        framesRateInSecond = framesRateInSecondOptions[framesRateInSecondStr]



Saturday, 29 December 2018

Thursday, 18 May 2017

Maya python UI passing argument in command

Here is example of Maya UI code in case you need to build in a command to UI element which passes an argument.
More about this technique here:
http://download.autodesk.com/us/maya/2011help/pymel/ui.html

Note - this is all one function myUI(), where buttonPressed is function defined inside that function. It doesn`t have to be, but this way it is localised and only visible to the UI function.

import maya.cmds as mc

def myUI():

    def buttonPressed(name):
        print "pressed %s!" % name

    win = mc.window(title="My Window")
    layout = mc.columnLayout()
    btn = mc.button( command = lambda *args: buttonPressed('chad') )

    showWindow()



Sunday, 24 April 2016

Eclipse installation

For users of Eclipse or those who are thinking about using Eclipse. I just tested new Eclipse installer and it just works great. No Error Code 13 and such things with Java. Saying that I had JVM (Java Virtual Machine) already installed. But this is the most simple installation. Tested on Windows 7 64 bit. Just follow this link:
https://wiki.eclipse.org/Eclipse/Installation

For those programming with Python choose C/C++ build and then once running Eclipse, go to Help / Install New Software to add PyDev extension. More about that here:
http://www.pydev.org/download.html
 

Friday, 22 April 2016

Kate text editor - remove new lines

Here is one tip in case you work with Kate text editor - commonly found on linux distribution of Kubuntu.

In case you want to remove all new lines "\n" - merge lines into one, just select the lines you want to merge and press Ctrl + j.

This is operation which can save you a lot of time. For example if you copy paste printed python list from Maya and want to put this result to a list defintion in your python script in Kate.


Sunday, 10 April 2016

Maya.env tips

Since I had to fix something with my Maya.env file I thought it would be good to also share some example for Maya users who want to make their own Maya library in a specific place on disk or network.

Below is example of Maya.env file with custom path to MEL scripts, python scripts and plugins.
Note that plugins contain both path to python scripted plugins as well as C++ compiled plugins. Also plugins unlike scripts are stored under Maya version specific folder. Should be done for scripts too, but usually it`s not needed.

TIP: you can also use USER_SCRIPT_PATH in your Maya MEL script sourcing function. If you recursively source every subfolder from here, you have all MEL scripts available after Maya starts. This is done from a userSetup.mel which is special Maya file you can define. And as long as it is found in MAYA_SCRIPT_PATH it will be executed first after Maya starts.

TIP: By defining USER_SCRIPT_PATH you get this relative root folder and if you move your library to different place or computer, you just change this one and your library can be found by Maya again.

More about userSetup.mel here:
https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/Maya/files/PC-Run-MEL-commands-whenever-Maya-starts-up-htm.html

Autodesk documentation about defining Maya.env variables:
https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/files/GUID-DB30AAB7-4639-4C3B-A479-7F26D953E0F2-htm.html

Example Maya.env file content on Windows OS:

USER_SCRIPT_PATH = C:\Users\syntetik\Documents\maya_tools

MAYA_SCRIPT_PATH = %USER_SCRIPT_PATH%\mel\mystuff;%USER_SCRIPT_PATH%\mel\thirdparty;%USER_SCRIPT_PATH%\mel\startup
PYTHONPATH = %USER_SCRIPT_PATH%\python\

USER_PLUGIN_PATH = %USER_SCRIPT_PATH%\plugin\maya2016
MAYA_PLUG_IN_PATH = %USER_PLUGIN_PATH%\mystuff;%USER_PLUGIN_PATH%\my_scripted;%USER_PLUGIN_PATH%\thirdparty_scripted;%USER_PLUGIN_PATH%\thirdparty

Thursday, 18 February 2016

Exploring Human Muscles Setup in Maya Course


Here is my latest course on rigging human using Autodesk Maya Muscles for Digital Tutors:

Over 6 hours detailed workflow, great as an introduction to anyone learning how to use muscles in rigging. Anatomy examples and custom Python tools included. Thanks to Pavel Hruboš who did test animations and Jan Jinda for providing werewolf model.

Thursday, 16 July 2015

Maya UUID

Recently found that Maya has nice mechanism with UUID attribute on each node in the scene. I don`t know when did they add it but it`s pretty cool! Check this command which finds a lambert shader node based on its unique ID:


import maya.cmds as mc
objUUID = 'E3FABA33-4254-E1F8-6AEF-2FA0A90EBAF7'
mc.ls(objUUID)[0] 




Sunday, 28 June 2015

Cg & programming keyboard

So this is my latest keyboard. Connect IT LED illuminated. Keys are classic layout, not too hard to press but still with feedback.
Feels very comfortable for typing. I've also added soft pad to reduce the noise which comes from the table when typing. I can recommended this one. As a nice bonus there is control for volume and other multimedia functions with Fn key combination.

Monday, 16 September 2013

Maya command

this is a nice command to fit your view on objects in scene, found during work on Splash Rigging panel

import maya.cmds as mc
mc.viewFit()

Saturday, 13 July 2013

TD Channel on youtube


And here is another great looking youtube channel with videos about programming and scripting. And there is a lot of videos focused on programming for Maya. Definitely check this out if you are a Maya TD either working in pipeline or for a specific department.
http://www.youtube.com/user/TDChannel11?feature=watch

Autodesk learning channel for TDs


This is great channel which is run by Autodesk for learning their products, including Maya. I have found really good videos for making python plugins for Maya starting from a basic level. Even explaining ideal installation of my favourite python IDE, Eclipse.
http://www.youtube.com/playlist?list=PLC046B3E3DEA809D4
If you want to learn developing tools for Maya or need to be more efficient as a TD make sure to check out this channel, there might be some useful information for you.

Saturday, 25 May 2013

straps rig setup

I have been asked about strap rig setup many times by students and people learning rigging. So here is one made using Maya Muscle Spline and keepOut nodes (part of Maya Muscle) and rivet system rivetBaz (free download from creativecrash.com).

strap rig download link (Maya Binary 2012)
And here is step by step tutorial.



Wednesday, 3 April 2013

Josh Carrey from REEL FX to teach rigging at Anomalia

Based on announcement from Anomalia, czech animation summer school, rigging guru from Texas, Josh Carrey will be leading their rigging course this year! Great opportunity if you will be around and want to learn from a senior specialist in this field:


ANOMALIA 2013 Advanced Cartoon Rigging with Josh Carey [REEL FX] from ANOMALIA on Vimeo.

Saturday, 9 March 2013

Yeti used to generate feathers in Ftrack pipeline

I really like this demonstration of using Yetti in production. Swedish VFX company FIDO has made this realistic CG falcon and used new software for Fur and Feathers - Yetti. See how they handled this challenging task making realistic bird:
http://rendermansite.pixar.com/view/Fido

Yetti website:
http://peregrinelabs.com/

Also, the pipeline used at Fido is built on Ftrack. Similar to Shotgun, this is online commercial VFX production and asset management system. They currently offer less features but have also currently lower pricing then Shotgun, which is interesting. See bottom of the same page.
According to ftrack on twitter, they are working on better integration and some publishing tools for common VFX applications like Maya and Nuke and even adding support for RV as review system and Dropbox for storing assets and shots online.

Ftrack website:
http://www.ftrack.com/