Fix #3394. Fix bug where railing and roof type names were hardcoded. Also improve UI of create type form so you can actually read the fields.

This commit is contained in:
Dion Moult
2023-07-07 17:57:09 +10:00
parent cb412c78b5
commit bb7a73feac
5 changed files with 40 additions and 6 deletions
@@ -54,6 +54,8 @@ classes = (
product.AddEmptyType,
product.AlignProduct,
product.ChangeTypePage,
product.DisableAddType,
product.EnableAddType,
product.LoadTypeThumbnails,
product.MirrorElements,
workspace.Hotkey,
@@ -37,6 +37,24 @@ from . import prop
import json
class EnableAddType(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.enable_add_type"
bl_label = "Enable Add Type"
bl_options = {"REGISTER", "UNDO"}
def _execute(self, context):
bpy.context.scene.BIMModelProperties.is_adding_type = True
class DisableAddType(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.disable_add_type"
bl_label = "Disable Add Type"
bl_options = {"REGISTER", "UNDO"}
def _execute(self, context):
bpy.context.scene.BIMModelProperties.is_adding_type = False
class AddEmptyType(bpy.types.Operator, AddObjectHelper):
bl_idname = "bim.add_empty_type"
bl_label = "Add Empty Type"
@@ -92,6 +92,7 @@ class BIMModelProperties(PropertyGroup):
)
icon_id: bpy.props.IntProperty()
updating: bpy.props.BoolProperty(default=False)
is_adding_type: bpy.props.BoolProperty(default=False)
occurrence_name_style: bpy.props.EnumProperty(
items=[("CLASS", "By Class", ""), ("TYPE", "By Type", ""), ("CUSTOM", "Custom", "")],
name="Occurrence Name Style",
@@ -70,10 +70,7 @@ class LaunchTypeManager(bpy.types.Operator):
row = columns.row(align=True)
row.alignment = "CENTER"
row.prop(props, "type_predefined_type", text="")
row.prop(props, "type_template", text="")
row.prop(props, "type_name", text="")
row.operator("bim.add_type", icon="ADD", text="")
# In case you want something here in the future
row = columns.row(align=True)
row.alignment = "RIGHT"
@@ -86,6 +83,22 @@ class LaunchTypeManager(bpy.types.Operator):
op = row.operator("bim.change_type_page", icon="TRIA_RIGHT", text="")
op.page = AuthoringData.data["next_page"]
if props.is_adding_type:
row = self.layout.row()
box = row.box()
row = box.row()
row.prop(props, "type_predefined_type")
row = box.row()
row.prop(props, "type_template")
row = box.row()
row.prop(props, "type_name")
row = box.row(align=True)
row.operator("bim.add_type", icon="CHECKMARK", text="Save New Type")
row.operator("bim.disable_add_type", icon="CANCEL", text="")
else:
row = self.layout.row()
row.operator("bim.enable_add_type", icon="ADD", text="Create New Type")
flow = self.layout.grid_flow(row_major=True, columns=3, even_columns=True, even_rows=True, align=True)
for relating_type in AuthoringData.data["paginated_relating_types"]:
@@ -383,7 +383,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
elif template == "RAILING":
mesh = bpy.data.meshes.new("IfcRailing")
obj = bpy.data.objects.new("TYPEX", mesh)
obj = bpy.data.objects.new(name, mesh)
element = blenderbim.core.root.assign_class(
tool.Ifc,
tool.Collector,
@@ -402,7 +402,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
elif template == "ROOF":
mesh = bpy.data.meshes.new("IfcRoof")
obj = bpy.data.objects.new("TYPEX", mesh)
obj = bpy.data.objects.new(name, mesh)
element = blenderbim.core.root.assign_class(
tool.Ifc,
tool.Collector,