Skip to content

Maya Examples

Daniele Federico edited this page Sep 7, 2018 · 6 revisions

Export/Import a kb file in Maya

import tempfile
from kiko.apps.maya import manager
from kiko.constants import KB_FILE_EXTENSION

manager = manager.MayaKikoManager()
kb_file = tempfile.mkstemp(suffix=KB_FILE_EXTENSION)

# this will export the selected objects
manager.export_to_file(kb_file)

# import the kb file trying to find the objects with the same name as the ones originally exported
manager.import_from_file(kb_file, ignore_item_chunks=True)

Export/Import a kb file from Maya and applying it to a different object

import tempfile
from maya import cmds
from kiko.apps.maya import manager
from kiko.constants import KB_FILE_EXTENSION

manager = manager.MayaKikoManager()
kb_file = tempfile.mkstemp(suffix=KB_FILE_EXTENSION)

# this will export the selected objects
cmds.select("locator1")
manager.export_to_file(kb_file)

# import the kb file onto locator2 mapping the original name "locator1" to "locator2"
obj_mapping = {"locator1": "locator2"}
manager.import_from_file(kb_file, objects=["locator2"], obj_mapping=obj_mapping, ignore_item_chunks=True)

Export/Import a kb file from Maya and applying it to a namespaced object

import tempfile
from maya import cmds
from kiko.apps.maya import manager
from kiko.constants import KB_FILE_EXTENSION

manager = manager.MayaKikoManager()
kb_file = tempfile.mkstemp(suffix=KB_FILE_EXTENSION)

# this will export the selected objects
cmds.select("locator1")
manager.export_to_file(kb_file)

# import the kb file onto locator2 mapping the original name "locator1" to "testNS:locator1"
cmds.select("testNS:locator1")
manager.import_from_file(kb_file, prefix_to_add="testNS:", ignore_item_chunks=True)
Clone this wiki locally