def dump(root=None, file_path=None):
"""Dump the hierarchy data starting at root to disk.
:param root: Root node of the hierarchy.
:param file_path: Export json path.
:return: The hierarchy data that was exported.
"""
if root is None:
root = cmds.ls(sl=True)
if root:
root = root[0]
else:
return
if file_path is None:
file_path = cmds.fileDialog2(fileFilter='Skeleton Files (*.json)', dialogStyle=2, caption='Export Skeleton',
fileMode=0, returnFilter=False)
if file_path:
file_path = file_path[0]
else:
return
data = get_data(root)
fh = open(file_path, 'w')
json.dump(data, fh, indent=4)
fh.close()
logger.info('Exported skeleton to %s', file_path)
return data, file_path
评论列表
文章目录