mayametaautodeskalembic-format

How to add new meta data to alembic file in maya?


I want to add some extra information into the exists abc file or if its possible while creating alembic cache with some extra information in maya or any cg application using pyhon. I am appreciate any one can help me to edit the alembic file.

input example

meta_data = {'name': 'Hero', 'tag': 'test_show'}
abc_file = '/show/test_show/scene/hero.abc'

set meta data ?

from alembic import Abc

get meta data

from alembic import Abc

archive = Abc.IArchive(abc_file)
top = archive.getTop()
meta_data = top.getMetaData()
print meta_data__str()

Solution

  • You can't write just arbitrary data but you can set description and application strings:

    from alembic import Abc
    
    MY_APP = 'My cool application'
    
    
    def write(abc_file, description):
        archive = Abc.CreateArchiveWithInfo(abc_file, MY_APP, description) 
    
    def read(abc_file):
        archive = Abc.IArchive(abc_file)
        top = archive.getTop()
        return Abc.GetArchiveInfo(archive)
    
    abc_file = 'alembic.abc'
    write(abc_file, 'An abc file cool description')
    archive_info = read(abc_file)
    print(archive_info.get('appName'))
    print(archive_info.get('userDescription'))
    print(archive_info.get('whenWritten'))