mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
You can now create new empty types, and select type objects from the type manager
This commit is contained in:
@@ -101,7 +101,7 @@ class BIM_PT_Boundary(Panel):
|
||||
entity = getattr(boundary, ifc_attribute)
|
||||
if entity:
|
||||
row.label(text=f"{entity.is_a()}/{entity.Name}")
|
||||
op = row.operator("bim.select_global_id", text="", icon="TRACKER")
|
||||
op = row.operator("bim.select_global_id", text="", icon="OBJECT_DATA")
|
||||
op.global_id = entity.GlobalId
|
||||
else:
|
||||
row.label(text="")
|
||||
|
||||
@@ -94,7 +94,7 @@ class BIM_PT_debug(Panel):
|
||||
op = row.operator("bim.select_global_id", icon="RESTRICT_SELECT_OFF", text="")
|
||||
op.global_id = attribute.string_value
|
||||
if attribute.name == "ObjectPlacement":
|
||||
op = row.operator("bim.print_object_placement", icon="TRACKER", text="")
|
||||
op = row.operator("bim.print_object_placement", icon="OBJECT_ORIGIN", text="")
|
||||
op.step_id = attribute.int_value
|
||||
if attribute.int_value:
|
||||
row.operator(
|
||||
|
||||
@@ -398,7 +398,7 @@ class LoadTypeThumbnails(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
x_offset = (size / 2) - (width / 2)
|
||||
y_offset = (size / 2) - (height / 2)
|
||||
draw.rectangle([x_offset, y_offset, width + x_offset, height + y_offset], outline="white", width=2)
|
||||
draw.rectangle([x_offset, y_offset, width + x_offset, height + y_offset], outline="white", width=5)
|
||||
current_thickness = 0
|
||||
del thicknesses[-1]
|
||||
for thickness in thicknesses:
|
||||
@@ -410,8 +410,18 @@ class LoadTypeThumbnails(bpy.types.Operator, tool.Ifc.Operator):
|
||||
x = (current_thickness / total_thickness) * width
|
||||
line = [x_offset + x, y_offset, x_offset + x, y_offset + height]
|
||||
draw.line(line, fill="white", width=2)
|
||||
elif False:
|
||||
# TODO: things like parametric duct segments
|
||||
pass
|
||||
elif not element.RepresentationMaps:
|
||||
# Empties are represented by a generic thumbnail
|
||||
width = height = 100
|
||||
x_offset = (size / 2) - (width / 2)
|
||||
y_offset = (size / 2) - (height / 2)
|
||||
draw.line([x_offset, y_offset, width + x_offset, height + y_offset], fill="white", width=2)
|
||||
draw.line([x_offset, y_offset + height, width + x_offset, y_offset], fill="white", width=2)
|
||||
draw.rectangle([x_offset, y_offset, width + x_offset, height + y_offset], outline="white", width=5)
|
||||
else:
|
||||
# For things like parametric duct segments
|
||||
draw.line([0, 0, size, size], fill="red", width=2)
|
||||
draw.line([0, size, size, 0], fill="red", width=2)
|
||||
|
||||
|
||||
@@ -234,14 +234,14 @@ class BIMModelProperties(PropertyGroup):
|
||||
type_page: bpy.props.IntProperty(name="Type Page", default=1, update=update_type_page)
|
||||
type_template: bpy.props.EnumProperty(
|
||||
items=(
|
||||
("1", "Custom Mesh", ""),
|
||||
("2", "Vertical Layers", ""),
|
||||
("2", "Horizontal Layers", ""),
|
||||
("3", "Extruded Profile", ""),
|
||||
("4", "Non-Geometric Type", ""),
|
||||
("MESH", "Custom Mesh", ""),
|
||||
("LAYERSET_AXIS2", "Vertical Layers", ""),
|
||||
("LAYERSET_AXIS3", "Horizontal Layers", ""),
|
||||
("PROFILESET", "Extruded Profile", ""),
|
||||
("EMPTY", "Non-Geometric Type", ""),
|
||||
),
|
||||
name="Type Template",
|
||||
default="1",
|
||||
default="MESH",
|
||||
)
|
||||
type_class: bpy.props.EnumProperty(items=get_type_class, name="IFC Class", update=update_type_class)
|
||||
type_predefined_type: bpy.props.EnumProperty(items=get_type_predefined_type, name="Predefined Type", default=None)
|
||||
|
||||
@@ -57,7 +57,7 @@ class LaunchTypeManager(bpy.types.Operator):
|
||||
row.alignment = "CENTER"
|
||||
row.prop(props, "type_predefined_type", text="")
|
||||
row.prop(props, "type_template", text="")
|
||||
op = row.operator("bim.change_type_page", icon="ADD", text="")
|
||||
row.operator("bim.add_type", icon="ADD", text="")
|
||||
|
||||
row = columns.row(align=True)
|
||||
row.alignment = "RIGHT"
|
||||
@@ -99,6 +99,8 @@ class LaunchTypeManager(bpy.types.Operator):
|
||||
op.ifc_class = relating_type["ifc_class"]
|
||||
op.relating_type_id = relating_type["id"]
|
||||
|
||||
op = row.operator("bim.select_type", icon="OBJECT_DATA", text="")
|
||||
op.relating_type = relating_type["id"]
|
||||
op = row.operator("bim.duplicate_type", icon="COPYDOWN", text="")
|
||||
op.element = relating_type["id"]
|
||||
op = row.operator("bim.remove_type", icon="X", text="")
|
||||
|
||||
@@ -65,7 +65,7 @@ class BIM_PT_spatial(Panel):
|
||||
row = self.layout.row(align=True)
|
||||
if SpatialData.data["label"]:
|
||||
row.label(text=SpatialData.data["label"])
|
||||
row.operator("bim.select_container", icon="TRACKER", text="")
|
||||
row.operator("bim.select_container", icon="OBJECT_DATA", text="")
|
||||
row.operator("bim.select_similar_container", icon="RESTRICT_SELECT_OFF", text="")
|
||||
row.operator("bim.enable_editing_container", icon="GREASEPENCIL", text="")
|
||||
if SpatialData.data["is_directly_contained"]:
|
||||
|
||||
@@ -20,6 +20,7 @@ import bpy
|
||||
from . import ui, prop, operator
|
||||
|
||||
classes = (
|
||||
operator.AddType,
|
||||
operator.AssignType,
|
||||
operator.DisableEditingType,
|
||||
operator.DuplicateType,
|
||||
|
||||
@@ -40,7 +40,7 @@ class TypeData:
|
||||
{
|
||||
"is_product": cls.is_product(),
|
||||
"total_instances": cls.total_instances(),
|
||||
"type_name": cls.type_name(),
|
||||
"relating_type": cls.relating_type(),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -82,8 +82,11 @@ class TypeData:
|
||||
return str(len(ifcopenshell.util.element.get_types(element)))
|
||||
|
||||
@classmethod
|
||||
def type_name(cls):
|
||||
def relating_type(cls):
|
||||
element = tool.Ifc.get_entity(bpy.context.active_object)
|
||||
type = ifcopenshell.util.element.get_type(element)
|
||||
if type:
|
||||
return f"{type.is_a()}/{type.Name or 'Unnamed'}"
|
||||
element_type = ifcopenshell.util.element.get_type(element)
|
||||
if element_type:
|
||||
return {
|
||||
"id": element_type.id(),
|
||||
"name":f"{element_type.is_a()}/{element_type.Name or 'Unnamed'}"
|
||||
}
|
||||
|
||||
@@ -113,15 +113,12 @@ class SelectType(bpy.types.Operator):
|
||||
bl_idname = "bim.select_type"
|
||||
bl_label = "Select Type"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
related_object: bpy.props.StringProperty()
|
||||
relating_type: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
related_object = bpy.data.objects.get(self.related_object, context.active_object)
|
||||
oprops = related_object.BIMObjectProperties
|
||||
element_type = ifcopenshell.util.element.get_type(self.file.by_id(oprops.ifc_definition_id))
|
||||
if element_type is not None:
|
||||
obj = IfcStore.get_element(element_type.GlobalId)
|
||||
element = tool.Ifc.get().by_id(self.relating_type)
|
||||
obj = tool.Ifc.get_object(element)
|
||||
if obj:
|
||||
context.view_layer.objects.active = obj
|
||||
obj.select_set(True)
|
||||
return {"FINISHED"}
|
||||
@@ -169,6 +166,27 @@ class SelectTypeObjects(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AddType(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.add_type"
|
||||
bl_label = "Add Type"
|
||||
bl_options = {"REGISTER"}
|
||||
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMModelProperties
|
||||
ifc_class = props.type_class
|
||||
predefined_type = props.type_predefined_type
|
||||
template = props.type_template
|
||||
if template == "EMPTY":
|
||||
obj = bpy.data.objects.new("TYPEX", None)
|
||||
element = ifcopenshell.api.run("root.create_entity", tool.Ifc.get(), ifc_class=ifc_class, predefined_type=predefined_type, name="TYPEX")
|
||||
tool.Ifc.link(element, obj)
|
||||
collection = bpy.data.collections.get("Types")
|
||||
if collection:
|
||||
collection.objects.link(obj)
|
||||
bpy.ops.bim.load_type_thumbnails(ifc_class=ifc_class)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class RemoveType(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.remove_type"
|
||||
bl_label = "Remove Type"
|
||||
|
||||
@@ -76,9 +76,10 @@ class BIM_PT_type(Panel):
|
||||
row.operator("bim.disable_editing_type", icon="CANCEL", text="")
|
||||
else:
|
||||
row = self.layout.row(align=True)
|
||||
if TypeData.data["type_name"]:
|
||||
row.label(text=TypeData.data["type_name"])
|
||||
row.operator("bim.select_type", icon="TRACKER", text="")
|
||||
if TypeData.data["relating_type"]:
|
||||
row.label(text=TypeData.data["relating_type"]["name"])
|
||||
op = row.operator("bim.select_type", icon="OBJECT_DATA", text="")
|
||||
op.relating_type = TypeData.data["relating_type"]["id"]
|
||||
row.operator("bim.select_similar_type", icon="RESTRICT_SELECT_OFF", text="")
|
||||
row.operator("bim.enable_editing_type", icon="GREASEPENCIL", text="")
|
||||
row.operator("bim.unassign_type", icon="X", text="")
|
||||
|
||||
Reference in New Issue
Block a user