It seems difficult to find any information about enum-flag usage and workflow. I'm familiar with bitflags and related operations, but the blender/python specifics are fun to figure out.
Is there any clever (or possibly obvious in my case) mechanism to convert enum flags into a string? It is primarily for debugging, but user friendly would be a plus.
The way enum properties are defined in Blender makes me wonder if the flags are not already defined as a string in some way.
Edit: For example, my flags are defined like this:
FBXG_Mode=[ # mode flags ('GA', "Asset", "...", 1), ('LP', "Low", "...", 2), ('HP', "High", "...", 4), # system flags ('EXCLUDE',"","",8), ('RENAMED',"","",16), ('DELETE',"","",32), ]
And it seems we can check for flags using strings like this..
if 'GA' in MyFlags:
By the way, how exactly does this work? Does the environment process this correctly because it associates the
MyFlags variable with the
I'm very new to Python, so I have a couple questions if anyone knows the answers:
What tells the environment the attribute order of my
FBXG_Modelist? Eg, how does it know that I placed the flag names into the second column/entry? Is this just hard-coded somewhere in the Blender or Python environment? Where would I find documentation about this? I'm not sure what this is called.
How do I access an element of
FBXG_Modein a way that allows me to access the name, description, value, etc? Would it be
FBXG_Mode? I'm looking for something more like
FBXG_Mode['GA'].Description, or at least
FBXG_Mode['GA']. I would like to avoid the hard-coded indices if possible.
Is it possible to access the strings and/or properties of the
FBXG_Modelist using only the
MyFlagsvariable after it is assigned or associated with it? Does a flags variable have any type of association after it is assigned, or is the association only available during the assignment?
Is there any quick/automatic way to extract the toggled flags of a variable in string form, such as for printing text? This seems like something a generic function could be written to do, so I'm wondering if one already exists? Especially since Blender can generate UI controls basically the same way.
Thanks for any help!