This commit is contained in:
Andrej730
2025-01-20 16:16:33 +05:00
parent 3ad247b9a7
commit c0499a2c88
8 changed files with 13 additions and 16 deletions
-2
View File
@@ -336,5 +336,3 @@ def load_post(scene):
WallAxisDecorator.install(bpy.context) WallAxisDecorator.install(bpy.context)
if model_props.show_slab_direction: if model_props.show_slab_direction:
SlabDirectionDecorator.install(bpy.context) SlabDirectionDecorator.install(bpy.context)
@@ -714,7 +714,7 @@ class MergeIdenticalObjects(bpy.types.Operator, tool.Ifc.Operator):
plural_object_type = f"{object_type.lower()}s" plural_object_type = f"{object_type.lower()}s"
if merged_data: if merged_data:
for element_type, element_names in merged_data.items(): for element_type, element_names in merged_data.items():
names = ", ". join([n or "Unnamed" for n in element_names]) names = ", ".join([n or "Unnamed" for n in element_names])
print(f"- {element_type}: {names}") print(f"- {element_type}: {names}")
merged = sum(len(v) for v in merged_data.values()) merged = sum(len(v) for v in merged_data.values())
@@ -3052,7 +3052,6 @@ class OverrideMove(bpy.types.Operator):
obj.select_set(True) obj.select_set(True)
self.new_active_obj = obj self.new_active_obj = obj
# Get aggregates # Get aggregates
props = context.scene.BIMAggregateProperties props = context.scene.BIMAggregateProperties
not_editing_objs = [o.obj for o in props.not_editing_objects] not_editing_objs = [o.obj for o in props.not_editing_objects]
@@ -3063,7 +3062,7 @@ class OverrideMove(bpy.types.Operator):
obj.select_set(False) obj.select_set(False)
continue continue
if obj == props.editing_aggregate: if obj == props.editing_aggregate:
continue continue
element = tool.Ifc.get_entity(obj) element = tool.Ifc.get_entity(obj)
if not element or not element.is_a("IfcElement"): if not element or not element.is_a("IfcElement"):
continue continue
@@ -3072,7 +3071,7 @@ class OverrideMove(bpy.types.Operator):
aggregates_to_move.append(tool.Ifc.get_object(element)) aggregates_to_move.append(tool.Ifc.get_object(element))
continue continue
if not parts and props.in_aggregate_mode: if not parts and props.in_aggregate_mode:
continue continue
aggregate = ifcopenshell.util.element.get_aggregate(element) aggregate = ifcopenshell.util.element.get_aggregate(element)
if aggregate: if aggregate:
aggregates_to_move.append(tool.Ifc.get_object(aggregate)) aggregates_to_move.append(tool.Ifc.get_object(aggregate))
@@ -3098,7 +3097,7 @@ class OverrideMove(bpy.types.Operator):
obj.select_set(False) obj.select_set(False)
continue continue
if obj == props.editing_nest: if obj == props.editing_nest:
continue continue
element = tool.Ifc.get_entity(obj) element = tool.Ifc.get_entity(obj)
if not element or not element.is_a("IfcElement"): if not element or not element.is_a("IfcElement"):
continue continue
@@ -3107,7 +3106,7 @@ class OverrideMove(bpy.types.Operator):
nests_to_move.append(tool.Ifc.get_object(element)) nests_to_move.append(tool.Ifc.get_object(element))
continue continue
if not components and props.in_nest_mode: if not components and props.in_nest_mode:
continue continue
nest = ifcopenshell.util.element.get_nest(element) nest = ifcopenshell.util.element.get_nest(element)
if nest: if nest:
nests_to_move.append(tool.Ifc.get_object(nest)) nests_to_move.append(tool.Ifc.get_object(nest))
@@ -33,6 +33,7 @@ def transparent_color(color, alpha=0.1):
color[3] = alpha color[3] = alpha
return color return color
def create_bounding_box(objs): def create_bounding_box(objs):
# Initialize the bounding box coordinates # Initialize the bounding box coordinates
min_x, min_y, min_z = float("inf"), float("inf"), float("inf") min_x, min_y, min_z = float("inf"), float("inf"), float("inf")
@@ -77,6 +78,7 @@ def create_bounding_box(objs):
return indices, edges return indices, edges
class NestDecorator: class NestDecorator:
is_installed = False is_installed = False
handlers = [] handlers = []
@@ -206,7 +208,7 @@ class NestDecorator:
else: else:
self.draw_batch("POINTS", [location], color) self.draw_batch("POINTS", [location], color)
# if context.scene.BIMNestProperties.in_aggregate_mode: # if context.scene.BIMNestProperties.in_aggregate_mode:
# return # return
components = ifcopenshell.util.element.get_components(tool.Ifc.get_entity(nest)) components = ifcopenshell.util.element.get_components(tool.Ifc.get_entity(nest))
components_objs = [tool.Ifc.get_object(p) for p in components] components_objs = [tool.Ifc.get_object(p) for p in components]
components_objs.append(nest) components_objs.append(nest)
@@ -227,12 +229,8 @@ class NestModeDecorator:
if cls.is_installed: if cls.is_installed:
cls.uninstall() cls.uninstall()
handler = cls() handler = cls()
cls.handlers.append( cls.handlers.append(SpaceView3D.draw_handler_add(handler.draw_nest_name, (context,), "WINDOW", "POST_PIXEL"))
SpaceView3D.draw_handler_add(handler.draw_nest_name, (context,), "WINDOW", "POST_PIXEL") cls.handlers.append(SpaceView3D.draw_handler_add(handler.draw_nest_empty, (context,), "WINDOW", "POST_VIEW"))
)
cls.handlers.append(
SpaceView3D.draw_handler_add(handler.draw_nest_empty, (context,), "WINDOW", "POST_VIEW")
)
cls.is_installed = True cls.is_installed = True
@classmethod @classmethod
@@ -49,6 +49,7 @@ class BIMObjectNestProperties(PropertyGroup):
is_editing: BoolProperty(name="Is Editing") is_editing: BoolProperty(name="Is Editing")
relating_object: PointerProperty(name="Nest Host", type=bpy.types.Object, update=update_relating_object) relating_object: PointerProperty(name="Nest Host", type=bpy.types.Object, update=update_relating_object)
def update_nest_decorator(self, context): def update_nest_decorator(self, context):
if self.nest_decorator: if self.nest_decorator:
NestDecorator.install(bpy.context) NestDecorator.install(bpy.context)
+1
View File
@@ -24,6 +24,7 @@ if TYPE_CHECKING:
import ifcopenshell import ifcopenshell
import bonsai.tool as tool import bonsai.tool as tool
def enable_editing_nest(nest, obj=None): def enable_editing_nest(nest, obj=None):
nest.enable_editing(obj) nest.enable_editing(obj)
@@ -45,6 +45,7 @@ def validate_type(
:return: True if the representation type was set and it is a valid :return: True if the representation type was set and it is a valid
combination, or False otherwise. combination, or False otherwise.
""" """
def is_operand(item): def is_operand(item):
return ( return (
item.is_a("IfcBooleanResult") item.is_a("IfcBooleanResult")
@@ -39,7 +39,6 @@ class TestRemoveBoolean(test.bootstrap.IFC4):
assert set(rep.Items) == {first, second} assert set(rep.Items) == {first, second}
assert not self.file.by_type("IfcBooleanResult") assert not self.file.by_type("IfcBooleanResult")
def test_removing_a_top_level_nested_boolean(self): def test_removing_a_top_level_nested_boolean(self):
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject") ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
model = ifcopenshell.api.context.add_context(self.file, context_type="Model") model = ifcopenshell.api.context.add_context(self.file, context_type="Model")