mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
You can now eyedrop an object in the 3D viewport to fill in its class in the type selector
This commit is contained in:
@@ -52,6 +52,7 @@ class AssignType(bpy.types.Operator, Operator):
|
||||
for obj in related_objects:
|
||||
core.assign_type(tool.Ifc, tool.Type, element=tool.Ifc.get_entity(obj), type=type)
|
||||
oprops = obj.BIMObjectProperties
|
||||
obj.BIMTypeProperties.relating_type_object = None
|
||||
|
||||
|
||||
class UnassignType(bpy.types.Operator):
|
||||
@@ -130,6 +131,7 @@ class DisableEditingType(bpy.types.Operator):
|
||||
def execute(self, context):
|
||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
||||
obj.BIMTypeProperties.is_editing_type = False
|
||||
obj.BIMTypeProperties.relating_type_object = None
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import ifcopenshell.util.type
|
||||
from blenderbim.bim.module.type.data import TypeData
|
||||
from blenderbim.bim.prop import StrProperty, Attribute
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
import blenderbim.tool as tool
|
||||
from bpy.types import PropertyGroup
|
||||
from bpy.props import (
|
||||
PointerProperty,
|
||||
@@ -50,9 +51,41 @@ def update_relating_type_class(self, context):
|
||||
TypeData.is_loaded = False
|
||||
|
||||
|
||||
def update_relating_type_from_object(self, context):
|
||||
if self.relating_type_object is None:
|
||||
return
|
||||
element = tool.Ifc.get_entity(self.relating_type_object)
|
||||
if not element:
|
||||
return
|
||||
element_type = ifcopenshell.util.element.get_type(element)
|
||||
if not element_type:
|
||||
return
|
||||
self.relating_type = str(element_type.id())
|
||||
|
||||
|
||||
def is_object_class_applicable(self, obj):
|
||||
if not TypeData.is_loaded:
|
||||
TypeData.load()
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
if not element:
|
||||
return
|
||||
element_type = ifcopenshell.util.element.get_type(element)
|
||||
if element_type is None:
|
||||
return False
|
||||
return str(element_type.is_a()) in [r_t_c[0] for r_t_c in TypeData.data["relating_type_classes"]]
|
||||
|
||||
|
||||
class BIMTypeProperties(PropertyGroup):
|
||||
is_editing_type: BoolProperty(name="Is Editing Type")
|
||||
relating_type_class: EnumProperty(
|
||||
items=get_relating_type_class, name="Relating Type Class", update=update_relating_type_class
|
||||
items=get_relating_type_class,
|
||||
name="Relating Type Class",
|
||||
update=update_relating_type_class,
|
||||
)
|
||||
relating_type: EnumProperty(items=get_relating_type, name="Relating Type")
|
||||
relating_type_object: PointerProperty(
|
||||
type=bpy.types.Object,
|
||||
name="Copy Class",
|
||||
update=update_relating_type_from_object,
|
||||
poll=is_object_class_applicable,
|
||||
)
|
||||
|
||||
@@ -66,21 +66,24 @@ class BIM_PT_type(Panel):
|
||||
op.element = context.active_object.BIMObjectProperties.ifc_definition_id
|
||||
|
||||
def draw_product_ui(self, context):
|
||||
layout = self.layout
|
||||
props = context.active_object.BIMTypeProperties
|
||||
oprops = context.active_object.BIMObjectProperties
|
||||
|
||||
if props.is_editing_type:
|
||||
row = self.layout.row(align=True)
|
||||
row = layout.row(align=True)
|
||||
row_object = layout.row(align=True)
|
||||
|
||||
row.prop(props, "relating_type_class", text="")
|
||||
if type_prop.get_relating_type(None, context):
|
||||
prop_with_search(row, props, "relating_type", text="")
|
||||
row.operator("bim.assign_type", icon="CHECKMARK", text="")
|
||||
row_object.prop(props, "relating_type_object", icon="COPYDOWN")
|
||||
else:
|
||||
row.label(text="No Types Found")
|
||||
row.operator("bim.disable_editing_type", icon="CANCEL", text="")
|
||||
else:
|
||||
row = self.layout.row(align=True)
|
||||
row = layout.row(align=True)
|
||||
if TypeData.data["relating_type"]:
|
||||
row.label(text=TypeData.data["relating_type"]["name"])
|
||||
op = row.operator("bim.select_type", icon="OBJECT_DATA", text="")
|
||||
|
||||
Reference in New Issue
Block a user