Try operating Studio Library from Python. [Anim Save]

I will show you how to operate animation registration in Studio Library from Python.

Samples are available on the creator's GitHub, so it is recommended that you check this first. https://github.com/krathjen/studiolibrary/blob/master/src/studiolibrarymaya/README.md

environment

Animation registration

If you want to save the animation of the selected rig to the D drive as Tanuki.anim.

script

# studiolibrary2.7.1
import os
import maya.cmds as cmds
from studiolibrarymaya import animitem

path    = os.path.join("D:/studiolibrary/root/dev", "Tanuki.anim")
objects = cmds.ls(selection=True) or []

# Saving an animation item
if objects :
    animitem.save(
        path, 
        objects         = objects, 
        frameRange      = (0, 40),
        fileType        = "mayaAscii",
        thumbnail       = "D:/studiolibrary/image/tibitanu.jpg ",
        comment         = "This is Tanuki",
        bakeConnected   = False,
        )

Explanation of flags used in save

Execution result

When you actually move it, it looks like this.

image.png

image.png Chibitanu is good

For versions prior to studiolibrary 2.5.7

If you are using a version earlier than studiolibrary 2.5.7, the writing method is slightly different. Note that you need to instantiate the item once.

# studiolibrary2.5.7
import os
import maya.cmds as cmds
from studiolibrarymaya import animitem

path    = os.path.join("D:/studiolibrary/root/dev", "Tanuki.anim")
objects = cmds.ls(selection=True) or []

item = animitem.AnimItem(path)

# Saving an animation item
if objects :
    item.save(
        objects         = objects, 
        frameRange      = (0, 40),
        fileType        = "mayaAscii",
        bakeConnected   = False,
        )

Next time, I will write how to load animation in Studio Library using Python.

Recommended Posts

Try operating Studio Library from Python. [Anim Save]
Try IAM Database Authentication from Python
Try using Amazon DynamoDB from Python
Try operating Nifty Cloud MQTT from C4SA
Try python
Try HTML scraping with a Python library
Try calling Python from Ruby with thrift
Try Juniper JUNOS PyEz (python library) Memo 1 ~ PyEz Overview ~
Call Python library for text normalization from MATLAB
Try accessing the YQL API directly from Python 3
Registering with PyPI from modern Python library self-made
Python 3.6 email library
Python> try: / except:
sql from python
Install PyCall on Raspberry PI and try using GPIO's library for Python from Ruby
MeCab from Python
Python Library notes
Translator in Python from Visual Studio 2017 (Microsoft Translator Text API)
App development to tweet in Python from Visual Studio 2017
Try debugging Python on Raspberry Pi with Visual Studio.
I wanted to use the Python library from MATLAB