Hi!
I am trying to get the index of a stroke in a GPencilFrame’s strokes bpy_prop_collection. The bpy_prop_collection has a method called find. The documentation says that it accepts key
as a parameter which is a string identifier for the collection member.
How do I get this key
in, say, a for loop iteration? When I use the keys()
method for a Grease Pencil’s Strokes bpy_prop_collection it returns an empty list. If I cast the collection as a List type, I can use Python’s index
method, but I would like to understand find
. Thank you!
for stroke in layer.active_frame.strokes:
for pt in stroke.points:
if pt == point: #point is a selected point
print("keys",layer.active_frame.strokes.keys()) # []
#print(layer.active_frame.strokes.find(s)) # returns an exception set
print(list(layer.active_frame.strokes).index(s)) # 0
return stroke