def savePose(path, objects = None, iconPath = None, metadata = None): """ Save the pose data for the given objects. Example: path = "C:/example.pose" pose = savePose(path, metadata={'description': 'Example pose'}) print pose.metadata() # {'description': 'Example pose', 'user': '******', 'mayaVersion': u'2016'} :type path: str :type objects: list[str] :rtype: mutils.Pose """ objects = objects or maya.cmds.ls(selection=True) or [] if not objects: raise Exception('No objects selected. Please select at least one object.') posePath = path + '/pose.json' iconPath_ = path + '/thumbnail.jpg' if iconPath: shutil.move(iconPath, iconPath_) else: mutils.createSnapshot(iconPath_) pose = mutils.Pose.fromObjects(objects) if metadata: pose.updateMetadata(metadata) pose.save(posePath) return pose
def saveAnim(path, objects = None, time = None, bakeConnected = False, sampleBy = 1, metadata = None): """ Save the anim data for the given objects. Example: anim = "C:/example.anim" anim = saveAnim(path, metadata={'description': 'Example anim'}) print anim.metadata() # {'description': 'Example anim', 'user': '******', 'mayaVersion': u'2016'} :type path: str :type objects: list[str] :rtype: mutils.Animation """ step = 1 objects = objects or maya.cmds.ls(selection=True) or [] if not objects: raise Exception('No objects selected. Please select at least one object.') if not time: time = mutils.animationFrameRange(objects) start, end = time if start >= end: msg = 'The start frame cannot be greater than or equal to the end frame!' raise AnimationTransferError(msg) iconPath = path + '/thumbnail.jpg' sequencePath = path + '/sequence/thumbnail.jpg' sequencePath = mutils.createSnapshot(path=sequencePath, start=start, end=end, step=step) if iconPath: shutil.copyfile(sequencePath, iconPath) anim = mutils.Animation.fromObjects(objects) if metadata: anim.updateMetadata(metadata) anim.save(path, time=time, bakeConnected=bakeConnected, sampleBy=sampleBy) return anim
def saveAnim(path, objects=None, time=None, sampleBy=1, metadata=None, bakeConnected=False): """ Save the anim data for the given objects. Example: anim = "C:/example.anim" anim = saveAnim(path, metadata={'description': 'Example anim'}) print anim.metadata() # {'description': 'test', 'user': '******', 'mayaVersion': u'2016'} :type path: str :type objects: None or list[str] :type time: None or int :type sampleBy: int :type metadata: dict or None :type bakeConnected: bool :rtype: mutils.Animation """ step = 1 objects = objects or maya.cmds.ls(selection=True) or [] if not objects: raise Exception( "No objects selected. Please select at least one object.") if not time: time = mutils.selectedObjectsFrameRange(objects) start, end = time if start >= end: msg = "The start frame cannot be greater than or equal to the end frame!" raise AnimationTransferError(msg) iconPath = path + "/thumbnail.jpg" sequencePath = path + "/sequence/thumbnail.jpg" sequencePath = mutils.createSnapshot( path=sequencePath, start=start, end=end, step=step, ) if iconPath: shutil.copyfile(sequencePath, iconPath) anim = mutils.Animation.fromObjects(objects) if metadata: anim.updateMetadata(metadata) anim.save(path, time=time, bakeConnected=bakeConnected, sampleBy=sampleBy) return anim
def savePose(path, objects=None, iconPath=None, metadata=None): """ Save the pose data for the given objects. Example: path = "C:/example.pose" pose = savePose(path, metadata={'description': 'Example pose'}) print pose.metadata() # {'description': 'Example pose', 'user': '******', 'mayaVersion': u'2016'} :type path: str :type objects: list[str] :rtype: mutils.Pose """ objects = objects or maya.cmds.ls(selection=True) or [] if not objects: raise Exception( "No objects selected. Please select at least one object." ) posePath = path + "/pose.json" iconPath_ = path + "/thumbnail.jpg" if iconPath: shutil.move(iconPath, iconPath_) else: mutils.createSnapshot(iconPath_) pose = mutils.Pose.fromObjects(objects) if metadata: pose.updateMetadata(metadata) pose.save(posePath) return pose