mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 17:57:02 +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)
|
entity = getattr(boundary, ifc_attribute)
|
||||||
if entity:
|
if entity:
|
||||||
row.label(text=f"{entity.is_a()}/{entity.Name}")
|
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
|
op.global_id = entity.GlobalId
|
||||||
else:
|
else:
|
||||||
row.label(text="")
|
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 = row.operator("bim.select_global_id", icon="RESTRICT_SELECT_OFF", text="")
|
||||||
op.global_id = attribute.string_value
|
op.global_id = attribute.string_value
|
||||||
if attribute.name == "ObjectPlacement":
|
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
|
op.step_id = attribute.int_value
|
||||||
if attribute.int_value:
|
if attribute.int_value:
|
||||||
row.operator(
|
row.operator(
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ class LoadTypeThumbnails(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
x_offset = (size / 2) - (width / 2)
|
x_offset = (size / 2) - (width / 2)
|
||||||
y_offset = (size / 2) - (height / 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
|
current_thickness = 0
|
||||||
del thicknesses[-1]
|
del thicknesses[-1]
|
||||||
for thickness in thicknesses:
|
for thickness in thicknesses:
|
||||||
@@ -410,8 +410,18 @@ class LoadTypeThumbnails(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
x = (current_thickness / total_thickness) * width
|
x = (current_thickness / total_thickness) * width
|
||||||
line = [x_offset + x, y_offset, x_offset + x, y_offset + height]
|
line = [x_offset + x, y_offset, x_offset + x, y_offset + height]
|
||||||
draw.line(line, fill="white", width=2)
|
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:
|
else:
|
||||||
# For things like parametric duct segments
|
|
||||||
draw.line([0, 0, size, size], fill="red", width=2)
|
draw.line([0, 0, size, size], fill="red", width=2)
|
||||||
draw.line([0, size, size, 0], 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_page: bpy.props.IntProperty(name="Type Page", default=1, update=update_type_page)
|
||||||
type_template: bpy.props.EnumProperty(
|
type_template: bpy.props.EnumProperty(
|
||||||
items=(
|
items=(
|
||||||
("1", "Custom Mesh", ""),
|
("MESH", "Custom Mesh", ""),
|
||||||
("2", "Vertical Layers", ""),
|
("LAYERSET_AXIS2", "Vertical Layers", ""),
|
||||||
("2", "Horizontal Layers", ""),
|
("LAYERSET_AXIS3", "Horizontal Layers", ""),
|
||||||
("3", "Extruded Profile", ""),
|
("PROFILESET", "Extruded Profile", ""),
|
||||||
("4", "Non-Geometric Type", ""),
|
("EMPTY", "Non-Geometric Type", ""),
|
||||||
),
|
),
|
||||||
name="Type Template",
|
name="Type Template",
|
||||||
default="1",
|
default="MESH",
|
||||||
)
|
)
|
||||||
type_class: bpy.props.EnumProperty(items=get_type_class, name="IFC Class", update=update_type_class)
|
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)
|
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.alignment = "CENTER"
|
||||||
row.prop(props, "type_predefined_type", text="")
|
row.prop(props, "type_predefined_type", text="")
|
||||||
row.prop(props, "type_template", 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 = columns.row(align=True)
|
||||||
row.alignment = "RIGHT"
|
row.alignment = "RIGHT"
|
||||||
@@ -99,6 +99,8 @@ class LaunchTypeManager(bpy.types.Operator):
|
|||||||
op.ifc_class = relating_type["ifc_class"]
|
op.ifc_class = relating_type["ifc_class"]
|
||||||
op.relating_type_id = relating_type["id"]
|
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 = row.operator("bim.duplicate_type", icon="COPYDOWN", text="")
|
||||||
op.element = relating_type["id"]
|
op.element = relating_type["id"]
|
||||||
op = row.operator("bim.remove_type", icon="X", text="")
|
op = row.operator("bim.remove_type", icon="X", text="")
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class BIM_PT_spatial(Panel):
|
|||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
if SpatialData.data["label"]:
|
if SpatialData.data["label"]:
|
||||||
row.label(text=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.select_similar_container", icon="RESTRICT_SELECT_OFF", text="")
|
||||||
row.operator("bim.enable_editing_container", icon="GREASEPENCIL", text="")
|
row.operator("bim.enable_editing_container", icon="GREASEPENCIL", text="")
|
||||||
if SpatialData.data["is_directly_contained"]:
|
if SpatialData.data["is_directly_contained"]:
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import bpy
|
|||||||
from . import ui, prop, operator
|
from . import ui, prop, operator
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
|
operator.AddType,
|
||||||
operator.AssignType,
|
operator.AssignType,
|
||||||
operator.DisableEditingType,
|
operator.DisableEditingType,
|
||||||
operator.DuplicateType,
|
operator.DuplicateType,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class TypeData:
|
|||||||
{
|
{
|
||||||
"is_product": cls.is_product(),
|
"is_product": cls.is_product(),
|
||||||
"total_instances": cls.total_instances(),
|
"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)))
|
return str(len(ifcopenshell.util.element.get_types(element)))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def type_name(cls):
|
def relating_type(cls):
|
||||||
element = tool.Ifc.get_entity(bpy.context.active_object)
|
element = tool.Ifc.get_entity(bpy.context.active_object)
|
||||||
type = ifcopenshell.util.element.get_type(element)
|
element_type = ifcopenshell.util.element.get_type(element)
|
||||||
if type:
|
if element_type:
|
||||||
return f"{type.is_a()}/{type.Name or 'Unnamed'}"
|
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_idname = "bim.select_type"
|
||||||
bl_label = "Select Type"
|
bl_label = "Select Type"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
related_object: bpy.props.StringProperty()
|
relating_type: bpy.props.IntProperty()
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.file = IfcStore.get_file()
|
element = tool.Ifc.get().by_id(self.relating_type)
|
||||||
related_object = bpy.data.objects.get(self.related_object, context.active_object)
|
obj = tool.Ifc.get_object(element)
|
||||||
oprops = related_object.BIMObjectProperties
|
if obj:
|
||||||
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)
|
|
||||||
context.view_layer.objects.active = obj
|
context.view_layer.objects.active = obj
|
||||||
obj.select_set(True)
|
obj.select_set(True)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
@@ -169,6 +166,27 @@ class SelectTypeObjects(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
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):
|
class RemoveType(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_idname = "bim.remove_type"
|
bl_idname = "bim.remove_type"
|
||||||
bl_label = "Remove Type"
|
bl_label = "Remove Type"
|
||||||
|
|||||||
@@ -76,9 +76,10 @@ class BIM_PT_type(Panel):
|
|||||||
row.operator("bim.disable_editing_type", icon="CANCEL", text="")
|
row.operator("bim.disable_editing_type", icon="CANCEL", text="")
|
||||||
else:
|
else:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
if TypeData.data["type_name"]:
|
if TypeData.data["relating_type"]:
|
||||||
row.label(text=TypeData.data["type_name"])
|
row.label(text=TypeData.data["relating_type"]["name"])
|
||||||
row.operator("bim.select_type", icon="TRACKER", text="")
|
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.select_similar_type", icon="RESTRICT_SELECT_OFF", text="")
|
||||||
row.operator("bim.enable_editing_type", icon="GREASEPENCIL", text="")
|
row.operator("bim.enable_editing_type", icon="GREASEPENCIL", text="")
|
||||||
row.operator("bim.unassign_type", icon="X", text="")
|
row.operator("bim.unassign_type", icon="X", text="")
|
||||||
|
|||||||
Reference in New Issue
Block a user