0
$\begingroup$

enter image description here

enter image description here

How to properly register a FloatVectorProperty? When I do:

box.prop(self, "amb_day_color")

where amb_day_color is a FloatVectorProperty, I get an error saying property not found even though I have defined it.

class Panel_ToolBoxPrelite(bpy.types.Panel):
    bl_label = "Prelite ToolBox"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = 'BG Toolbox'

    amb_day_color: FloatVectorProperty(name="Ambient Day Color", subtype='COLOR', default=(130/255, 130/255, 130/255), min=0.0, max=1.0)
    lit_day_color: FloatVectorProperty(name="Light Day Color", subtype='COLOR', default=(170/255, 170/255, 170/255), min=0.0, max=1.0)
    amb_night_color: FloatVectorProperty(name="Ambient Night Color", subtype='COLOR', default=(30/255, 30/255, 30/255), min=0.0, max=1.0)
    lit_night_color: FloatVectorProperty(name="Light Night Color", subtype='COLOR', default=(50/255, 50/255, 50/255), min=0.0, max=1.0)

    def draw(self, context):
        layout = self.layout

        box = layout.box()
        box.label(text="Display Prelite")  
        row = box.row()
        row.operator(Operator_Display_Day_Prelite.bl_idname, text="Day")
        row.operator(Operator_Display_Off_Prelite.bl_idname, text="Off") 
        row.operator(Operator_Display_Night_Prelite.bl_idname, text="Night")
        layout.separator()
        box = layout.box()
        box.label(text="AutoPrelite")  

        box.prop(self, "amb_day_color")
        box.prop(self, "lit_day_color")[![enter image description here][1]][1]
        box.prop(self, "amb_night_color")
        box.prop(self, "lit_night_color")

        box.operator(Operator_Auto_Day_Prelite.bl_idname, text="Apply Day")
        box.operator(Operator_Auto_Night_Prelite.bl_idname, text="Apply Night")
$\endgroup$
3
  • 2
    $\begingroup$ What do you want to do? What are you trying to do? What's the context? Where do you want a property? What property is it supposed to be? What is this for? Can you describe the situation first? $\endgroup$ Commented May 7 at 9:53
  • $\begingroup$ Hello ! This is an XY problem. It should work out of the box, but you cannot add custom properties to panel classes. You should store it on an ID class, like bpy.types.Scene. Cheers $\endgroup$
    – Gorgious
    Commented May 7 at 12:28
  • $\begingroup$ Hello, Oleg, On the basis of the suggestions, I think it's fair to call this a duplicate.. if for any reason you disagree, just edit to explain why the suggestions don't work for you, and we can re-open. $\endgroup$
    – Robin Betts
    Commented May 7 at 17:26

0

Browse other questions tagged .