BallanceBlenderHelper/ballance_blender_plugin/add_floor.py

124 lines
3.3 KiB
Python
Raw Normal View History

2020-10-05 22:30:06 +08:00
import bpy,mathutils
2020-10-06 12:57:25 +08:00
import os
2020-10-05 22:30:06 +08:00
from . import utils, config
class BALLANCE_OT_add_floor(bpy.types.Operator):
"""Add Ballance floor"""
bl_idname = "ballance.add_floor"
bl_label = "Add floor"
bl_options = {'UNDO'}
floor_type: bpy.props.EnumProperty(
name="Type",
description="Floor type",
items=tuple((x, x, "") for x in config.floor_block_dict.keys()),
)
expand_length_1 : bpy.props.IntProperty(
name="D1 length",
description="The length of expand direction 1",
2020-10-06 12:57:25 +08:00
min=0,
2020-10-05 22:30:06 +08:00
default=0,
)
expand_length_2 : bpy.props.IntProperty(
name="D2 length",
description="The length of expand direction 2",
2020-10-06 12:57:25 +08:00
min=0,
2020-10-05 22:30:06 +08:00
default=0,
)
height_multiplier : bpy.props.FloatProperty(
name="Height",
description="The multiplier for height. Default height is 5",
2020-10-06 12:57:25 +08:00
min=0.0,
2020-10-05 22:30:06 +08:00
default=1.0,
)
rotation_inside_mesh: bpy.props.EnumProperty(
name="Rotation",
description="Rotation inside mesh",
items=(
("R0", "0 degree", ""),
("R90", "90 degree", ""),
("R180", "180 degree", ""),
("R270", "270 degree", "")
),
default="R0"
)
use_2d_top : bpy.props.BoolProperty(
name="Top side"
)
use_2d_right : bpy.props.BoolProperty(
name="Right side"
)
use_2d_bottom : bpy.props.BoolProperty(
name="Bottom side"
)
use_2d_left : bpy.props.BoolProperty(
name="Left side"
)
use_3d_top : bpy.props.BoolProperty(
name="Top face"
)
use_3d_bottom : bpy.props.BoolProperty(
name="Bottom face"
)
2020-10-06 12:57:25 +08:00
@classmethod
def poll(self, context):
prefs = bpy.context.preferences.addons[__package__].preferences
return os.path.isdir(prefs.external_folder)
2020-10-05 22:30:06 +08:00
def execute(self, context):
return {'FINISHED'}
def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self)
def draw(self, context):
layout = self.layout
col = layout.column()
col.label(text="Basic param")
col.prop(self, "floor_type")
2020-10-06 12:57:25 +08:00
col.prop(self, "rotation_inside_mesh")
col.prop(self, "height_multiplier")
col.separator()
col.label(text="Expand")
2020-10-05 22:30:06 +08:00
col.prop(self, "expand_length_1")
col.prop(self, "expand_length_2")
2020-10-06 12:57:25 +08:00
grids = col.grid_flow(columns=3)
grids.separator()
grids.label(text="X")
grids.separator()
grids.label(text="X")
grids.template_icon(icon_value = config.blenderIcon_floor_dict[self.floor_type])
grids.label(text="X")
grids.separator()
grids.label(text="X")
grids.separator()
2020-10-05 22:30:06 +08:00
col.separator()
col.label(text="Faces")
row = col.row()
row.prop(self, "use_3d_top")
row.prop(self, "use_3d_bottom")
col.separator()
col.label(text="Sides")
2020-10-06 12:57:25 +08:00
grids = col.grid_flow(columns=3)
grids.separator()
grids.prop(self, "use_2d_top")
grids.separator()
grids.prop(self, "use_2d_left")
grids.template_icon(icon_value = config.blenderIcon_floor_dict[self.floor_type])
grids.prop(self, "use_2d_right")
grids.separator()
grids.prop(self, "use_2d_bottom")
grids.separator()
2020-10-05 22:30:06 +08:00