This commit is contained in:
Andrej730
2024-09-25 10:24:55 +05:00
parent fce7b4416e
commit 6ac40b4ab3
3 changed files with 18 additions and 9 deletions
@@ -1456,6 +1456,9 @@ class OverrideJoin(bpy.types.Operator, tool.Ifc.Operator):
bl_label = "IFC Join"
bl_options = {"REGISTER", "UNDO"}
target: bpy.types.Object
target_element: ifcopenshell.entity_instance
def invoke(self, context, event):
if not tool.Ifc.get():
return bpy.ops.object.join()
@@ -1469,12 +1472,12 @@ class OverrideJoin(bpy.types.Operator, tool.Ifc.Operator):
return
self.target = context.active_object
self.target_element = tool.Ifc.get_entity(self.target)
if self.target_element:
if target_element := tool.Ifc.get_entity(self.target):
self.target_element = target_element
return self.join_ifc_obj()
return self.join_blender_obj()
def join_ifc_obj(self):
def join_ifc_obj(self) -> None:
ifc_file = tool.Ifc.get()
builder = ShapeBuilder(ifc_file)
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(ifc_file)
@@ -1539,7 +1542,7 @@ class OverrideJoin(bpy.types.Operator, tool.Ifc.Operator):
apply_openings=True,
)
def join_blender_obj(self):
def join_blender_obj(self) -> None:
for obj in bpy.context.selected_objects:
if obj == self.target:
continue
@@ -2289,6 +2292,7 @@ class ImportRepresentationItems(bpy.types.Operator, tool.Ifc.Operator):
def _execute(self, context):
obj = context.active_object
assert obj
props = context.scene.BIMGeometryProperties
if previous_obj := props.representation_obj:
previous_obj.hide_set(False)
+9 -5
View File
@@ -29,9 +29,11 @@ import ifcopenshell.api.grid
import ifcopenshell.geom
import ifcopenshell.guid
import ifcopenshell.util.element
import ifcopenshell.util.representation
import ifcopenshell.util.system
import ifcopenshell.util.placement
import ifcopenshell.util.representation
import ifcopenshell.util.shape_builder
import ifcopenshell.util.system
import ifcopenshell.util.unit
import bonsai.core.tool
import bonsai.core.drawing
import bonsai.core.geometry
@@ -1409,11 +1411,13 @@ class Geometry(bonsai.core.tool.Geometry):
return use_immediate_repr
@classmethod
def get_elements_by_representation(cls, representation):
def get_elements_by_representation(
cls, representation: ifcopenshell.entity_instance
) -> set[ifcopenshell.entity_instance]:
return ifcopenshell.util.element.get_elements_by_representation(tool.Ifc.get(), representation)
@classmethod
def sync_item_positions(cls):
def sync_item_positions(cls) -> None:
props = bpy.context.scene.BIMGeometryProperties
if not props.representation_obj:
return
@@ -1499,7 +1503,7 @@ class Geometry(bonsai.core.tool.Geometry):
cls.record_object_position(obj)
@classmethod
def disable_item_mode(cls):
def disable_item_mode(cls) -> None:
props = bpy.context.scene.BIMGeometryProperties
if props.representation_obj:
props.representation_obj.hide_set(False)
@@ -19,6 +19,7 @@ from __future__ import annotations
import re
import json
import ifcopenshell
import ifcopenshell.util.attribute
import ifcopenshell.util.schema
from pathlib import Path
from typing import Any, NoReturn, Union, Optional, TYPE_CHECKING