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
If you want to save the animation of the selected rig to the D drive as Tanuki.anim.
# 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,
)
path
str
--Specify the save destination of the animation.
D:/studiolibrary/xxx/xxx/hoge.anim
objects
[str, str, str, str]
--Specify the object to register the animation.
--The sample implementation saves the animation of the object selected in cmds.ls (sl = True)
.
frameRange
(int, int)
--Specify the range of animation to be registered.
--If you do not specify a number, the start and end of the animation will be detected automatically and registered with that value.
fileType
str
--Specify the save format for the created Maya file.
--MayaAScii
or mayaBinary
thumbnail
str
--Specify the file path of the image used for the thumbnail.
D:/studiolibrary/image/tibitanu.jpg
--When registering, the image will be copied to the .anim folder and an image called thumbnail.jpg
will be automatically generated.
comment
str
--This is a comment.
bakeConnected ――I didn't know what kind of function it was, so I turned it off. I will add it as soon as I understand it.
When you actually move it, it looks like this.
Chibitanu is good
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