0
$\begingroup$

I am trying to create variables from user input gathered in a UI panel that I can use in other python files (modules) to create geometry. The goal would also be to be able to procedurally update the mesh automatically every time the input changes. How can I create the variables to do this? I wwas told to create an init function in my properties class and make and object, but I'm a little lost on that. Any help is appreciated.

properties.py

class CabinetProperties(bpy.types.PropertyGroup):
    def __init__(self, cabinetWidth, cabinetDepth, cabinetHeight, cabinetType, flushDoors):
        self.cabinetWidth = cabinetWidth
        self.cabinetDepth = cabinetDepth
        self.cabinetHeight = cabinetHeight
        self.cabinetType = cabinetType
        self.flushDoors = flushDoors

    cabinetWidth : bpy.props.FloatProperty(name = "Cabinet Width", soft_min = 0, soft_max = 1000)
    cabinetDepth : bpy.props.FloatProperty(name = "Cabinet Depth", soft_min = 0, soft_max = 1000)
    cabinetHeight : bpy.props.FloatProperty(name = "Cabinet Height", soft_min = 0, soft_max = 1000)

    cabinetType : bpy.props.EnumProperty(
        name = "Cabinet Type",
        description = "Choose Your Cabinet Type",
        items = [('upperCabinet',"Upper Cabinet", ""),
                 ('baseCabinet',"Base Cabinet", "")
        ]
    )

    flushDoors : bpy.props.BoolProperty(
        name = "Flush Doors",
        default = False
    )

panel.py

class CABINET_PT_Panel(bpy.types.Panel):
    bl_idname = "CABINET_PT_Panel"
    bl_label = "Cabinet"
    bl_category = "Archviz Addon"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"

    def draw(self, context):
        layout = self.layout
        scene = context.scene
        mytool = scene.my_tool

        layout.prop(mytool, "cabinetType", expand = True)
        layout.prop(mytool, "cabinetWidth")
        layout.prop(mytool, "cabinetDepth")
        layout.prop(mytool, "cabinetHeight")
        layout.prop(mytool, "flushDoors")
        
        row = layout.row()
        row.operator('view3d.build_cabinet', text = "Built Cabinet")
$\endgroup$

0

You must log in to answer this question.

Browse other questions tagged .