def populateUi(self): frame_range_mode = configmaya.get_scene_option( const.CONFIG_FRAME_RANGE_MODE_KEY, default=const.DEFAULT_FRAME_RANGE_MODE) start_frame = configmaya.get_scene_option( const.CONFIG_FRAME_START_KEY, default=const.DEFAULT_FRAME_START) end_frame = configmaya.get_scene_option( const.CONFIG_FRAME_END_KEY, default=const.DEFAULT_FRAME_END) smart_bake_state = configmaya.get_scene_option( const.CONFIG_SMART_BAKE_KEY, default=const.DEFAULT_SMART_BAKE_STATE) from_channelbox_state = configmaya.get_scene_option( const.CONFIG_FROM_CHANNELBOX_KEY, default=const.DEFAULT_FROM_CHANNELBOX_STATE) label = const.FRAME_RANGE_MODE_VALUE_LABEL_MAP[frame_range_mode] self.frame_range_combo.setCurrentText(label) frame_range = lib.get_bake_frame_range(frame_range_mode, start_frame, end_frame) self.start_frame_spinbox.setValue(frame_range.start) self.end_frame_spinbox.setValue(frame_range.end) self.frameRangeModeIndexChangedHelper(frame_range_mode) self.smart_bake_cbox.setChecked(bool(smart_bake_state)) self.channel_box_cbox.setChecked(bool(from_channelbox_state)) return
def populateUi(self): """ Update the UI for the first time the class is created. """ name = const.CONFIG_MODE_KEY value = configmaya.get_scene_option( name, default=const.DEFAULT_MODE) value = str(value).title() LOG.debug('key=%r value=%r', name, value) self.function_comboBox.setCurrentText(value) name = const.CONFIG_WIDTH_KEY value = configmaya.get_scene_option( name, default=const.DEFAULT_WIDTH) LOG.debug('key=%r value=%r', name, value) self.width_horizontalSlider.setValue(value) self.width_spinBox.setValue(value) name = const.CONFIG_BLEND_WIDTH_KEY value = configmaya.get_scene_option( name, default=const.DEFAULT_BLEND_WIDTH) LOG.debug('key=%r value=%r', name, value) self.blendWidth_horizontalSlider.setValue(value) self.blendWidth_spinBox.setValue(value) return
def frameRangeModeIndexChanged(self, index): name = const.CONFIG_FRAME_RANGE_MODE_KEY value = const.FRAME_RANGE_MODE_VALUES[index] configmaya.set_scene_option(name, value, add_attr=True) LOG.debug('key=%r value=%r', name, value) enable_custom = value == const.FRAME_RANGE_MODE_CUSTOM_VALUE self.frameRangeStartSpinBox.setEnabled(enable_custom) self.frameRangeEndSpinBox.setEnabled(enable_custom) frame_start = configmaya.get_scene_option( const.CONFIG_FRAME_START_KEY, default=const.DEFAULT_FRAME_START) frame_end = configmaya.get_scene_option( const.CONFIG_FRAME_END_KEY, default=const.DEFAULT_FRAME_END) if value == const.FRAME_RANGE_MODE_CURRENT_FRAME_VALUE: frame_start = maya.cmds.currentTime(query=True) frame_end = frame_start elif value == const.FRAME_RANGE_MODE_TIMELINE_INNER_VALUE: frame_start, frame_end = time_utils.get_maya_timeline_range_inner() elif value == const.FRAME_RANGE_MODE_TIMELINE_OUTER_VALUE: frame_start, frame_end = time_utils.get_maya_timeline_range_outer() self.frameRangeStartSpinBox.setValue(frame_start) self.frameRangeEndSpinBox.setValue(frame_end)
def smooth_selected_keyframes(): """ Smooth the selected keyframes in the Graph Editor. Usage: 1. Select keyframes in Graph Editor. 2. Run tool 3. Keyframe values will be smoothed. """ key_attrs = maya.cmds.keyframe(query=True, name=True) or [] if len(key_attrs) == 0: msg = ( 'Please select keyframes ' '(in the Graph Editor) to smooth.' ) LOG.warning(msg) return smooth_type = configmaya.get_scene_option( const.CONFIG_MODE_KEY, default=const.DEFAULT_MODE) width = configmaya.get_scene_option( const.CONFIG_WIDTH_KEY, default=const.DEFAULT_WIDTH) blend_smooth_type = utils_const.SMOOTH_TYPE_GAUSSIAN blend_width = configmaya.get_scene_option( const.CONFIG_BLEND_WIDTH_KEY, default=const.DEFAULT_BLEND_WIDTH) undo_id = 'smoothkeyframes: ' undo_id += str(datetime.datetime.isoformat(datetime.datetime.now())) undo_id += ' ' undo_id += str(uuid.uuid4()) with undo_utils.undo_chunk_context(undo_id): for key_attr in key_attrs: selected_keyframes = maya.cmds.keyframe( key_attr, query=True, selected=True ) or [] if len(selected_keyframes) == 0: msg = ( 'Please select keyframes ' '(in the Graph Editor) to smooth.' ) LOG.warning(msg) continue lib.smooth_animcurve( key_attr, selected_keyframes, smooth_type, width, blend_smooth_type, blend_width) return
def populateUi(self): """ Update the UI for the first time the class is created. """ name = const.CONFIG_FRAME_RANGE_MODE_KEY value = configmaya.get_scene_option( name, default=const.DEFAULT_FRAME_RANGE_MODE) index = const.FRAME_RANGE_MODE_VALUES.index(value) label = const.FRAME_RANGE_MODE_LABELS[index] LOG.debug('key=%r value=%r', name, value) self.frameRangeModeComboBox.setCurrentText(label) enable_custom = value == const.FRAME_RANGE_MODE_CUSTOM_VALUE self.frameRangeStartSpinBox.setEnabled(enable_custom) self.frameRangeEndSpinBox.setEnabled(enable_custom) frame_start = configmaya.get_scene_option( const.CONFIG_FRAME_START_KEY, default=const.DEFAULT_FRAME_START) frame_end = configmaya.get_scene_option( const.CONFIG_FRAME_END_KEY, default=const.DEFAULT_FRAME_END) if value == const.FRAME_RANGE_MODE_CURRENT_FRAME_VALUE: frame_start = maya.cmds.currentTime(query=True) frame_end = frame_start elif value == const.FRAME_RANGE_MODE_TIMELINE_INNER_VALUE: frame_start, frame_end = time_utils.get_maya_timeline_range_inner() elif value == const.FRAME_RANGE_MODE_TIMELINE_OUTER_VALUE: frame_start, frame_end = time_utils.get_maya_timeline_range_outer() LOG.debug('key=%r value=%r', const.CONFIG_FRAME_START_KEY, frame_start) LOG.debug('key=%r value=%r', const.CONFIG_FRAME_END_KEY, frame_end) self.frameRangeStartSpinBox.setValue(frame_start) self.frameRangeEndSpinBox.setValue(frame_end) name = const.CONFIG_BUNDLE_ROTATE_MODE_KEY value = configmaya.get_scene_option( name, default=const.DEFAULT_BUNDLE_ROTATE_MODE) index = const.BUNDLE_ROTATE_MODE_VALUES.index(value) label = const.BUNDLE_ROTATE_MODE_LABELS[index] LOG.debug('key=%r value=%r', name, value) self.bundleRotateModeComboBox.setCurrentText(label) name = const.CONFIG_BUNDLE_UNLOCK_RELOCK_KEY value = configmaya.get_scene_option( name, default=const.DEFAULT_BUNDLE_UNLOCK_RELOCK) LOG.debug('key=%r value=%r', name, value) self.bundleUnlockRelockCheckBox.setChecked(value) return
def frameRangeModeIndexChanged(self, index): name = const.CONFIG_FRAME_RANGE_MODE_KEY value = const.FRAME_RANGE_MODE_VALUES[index] configmaya.set_scene_option(name, value, add_attr=True) LOG.debug('key=%r value=%r', name, value) enable_custom = value == const.FRAME_RANGE_MODE_CUSTOM_VALUE self.frameRangeStartSpinBox.setEnabled(enable_custom) self.frameRangeEndSpinBox.setEnabled(enable_custom) frame_start = configmaya.get_scene_option( const.CONFIG_FRAME_START_KEY, default=const.DEFAULT_FRAME_START) frame_end = configmaya.get_scene_option( const.CONFIG_FRAME_END_KEY, default=const.DEFAULT_FRAME_END) time_utils.get_frame_range(value, start_frame=frame_start, end_frame=frame_end) self.frameRangeStartSpinBox.setValue(frame_start) self.frameRangeEndSpinBox.setValue(frame_end)
def populateUi(self): """ Update the UI for the first time the class is created. """ name = const.CONFIG_FRAME_RANGE_MODE_KEY value = configmaya.get_scene_option( name, default=const.DEFAULT_FRAME_RANGE_MODE) index = const.FRAME_RANGE_MODE_VALUES.index(value) label = const.FRAME_RANGE_MODE_LABELS[index] LOG.debug('key=%r value=%r', name, value) self.frameRangeModeComboBox.setCurrentText(label) enable_custom = value == const.FRAME_RANGE_MODE_CUSTOM_VALUE self.frameRangeStartSpinBox.setEnabled(enable_custom) self.frameRangeEndSpinBox.setEnabled(enable_custom) name_start = const.CONFIG_FRAME_START_KEY name_end = const.CONFIG_FRAME_END_KEY frame_start = configmaya.get_scene_option( name_start, default=const.DEFAULT_FRAME_START) frame_end = configmaya.get_scene_option( name_end, default=const.DEFAULT_FRAME_END) frame_start, frame_end = time_utils.get_frame_range( value, start_frame=frame_start, end_frame=frame_end) LOG.debug('key=%r value=%r', name_start, frame_start) LOG.debug('key=%r value=%r', name_end, frame_end) self.frameRangeStartSpinBox.setValue(frame_start) self.frameRangeEndSpinBox.setValue(frame_end) name = const.CONFIG_BUNDLE_POSITION_MODE_KEY value = configmaya.get_scene_option( name, default=const.DEFAULT_BUNDLE_POSITION_MODE) index = const.BUNDLE_POSITION_MODE_VALUES.index(value) label = const.BUNDLE_POSITION_MODE_LABELS[index] LOG.debug('key=%r value=%r', name, value) self.bundlePositionModeComboBox.setCurrentText(label) name = const.CONFIG_DELETE_STATIC_ANIM_CURVES_KEY value = configmaya.get_scene_option( name, default=const.DEFAULT_DELETE_STATIC_ANIM_CURVES) LOG.debug('key=%r value=%r', name, value) self.deleteStaticAnimCurvesCheckBox.setChecked(value) return
def main(): nodes = maya.cmds.ls(selection=True) if len(nodes) == 0: LOG.warn("Please select at least 1 object.") return # Get configuration values frame_range_mode = configmaya.get_scene_option( const.CONFIG_FRAME_RANGE_MODE_KEY, const.DEFAULT_FRAME_RANGE_MODE) custom_start_frame = configmaya.get_scene_option( const.CONFIG_FRAME_START_KEY, const.DEFAULT_FRAME_START) custom_end_frame = configmaya.get_scene_option(const.CONFIG_FRAME_END_KEY, const.DEFAULT_FRAME_END) smart_bake_state = configmaya.get_scene_option( const.CONFIG_SMART_BAKE_KEY, const.DEFAULT_SMART_BAKE_STATE) from_channelbox_state = configmaya.get_scene_option( const.CONFIG_FROM_CHANNELBOX_KEY, const.DEFAULT_FROM_CHANNELBOX_STATE) frame_range = lib.get_bake_frame_range(frame_range_mode, custom_start_frame, custom_end_frame) attrs = _get_attributes(from_channelbox_state) # Bake attributes s = time.time() ctx = tools_utils.tool_context( use_undo_chunk=True, restore_current_frame=True, use_dg_evaluation_mode=True, disable_viewport=True, disable_viewport_mode=const_utils.DISABLE_VIEWPORT_MODE_VP1_VALUE) with ctx: try: lib.bake_attributes(nodes, attrs, frame_range.start, frame_range.end, smart_bake_state) except Exception as e: LOG.error(e) finally: e = time.time() LOG.warn('Bake attribute success. Time elapsed: %r secs', e - s) return
def frameRangeModeIndexChangedHelper(self, frame_range_mode): assert isinstance(frame_range_mode, pycompat.TEXT_TYPE) start_name = const.CONFIG_FRAME_START_KEY end_name = const.CONFIG_FRAME_END_KEY # Get frame range custom_start_frame = configmaya.get_scene_option( start_name, const.DEFAULT_FRAME_START) custom_end_frame = configmaya.get_scene_option(end_name, const.DEFAULT_FRAME_END) frame_range = lib.get_bake_frame_range(frame_range_mode, custom_start_frame, custom_end_frame) # Set frame range widgets self.start_frame_spinbox.setValue(frame_range.start) self.end_frame_spinbox.setValue(frame_range.end) # Disable and enable widgets based on frame range mode. if frame_range_mode == const.FRAME_RANGE_MODE_TIMELINE_INNER_VALUE: self.start_frame_spinbox.setEnabled(False) self.end_frame_spinbox.setEnabled(False) self.smart_bake_cbox.setEnabled(True) elif frame_range_mode == const.FRAME_RANGE_MODE_TIMELINE_OUTER_VALUE: self.start_frame_spinbox.setEnabled(False) self.end_frame_spinbox.setEnabled(False) self.smart_bake_cbox.setEnabled(True) elif frame_range_mode == const.FRAME_RANGE_MODE_CUSTOM_VALUE: self.start_frame_spinbox.setEnabled(True) self.end_frame_spinbox.setEnabled(True) self.smart_bake_cbox.setEnabled(False) self.smart_bake_cbox.setChecked(False) # Set the custom frame values configmaya.set_scene_option(start_name, frame_range.start, add_attr=True) configmaya.set_scene_option(end_name, frame_range.end, add_attr=True) return
def smooth_selected_keyframes(): """ Smooth the selected keyframes in the Graph Editor. Usage:: 1) Select keyframes in Graph Editor. 2) Run tool 3) Keyframe values will be smoothed. """ key_attrs = maya.cmds.keyframe(query=True, name=True) or [] if len(key_attrs) == 0: msg = ('Please select keyframes ' '(in the Graph Editor) to smooth.') LOG.warning(msg) return for key_attr in key_attrs: selected_keyframes = maya.cmds.keyframe( key_attr, query=True, selected=True) or [] if len(selected_keyframes) == 0: msg = ('Please select keyframes ' '(in the Graph Editor) to smooth.') LOG.warning(msg) continue smooth_type = configmaya.get_scene_option(const.CONFIG_MODE_KEY, default=const.DEFAULT_MODE) width = configmaya.get_scene_option(const.CONFIG_WIDTH_KEY, default=const.DEFAULT_WIDTH) blend_smooth_type = utils_const.SMOOTH_TYPE_GAUSSIAN blend_width = configmaya.get_scene_option( const.CONFIG_BLEND_WIDTH_KEY, default=const.DEFAULT_BLEND_WIDTH) lib.smooth_animcurve(key_attr, selected_keyframes, smooth_type, width, blend_smooth_type, blend_width) return
def populateUi(self): """ Update the UI for the first time the class is created. """ name = const.CONFIG_FRAME_RANGE_MODE_KEY value = configmaya.get_scene_option( name, default=const.DEFAULT_FRAME_RANGE_MODE) index = const.FRAME_RANGE_MODE_VALUES.index(value) label = const.FRAME_RANGE_MODE_LABELS[index] LOG.debug('key=%r value=%r', name, value) self.frameRangeModeComboBox.setCurrentText(label) enable_custom = value == const.FRAME_RANGE_MODE_CUSTOM_VALUE self.frameRangeStartSpinBox.setEnabled(enable_custom) self.frameRangeEndSpinBox.setEnabled(enable_custom) frame_start = configmaya.get_scene_option( const.CONFIG_FRAME_START_KEY, default=const.DEFAULT_FRAME_START) frame_end = configmaya.get_scene_option( const.CONFIG_FRAME_END_KEY, default=const.DEFAULT_FRAME_END) if value == const.FRAME_RANGE_MODE_TIMELINE_INNER_VALUE: frame_start, frame_end = time_utils.get_maya_timeline_range_inner() elif value == const.FRAME_RANGE_MODE_TIMELINE_OUTER_VALUE: frame_start, frame_end = time_utils.get_maya_timeline_range_outer() LOG.debug('key=%r value=%r', const.CONFIG_FRAME_START_KEY, frame_start) LOG.debug('key=%r value=%r', const.CONFIG_FRAME_END_KEY, frame_end) self.frameRangeStartSpinBox.setValue(frame_start) self.frameRangeEndSpinBox.setValue(frame_end) name = const.CONFIG_BAKE_MODE_KEY value = configmaya.get_scene_option(name, default=const.DEFAULT_BAKE_MODE) index = const.BAKE_MODE_VALUES.index(value) label = const.BAKE_MODE_LABELS[index] LOG.debug('key=%r value=%r', name, value) self.rotateOrderModeComboBox.setCurrentText(label) name = const.CONFIG_ROTATE_ORDER_MODE_KEY value = configmaya.get_scene_option( name, default=const.DEFAULT_ROTATE_ORDER_MODE) index = const.ROTATE_ORDER_MODE_VALUES.index(value) label = const.ROTATE_ORDER_MODE_LABELS[index] LOG.debug('key=%r value=%r', name, value) self.rotateOrderModeComboBox.setCurrentText(label) name = const.CONFIG_DELETE_STATIC_ANIM_CURVES_KEY value = configmaya.get_scene_option( name, default=const.DEFAULT_DELETE_STATIC_ANIM_CURVES) LOG.debug('key=%r value=%r', name, value) self.deleteStaticAnimCurvesCheckBox.setChecked(value) return
def main(): """Ray-casts each bundle connected to the selected markers on to the mesh from the associated camera. Select markers and mesh objects to ray-cast on to, if no mesh objects are selected the tool will ray-cast on to all visible mesh objects. If a bundle translate attribute is locked, it will be unlocked, then projected, and then the lock state will be reverted to the original value. .. note:: The Marker node is the origin point of the ray-cast, *not* the camera's pivot position. This is intentional. If the user has a single dense (LIDAR) model node it can be helpful to project from a distance away from the camera origin. With a single dense mesh it is difficult to split the model up to use different mesh selections. Example:: >>> import mmSolver.tools.raycastmarker.tool as tool >>> tool.main() """ selection = maya.cmds.ls(selection=True) or [] if not selection: LOG.warning('Please select a marker to rayCast.') return node_categories = mmapi.filter_nodes_into_categories(selection) mkr_node_list = node_categories['marker'] bnd_node_list = node_categories['bundle'] cam_node_list = node_categories['camera'] if len(mkr_node_list) == 0 and len(bnd_node_list) == 0: LOG.warn('Please select markers or bundles to ray-cast.') return # The camera used to determine where bundles will be projected from. active_cam_tfm, active_cam_shp = _get_active_or_selected_camera( cam_node_list) # Get Markers mkr_list, use_camera = _get_markers(mkr_node_list, bnd_node_list, active_cam_shp) if use_camera and active_cam_shp is None: LOG.warn('Please activate a viewport to ray-cast Bundles from.') frame_range_mode = configmaya.get_scene_option( const.CONFIG_FRAME_RANGE_MODE_KEY, default=const.DEFAULT_FRAME_RANGE_MODE) frame_start = configmaya.get_scene_option( const.CONFIG_FRAME_START_KEY, default=const.DEFAULT_FRAME_START) frame_end = configmaya.get_scene_option(const.CONFIG_FRAME_END_KEY, default=const.DEFAULT_FRAME_END) if frame_range_mode == const.FRAME_RANGE_MODE_CURRENT_FRAME_VALUE: frame_start = int(maya.cmds.currentTime(query=True)) frame_end = frame_start elif frame_range_mode == const.FRAME_RANGE_MODE_TIMELINE_INNER_VALUE: frame_start, frame_end = time_utils.get_maya_timeline_range_inner() elif frame_range_mode == const.FRAME_RANGE_MODE_TIMELINE_OUTER_VALUE: frame_start, frame_end = time_utils.get_maya_timeline_range_outer() frame_range = time_utils.FrameRange(frame_start, frame_end) use_smooth_mesh = True bundle_unlock_relock = configmaya.get_scene_option( const.CONFIG_BUNDLE_UNLOCK_RELOCK_KEY, default=const.DEFAULT_BUNDLE_UNLOCK_RELOCK) # Do not disable the viewport if we're only baking a single frame. disable_viewport = True if frame_range.start == frame_range.end: disable_viewport = False mesh_nodes = _get_selected_meshes() with tools_utils.tool_context(use_undo_chunk=True, restore_current_frame=True, use_dg_evaluation_mode=True, disable_viewport=disable_viewport): bnd_nodes = lib.raycast_markers_onto_meshes( mkr_list, mesh_nodes, frame_range=frame_range, unlock_bnd_attrs=bundle_unlock_relock, relock_bnd_attrs=bundle_unlock_relock, use_smooth_mesh=use_smooth_mesh) if len(bnd_nodes) > 0: maya.cmds.select(bnd_nodes) else: maya.cmds.select(selection) return
def reparent(children, parent): """ Reparent 'children' nodes under 'parent' node. If 'parent' is None, the children are unparented to world. All settings are taken from the UI's defaults. To change these, please use the UI (or 'configmaya' module) """ children_nodes = [tfm_utils.TransformNode(node=n) for n in children] parent_node = None if parent is not None: parent_node = tfm_utils.TransformNode(node=parent) # Get all saved re-parent options. frame_range_mode = configmaya.get_scene_option( const.CONFIG_FRAME_RANGE_MODE_KEY, default=const.DEFAULT_FRAME_RANGE_MODE) start_frame = configmaya.get_scene_option( const.CONFIG_FRAME_START_KEY, default=const.DEFAULT_FRAME_START) end_frame = configmaya.get_scene_option( const.CONFIG_FRAME_END_KEY, default=const.DEFAULT_FRAME_END) bake_mode = configmaya.get_scene_option( const.CONFIG_BAKE_MODE_KEY, default=const.DEFAULT_BAKE_MODE) rotate_order = configmaya.get_scene_option( const.CONFIG_ROTATE_ORDER_MODE_KEY, default=const.DEFAULT_ROTATE_ORDER_MODE) delete_static_anim_curves = configmaya.get_scene_option( const.CONFIG_DELETE_STATIC_ANIM_CURVES_KEY, default=const.DEFAULT_DELETE_STATIC_ANIM_CURVES) viewport_mode = const_utils.DISABLE_VIEWPORT_MODE_VP1_VALUE # Check the children nodes and prompt the user what to do prompt_user, settable_map, full_msg, confirm_msg = \ __check_modify_nodes(children) if prompt_user is True: LOG.warn(full_msg) cancel_button = 'Cancel' continue_button = 'Continue' button = maya.cmds.confirmDialog( title='Warning: Cannot Modify Nodes.', message=confirm_msg, button=[continue_button, cancel_button], defaultButton=continue_button, cancelButton=cancel_button, dismissString=cancel_button) if button == cancel_button: LOG.warn('User canceled Re-parent.') return with tools_utils.tool_context(disable_viewport=True, use_undo_chunk=True, use_dg_evaluation_mode=False, restore_current_frame=True, pre_update_frame=False, disable_viewport_mode=viewport_mode): lib.reparent( children_nodes, parent_node, frame_range_mode=frame_range_mode, start_frame=start_frame, end_frame=end_frame, bake_mode=bake_mode, rotate_order_mode=rotate_order, delete_static_anim_curves=bool(delete_static_anim_curves), ) nodes = [tn.get_node() for tn in children_nodes] maya.cmds.select(nodes, replace=True) # Trigger Maya to refresh. maya.cmds.refresh(currentView=True, force=False) return
def main(frame_range_mode=None, start_frame=None, end_frame=None, bundle_position_mode=None, delete_static_anim_curves=None): """ Convert all selected transforms into 2D markers under a camera. :param frame_range_mode: The type of frame range to use, see 'mmSolver.utils.constant.FRAME_RANGE_MODE_*_VALUE' for more details. :type frame_range_mode: FRAME_RANGE_MODE_*_VALUE :param start_frame: The first frame to start converting the transform to a Marker. :type start_frame: int or None :param end_frame: The last frame to end converting the transform to a Marker. :type end_frame: int or None :param bundle_position_mode: The position for the newly created Bundle (connected to the Marker). :type bundle_position_mode: None or BUNDLE_POSITION_MODE_* :param delete_static_anim_curves: When enabled, this will remove all keyframes from the bundle, if the bundle is not animated. :type delete_static_anim_curves: bool """ if frame_range_mode is None: value = configmaya.get_scene_option( const.CONFIG_FRAME_RANGE_MODE_KEY, default=const.DEFAULT_FRAME_RANGE_MODE) assert value in const.FRAME_RANGE_MODE_VALUES frame_range_mode = value if start_frame is None or end_frame is None: start_frame = configmaya.get_scene_option( const.CONFIG_FRAME_START_KEY, default=const.DEFAULT_FRAME_START) end_frame = configmaya.get_scene_option( const.CONFIG_FRAME_END_KEY, default=const.DEFAULT_FRAME_END) if bundle_position_mode is None: value = configmaya.get_scene_option( const.CONFIG_BUNDLE_POSITION_MODE_KEY, default=const.DEFAULT_BUNDLE_POSITION_MODE) bundle_position_mode = value if delete_static_anim_curves is None: value = configmaya.get_scene_option( const.CONFIG_DELETE_STATIC_ANIM_CURVES_KEY, default=const.DEFAULT_DELETE_STATIC_ANIM_CURVES) delete_static_anim_curves = value # Frame range time_utils.get_frame_range(frame_range_mode, start_frame=start_frame, end_frame=end_frame) # Get camera model_editor = utils_viewport.get_active_model_editor() if model_editor is None: msg = 'Please select an active 3D viewport.' LOG.warning(msg) return cam_tfm, cam_shp = utils_viewport.get_viewport_camera(model_editor) if cam_shp is None: LOG.error('Please select an active viewport to get a camera.') return if utils_camera.is_startup_cam(cam_shp) is True: LOG.error("Cannot create Markers in 'persp' camera.") return # Get transforms tfm_nodes = maya.cmds.ls( selection=True, long=True, type='transform', ) or [] if len(tfm_nodes) == 0: LOG.warning('Please select one or more transform nodes.') return # Must ensure the plug-in is loaded, otherwise we won't have all # the functionality required. mmapi.load_plugin() with tools_utils.tool_context(pre_update_frame=True): mkr_nodes, bnd_nodes = lib.create_markers_from_transforms( cam_tfm, cam_shp, tfm_nodes, start_frame, end_frame, bundle_position_mode, delete_static_anim_curves) if len(mkr_nodes) > 0: maya.cmds.select(mkr_nodes, replace=True) return