Skip to content

Maya Examples

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

Initializing Kiko

from kiko import initialize
initialize()

Export/Import a kb file in Maya

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

man = manager.MayaKikoManager()
_, kb_file = tempfile.mkstemp(suffix=KB_FILE_EXTENSION)

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

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

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

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

man = manager.MayaKikoManager()
_, kb_file = tempfile.mkstemp(suffix=KB_FILE_EXTENSION)

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

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

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

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

man = manager.MayaKikoManager()
_, kb_file = tempfile.mkstemp(suffix=KB_FILE_EXTENSION)

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

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

UIs

from kiko.apps.maya.ui import exporter
d = exporter.MayaExporterDialog()
d.show()

from kiko.apps.maya.ui import importer
d = importer.MayaImporterDialog()
d.show()