krathjen / studiolibrary

Studio Library
https://www.studiolibrary.com
GNU Lesser General Public License v3.0
353 stars 141 forks source link

Procedural creation of folders/animation data #431

Closed can-adrian closed 1 year ago

can-adrian commented 1 year ago

Hi! Working in maya was wondering if there is any examples of creating poses/data without the UI? Or with the UI with some automation? looking to try and ingest a larger amount of animation in to studio library without having to do it manually

can-adrian commented 1 year ago

made a bit of progress digging around in mutils but get an error when I run in a shell in maya (in the UI everything works fine) (get the same error in maya 2023)


import mutils
mutils.saveAnim(
    path="/shows/test/test.anim", 
    objects=["pSphere1"],
    time=(1, 20),
    metadata={'description': 'Example anim'}
    )

#   File "<maya console>", line 8, in <module>
#   File "../studio_library/2.9.6.b3/platform-linux/mutils/animation.py", line 135, in saveAnim
#     bakeConnected=bakeConnected
#   File "../studio_library/2.9.6.b3/platform-linux/mutils/decorators.py", line 42, in wrapped
#     ret = fn(*args, **kwargs)
#   File "../studio_library/2.9.6.b3/platform-linux/mutils/decorators.py", line 55, in wrapped
#     return fn(*args, **kwargs)
#   File "../studio_library/2.9.6.b3/platform-linux/mutils/decorators.py", line 133, in wrapped
#     return fn(*args, **kwargs)
#   File "../studio_library/2.9.6.b3/platform-linux/mutils/decorators.py", line 102, in wrapped
#     return fn(*args, **kwargs)
#   File "../studio_library/2.9.6.b3/platform-linux/mutils/animation.py", line 677, in save
#     self.cleanMayaFile(mayaPath)
#   File "../studio_library/2.9.6.b3/platform-linux/mutils/animation.py", line 546, in cleanMayaFile
#     for line in f.readlines():
#   File "../maya/2022.3.0.0/platform-linux/maya/lib/python3.7/codecs.py", line 322, in decode
#     (result, consumed) = self._buffer_decode(data, self.errors, final)
# UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb4 in position 15: invalid start byte # 
can-adrian commented 1 year ago

Ah, I think I figured it out, in the example code file type is not specified but studio library requires maya ascii to do the stripping out


#from studiolibrary import mutils

import mutils
mutils.saveAnim(
    path="/mypath", 
    objects=['pSphere1','pSphere2'],
    time=(1, 20),
    metadata={'description': 'Example anim'},
    fileType='mayaAscii',  # <---- add this argument
    bakeConnected=False
    )