Is there any way to extract an int
value from one of Blender's ENUM_FLAG
properties? Here are the definitions I have:
# binary flag values
class OpFlag:
GA = 1<<0 # activator for asset mode
LP = 1<<1 # activator for low poly mode
HP = 1<<2 # activator for high poly mode
CU = 1<<3 # activator for custom mode
# string based flag values for Blender controls
opflags=[
('GA', "Asset", "desc", OpFlag.GA ),
('LP', "Low", "desc", OpFlag.LP ),
('HP', "High", "desc", OpFlag.HP ),
('CU', "Custom", "desc", OpFlag.CU )
]
# property using flags
modes : EnumProperty(
name = "Modes",
options = {'ENUM_FLAG'},
items = opflags,
default={'GA','LP','HP','CU'}
)
This is what I would like to be able to do, if possible:
control_op_flags = int( 0 ) # just to make it obvious this is an int
control_op_flags |= int( modes )
I read somewhere online that you can cast a Blender string-based enum value to int
, but it doesn't seem to work with an enum-flags set. This is the error I get:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'set'
Does anyone know how to convert an enum-flags
set into a single int
? I didn't consider it until just now, but is it possible to iterate the set and convert/OR
all of the values together myself? Would that be the proper way to handle this? I've never iterated a set before, so going to investigate that now.
Edit Update: When I try to iterate the set and OR in one entry from it, I get the error ValueError: invalid literal for int() with base 10: 'GA'
.. Sounds like it is dealing with it purely as a string. I'm not sure how to associate it with my opflags
list.
Thanks for any advice