def nla_w_pre(self, context): layout = self.layout basic_pre(self, context) layout.separator() layout.operator('zpy.select_from_strips') layout.separator() layout.operator('anim.channels_clean_empty') layout.operator('nla.action_sync_length', text='Sync Action length Now', icon='FILE_REFRESH').active = False for (ob, strips) in Get.strips_nla(context): for item in strips: icon = ['CHECKBOX_DEHLT', 'CHECKBOX_HLT'][item.strip.use_sync_length] break else: continue break else: icon = 'NONE' layout.operator('nla.toggle_action_sync', icon=icon) layout.separator()
def preview_nla(self, context): scn = context.scene start = end = None # Set preview range using snapping (from frame_step operator) prefs = scn.step_frames stepped = prefs.on_steps frame_step = prefs.frame_step strips_nla = Get.strips_nla(context) for (obj, strips) in strips_nla: for item in strips: strip = item.strip # Scale update start value frame_start = int(strip.frame_start) if stepped: while (frame_start % frame_step): frame_start -= 1 if (start is None) or (frame_start < start): start = frame_start # Get used frame range from repeat # if (strip.repeat != 1.0): # fs = strip.frame_start # fe = strip.frame_end # fe2 = scale_range(fe, fs, fe, 0, abs(fs - fe)) # frame_end = int((1 / strip.repeat) * fe2 + fs) # else: # frame_end = int(strip.frame_end) if self.repeat: afe = strip.action_frame_end frame_end = Get.frame_from_strip(context, strip, afe) else: frame_end = strip.frame_end frame_end = round(frame_end, 4) # Update end value if stepped: while (frame_end % frame_step): frame_end += 1 if (strip.repeat > 1.0) and self.repeat: # Don't let loops end on the first frame frame_end -= 1 if (end is None) or (end < frame_end): end = frame_end if (None not in {start, end}): scn.use_preview_range = True scn.frame_preview_end = end scn.frame_preview_start = start return {'FINISHED'} else: if strips_nla: self.report({'WARNING'}, "Couldn't set preview; using default") return bpy.ops.nla.previewrange_set()
def execute(self, context): value = None for (ob, strips) in Get.strips_nla(context): for item in strips: if value is None: value = not item.strip.use_sync_length item.strip.use_sync_length = value return {'FINISHED'}
def poll(cls, context): return Get.strips_nla(context)