0
$\begingroup$

this is the code:

class psg_Panel(bpy.types.Panel):
    bl_label = "Product scene panel"
    bl_idname = "OBJECT_PT_PSG"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "Product scene generator"
    
    b_color: bpy.props.FloatVectorProperty(
        name="Ball element Color",
        subtype="COLOR",
        default=(1.0, 1.0, 1.0),
        min=0.0,
        max=1.0
    )
    
    c_color: bpy.props.FloatVectorProperty(
        name="Platform Color",
        subtype="COLOR_GAMMA",
        size=4,
        default=(1.0, 1.0, 1.0,1.0),
        min=0.0,
        max=1.0
    )
    
    bg_color: bpy.props.FloatVectorProperty(
        name="Background Color",
        subtype="COLOR_GAMMA",
        size=4,
        default=(1.0, 1.0, 1.0,1.0),
        min=0.0,
        max=1.0
    )
    
    b_rad: bpy.props.FloatProperty(
        name="ball radius",
    )


    def draw(self, context):
        layout = self.layout
        row = layout.row()
        row.label(text="Product scene generator", icon='WORLD_DATA')
        row = layout.row()
        row.prop(self, "b_rad")        
        row = layout.row()
        row.operator("object.pro_scene_gen")

I tried it for b_rad and each colour but nothing except the button appear rest the whole addon is working properly with no error.

Screenshot of the panel

$\endgroup$
1
  • 3
    $\begingroup$ Hello. Panels can't hold custom properties. They're purely UI things. You may want to add a custom property to the current scene for example $\endgroup$
    – Gorgious
    Commented Apr 16, 2023 at 16:48

1 Answer 1

0
$\begingroup$
import bpy
from bpy.types import Panel, PropertyGroup
from bpy.props import *


class OBJECT_PG_PSG(PropertyGroup):
    
    b_color: FloatVectorProperty(
        name="Ball element Color",
        subtype="COLOR",
        default=(1.0, 1.0, 1.0),
        min=0.0,
        max=1.0
    )
    
    c_color: FloatVectorProperty(
        name="Platform Color",
        subtype="COLOR_GAMMA",
        size=4,
        default=(1.0, 1.0, 1.0,1.0),
        min=0.0,
        max=1.0
    )
    
    bg_color: FloatVectorProperty(
        name="Background Color",
        subtype="COLOR_GAMMA",
        size=4,
        default=(1.0, 1.0, 1.0,1.0),
        min=0.0,
        max=1.0
    )
    
    b_rad: FloatProperty(
        name="ball radius",
    )
    

class OBJECT_PT_PSG(Panel):
    bl_label = "Product scene panel"
    bl_idname = "OBJECT_PT_PSG"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "Product scene generator"
    
    
    def draw(self, context):
        layout = self.layout
        
        psg = context.scene.psg

        row = layout.row()
        row.label(text="Product scene generator", icon='WORLD_DATA')

        col = layout.column()
        col.use_property_split = True
        col.use_property_decorate = False
        col.prop(psg, "b_color")   
        col.prop(psg, "c_color")
        col.prop(psg, "bg_color")
        col.prop(psg, "b_rad")
     
        row = layout.row()
        row.operator("object.pro_scene_gen")
        

classes = (
    OBJECT_PG_PSG,
    OBJECT_PT_PSG,
)


def register():
    for cls in classes:
        bpy.utils.register_class(cls)

    bpy.types.Scene.psg = PointerProperty(type=OBJECT_PG_PSG)


def unregister():
    del bpy.types.Scene.psg

    for cls in reversed(classes):
        bpy.utils.unregister_class(cls)
    
    
if __name__ == '__main__':
    register()
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .