def execute(self, context): active = Get.active(context) active_select = Is.selected(active) selected = Get.selected(context) is_pose = bool(context.mode == 'POSE') arg = dict(only_selected=bool(selected)) if is_pose: clear = bpy.ops.pose.paths_clear # Operator only runs on active rig, so repeat for all in pose mode if selected: obs = {b.id_data for b in selected} else: obs = {ob for ob in Get.objects(context) if ob.mode == 'POSE'} for ob in obs: Set.active(context, ob) clear(**arg) else: Set.active(context, active) Set.select(active, active_select) elif bpy.ops.object.paths_clear.poll(context.copy()): bpy.ops.object.paths_clear(**arg) return {'FINISHED'}
def execute(self, context): do_all = (self.mode == {'loc', 'rot', 'scale'}) selected = Get.selected(context, mirror=True) for src in selected: base = get_base(src) if 'loc' in self.mode: src.location = base.location if 'rot' in self.mode: if src.rotation_mode == 'QUATERNION': src.rotation_quaternion = base.rotation_quaternion elif src.rotation_mode == 'AXIS_ANGLE': src.rotation_axis_angle = base.rotation_axis_angle else: src.rotation_euler = base.rotation_euler if Is.posebone(src): src.bbone_curveinx = src.bbone_curveoutx = src.bbone_curveiny = src.bbone_curveouty = src.bbone_rollin = src.bbone_rollout = 0 if 'scale' in self.mode: src.scale = base.scale if Is.posebone(src): src.bbone_scaleinx = src.bbone_scaleinx = src.bbone_scaleiny = src.bbone_scaleoutx = src.bbone_scaleouty = 1 src.bbone_easein = src.bbone_easeout = 0 utils.clean_custom(src) keyframe.keyingset(context, selected=selected) return {'FINISHED'}
def invoke(self, context, event): # Get current pose selected = Get.selected(context, mirror=True) for src in selected: pose.base[repr(src)] = Get.matrix(src, basis=True) # Disable animation and get pose from lower layers base_anim = dict() for src in selected: obj = src.id_data anim = obj.animation_data if (anim) and (obj not in base_anim): tracks = list() if anim.use_tweak_mode: # Find the strip to disable for track in reversed(anim.nla_tracks): for _strip in track.strips: if _strip.active: strip = _strip break elif _strip.action == anim.action: # backup in case strip isn't "active" strip = _strip else: tracks.append((track, track.mute)) # track.mute = True continue break base_anim[obj] = [strip, strip.mute, tracks] strip.mute = True # anim.use_tweak_mode = False else: base_anim[obj] = [None, anim.action_influence, tracks] anim.action_influence = 0 utils.update(context) pose.reset[repr(src)] = Get.matrix(src, basis=True) # Re-enable animation for obj in base_anim: anim = obj.animation_data (strip, value, tracks) = base_anim[obj] if strip: # for (track, track_mute) in tracks: # track.mute = track_mute strip.mute = value # anim.use_tweak_mode = True else: anim.action_influence = value utils.update(context) # context.window_manager.modal_handler_add(self) # return {'RUNNING_MODAL'} return self.execute(context)
def execute(self, context): for src in Get.selected(context): if src.rotation_mode in ('QUATERNION', 'AXIS_ANGLE'): src.rotation_quaternion *= -1 for (i, r) in enumerate(src.rotation_axis_angle): src.rotation_axis_angle[i] *= -1 if keyframe.use_auto(context): keyframe.rotation(context, src) return {'FINISHED'}
def execute(self, context): fac = (self.factor / 100) selected = Get.selected(context, mirror=True) for src in selected: base = pose.base[repr(src)] reset = pose.reset[repr(src)] if src.rotation_mode in ('QUATERNION', 'AXIS_ANGLE'): euler = 'XYZ' else: euler = src.rotation_mode if Is.matrix(reset): matrix = utils.lerp(base, reset, fac) matrix = utils.matrix_to_transforms(matrix, euler=euler) else: location = base.to_translation() rotation_quaternion = base.to_quaternion() axis = base.to_quaternion().to_axis_angle() rotation_axis_angle = (*axis[0], axis[1]) rotation_euler = base.to_euler(euler) scale = base.to_scale() matrix = type( 'matrix and transforms', (), dict( location=utils.lerp(location, reset.location, fac), rotation_quaternion=utils.lerp( rotation_quaternion, reset.rotation_quaternion, fac), rotation_axis_angle=utils.lerp( rotation_axis_angle, reset.rotation_axis_angle, fac), rotation_euler=utils.lerp(rotation_euler, reset.rotation_euler, fac), scale=utils.lerp(scale, reset.scale, fac), )) if 'loc' in self.mode: src.location = matrix.location if 'rot' in self.mode: src.rotation_quaternion = matrix.rotation_quaternion src.rotation_axis_angle = matrix.rotation_axis_angle src.rotation_euler = matrix.rotation_euler if 'scale' in self.mode: src.scale = matrix.scale keyframe.keyingset(context, selected=selected) return {'FINISHED'}
def execute(self, context): selection = Get.selected(context) if not selection: selection = [Get.active(context)] for src in selection: if Is.posebone(src): mp = src.id_data.pose.animation_visualization.motion_path else: mp = src.animation_visualization.motion_path mp.type = self.type return {'FINISHED'}
def poll(cls, context): ob = context.object if Is.armature(ob) and ob.mode in ('POSE', 'EDIT'): return Get.selected(context, ob) if not bpy.ops.paint.weight_from_bones.poll(context.copy()): return if Is.mesh(ob) and (ob.mode == 'WEIGHT_PAINT'): for mod in ob.modifiers: if (mod.type == 'ARMATURE') and (mod.object in Get.objects(context)[:]): if mod.object.mode == 'POSE': return True
def execute(self, context): # # Try to use the default keyframe jumper before running manual jump. # bpy.ops.screen.keyframe_jump(next=self.next) # if (scn.frame_current_final != frame): # return {'FINISHED'} scn = context.scene sub = scn.show_subframe selected = Get.selected(context) frames = list() if context.area.type == 'SEQUENCE_EDITOR': frames = scan_sequence(context) frames = scan_annotations(context, frames, 'SEQUENCE_EDITOR') if not frames: frames = scan_actions(context, sub, selected) if not frames: frames = scan_strips(context, sub, selected) frames = scan_annotations(context, frames) # Go through list of frames insert numbers between the available frames if self.mid: pre = None mid_points = frames.copy() for f in mid_points: if pre is not None: f_mid = pre + (f - pre) / 2 if not sub: f_mid = round(f_mid) if abs(f - f_mid) >= 1.0: frames.append(f_mid) pre = f frames = sorted(set(frames)) margin = 0.01 # skip subframe if the difference between it # and the next frame is less than this margin of error # Find the next frame in line after the current frame fc = (int(scn.frame_current_final), scn.frame_current_final)[sub] if self.next: for fn in frames: if (fc < fn) and (abs(fc - fn) > margin) and (sub or (round(fn) != fc)): break else: fn = None else: for fn in reversed(frames): if (fn < fc) and (abs(fn - fc) > margin) and (sub or (round(fn) != fc)): break else: fn = None if fn is None: self.report({'INFO'}, "No more keyframes to jump to in this direction") return {'CANCELLED'} # return {'PASS_THROUGH'} fn = Get.frame_mapped(context, fn) frame = round(fn) subframe = abs(fn - frame) if (frame < 0 and subframe): # Negative numbers have to offset a little for frame_set frame -= 1 subframe = 1 - subframe if not sub: subframe = 0 # context.scene.frame_set(fn, subframe=subframe) context.scene.frame_current = fn context.scene.frame_subframe = subframe return {'FINISHED'}
def execute(self, context): scn = context.scene active = Get.active(context) selected = Get.selected(context) is_pose = bool(context.mode == 'POSE') if not is_pose: self.use_tails = False mode = ('HEADS', 'TAILS')[self.use_tails] # Use the line thickness of the active item, across the selection if getattr(active, 'motion_path', None): line = active.motion_path.line_thickness else: line = 1 colors = dict() types = dict() for src in Get.selected(context): mp = src.motion_path if not mp: continue if mp.use_custom_color: colors[src] = mp.color if Is.posebone(src): display = src.id_data.pose.animation_visualization.motion_path else: display = src.animation_visualization.motion_path types[src] = display.type # Get the frame range to bake motion paths in motion = utils.prefs(__package__).motion if self.use_start_end: start = self.start_frame end = self.end_frame elif (motion.use_relative_range) or (scn.use_preview_range): start = scn.frame_preview_start end = scn.frame_preview_end fc = scn.frame_current fb = motion.frame_before fa = motion.frame_after if not (scn.use_preview_range) or (abs(end - start) > 100 > (fb + fa)): # If the preview range is too high, just default to nearby start = fc - fb end = fc + fa else: # if (active): # # Use the active object's motion path's in_range distance # if (Is.posebone(active)): # mp = active.id_data.pose.animation_visualization.motion_path # else: # mp = active.animation_visualization.motion_path # fb = mp.frame_before # fa = mp.frame_after # if (fb < 25): fb = 25 # if (fa < 25): fa = 25 # start = scn.frame_current - fb # end = scn.frame_current + fa start = scn.frame_start end = scn.frame_end fc = scn.frame_current if 150 < abs(end - start): start = fc - 50 end = fc + 50 # Create the motion paths args = dict(start_frame=start, end_frame=end + 1) if is_pose: op = bpy.ops.pose args['bake_location'] = mode # Operator only runs on active rig, so repeat for all in pose mode obs = {b.id_data for b in selected} for ob in obs: Set.active(context, ob) op.paths_clear(only_selected=True) op.paths_calculate(**args) else: Set.active(context, active) else: op = bpy.ops.object op.paths_clear(only_selected=True) op.paths_calculate(**args) for src in selected: mp = src.motion_path if not mp: continue mp.line_thickness = line color = colors.get(src) if color: mp.color = color if Is.posebone(src): display = src.id_data.pose.animation_visualization.motion_path else: display = src.animation_visualization.motion_path display.type = types.get(src, 'CURRENT_FRAME') # Set to use the frame hider instead of ever displaying all points # if is_pose: # src.id_data.pose.animation_visualization. \ # motion_path.type = 'CURRENT_FRAME' # else: # src.animation_visualization. \ # motion_path.type = 'CURRENT_FRAME' # scn.frame_set(scn.frame_current) return {'FINISHED'}
def poll(self, context): if context.mode in ('OBJECT', 'POSE'): for src in Get.selected(context): if src.rotation_mode in ('QUATERNION', 'AXIS_ANGLE'): return True
def poll(cls, context): if not hasattr(bpy.types.PoseBone, 'base_src'): return False for src in Get.selected(context): if src.get('base_src') and src.base_src.is_duplicate: return True
def poll(cls, context): if (context.mode != 'PAINT_WEIGHT'): return Get.selected(context)
def poll(cls, context): return Get.selected(context)