I have a group of objects in my scene that have animated materials. I've converted the material animations to NLA strips, and am trying to find the highest value in the list of end frames that the script is supposed to generate.
The goal is to have it so that when I have an object selected, the script searches the material NLA strip end values for all of the objects in the selected objects group, and finds the highest value in all of the strips.
Currently, it seems to print the end values for all of the strips, rather than finding the highest value among them. For example, in the blend I attached below, the highest value for the strips in the group of objects is 112, but it prints all of the values when the script is run.
Does anyone know what the problem could be?
import bpy
from random import choice
scene = bpy.context.scene
o = bpy.context.object
random_group = choice(o.users_group)
obs = random_group.objects[:]
myMaterials = bpy.data.materials
for o in obs:
myMaterials = o.data.materials
for material in myMaterials:
# Get all materials of currently selected object (if any)
if o.type == 'CURVE' or o.type == 'MESH':
if o.data.materials:
nla_strips = []
if material.animation_data is not None:
track = material.animation_data.nla_tracks
if material.animation_data and material.animation_data.nla_tracks:
for track in material.animation_data.nla_tracks:
for strip in track.strips:
nla_strips.append((strip, strip.mute))
myset = set([strip.frame_end])
print (max(myset))