The questions keep coming, I know. I cannot find this simple answer anywhere. It may be because I'm not sure exactly how to phrase it in searches.
Is it possible to declare a variable of a custom type that is derived from
I have a situation where I create controls for the active object. But I would like to show these controls in a disabled state when there is no active object (or any object at all). So my (possibly terrible) idea is to declare a local variable of the property group used by objects and use the data in this temporary property group to draw the buttons and controls. I know I can just skip drawing the associated controls, but I don't like how disruptive it is to have the panel contents shift around when it happens.
Here is an example of what I mean:
class MyClass(bpy.types.PropertyGroup): Var : BoolProperty( name = "Stuff", description = "my stuff", default=False ) def draw_panel(): if active_object: draw_buttons(active_object.MyProperties, disabled=false) else: temp_props = MyClass() draw_buttons(temp_props, disabled=true)
So the controls would be associated with a temporary property object. However, the code
temp_props = MyClass() does not work. It appears that
bpy_struct requires some type of "constructor parameter" (I'm not sure what these are called in python)?
If there is a better way to handle this, please feel free to slap me out of this idea. And in either case, how would one go about declaring a class derived from a property group or
bpy_struct locally within a function? Is it even possible? I can't seem to find anything in the API docs about initializing one of these objects on our own.