mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 14:26:30 +00:00
typing
This commit is contained in:
@@ -1456,6 +1456,9 @@ class OverrideJoin(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
bl_label = "IFC Join"
|
bl_label = "IFC Join"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
target: bpy.types.Object
|
||||||
|
target_element: ifcopenshell.entity_instance
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
if not tool.Ifc.get():
|
if not tool.Ifc.get():
|
||||||
return bpy.ops.object.join()
|
return bpy.ops.object.join()
|
||||||
@@ -1469,12 +1472,12 @@ class OverrideJoin(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.target = context.active_object
|
self.target = context.active_object
|
||||||
self.target_element = tool.Ifc.get_entity(self.target)
|
if target_element := tool.Ifc.get_entity(self.target):
|
||||||
if self.target_element:
|
self.target_element = target_element
|
||||||
return self.join_ifc_obj()
|
return self.join_ifc_obj()
|
||||||
return self.join_blender_obj()
|
return self.join_blender_obj()
|
||||||
|
|
||||||
def join_ifc_obj(self):
|
def join_ifc_obj(self) -> None:
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
builder = ShapeBuilder(ifc_file)
|
builder = ShapeBuilder(ifc_file)
|
||||||
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(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,
|
apply_openings=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def join_blender_obj(self):
|
def join_blender_obj(self) -> None:
|
||||||
for obj in bpy.context.selected_objects:
|
for obj in bpy.context.selected_objects:
|
||||||
if obj == self.target:
|
if obj == self.target:
|
||||||
continue
|
continue
|
||||||
@@ -2289,6 +2292,7 @@ class ImportRepresentationItems(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
|
assert obj
|
||||||
props = context.scene.BIMGeometryProperties
|
props = context.scene.BIMGeometryProperties
|
||||||
if previous_obj := props.representation_obj:
|
if previous_obj := props.representation_obj:
|
||||||
previous_obj.hide_set(False)
|
previous_obj.hide_set(False)
|
||||||
|
|||||||
@@ -29,9 +29,11 @@ import ifcopenshell.api.grid
|
|||||||
import ifcopenshell.geom
|
import ifcopenshell.geom
|
||||||
import ifcopenshell.guid
|
import ifcopenshell.guid
|
||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
import ifcopenshell.util.representation
|
|
||||||
import ifcopenshell.util.system
|
|
||||||
import ifcopenshell.util.placement
|
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.tool
|
||||||
import bonsai.core.drawing
|
import bonsai.core.drawing
|
||||||
import bonsai.core.geometry
|
import bonsai.core.geometry
|
||||||
@@ -1409,11 +1411,13 @@ class Geometry(bonsai.core.tool.Geometry):
|
|||||||
return use_immediate_repr
|
return use_immediate_repr
|
||||||
|
|
||||||
@classmethod
|
@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)
|
return ifcopenshell.util.element.get_elements_by_representation(tool.Ifc.get(), representation)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def sync_item_positions(cls):
|
def sync_item_positions(cls) -> None:
|
||||||
props = bpy.context.scene.BIMGeometryProperties
|
props = bpy.context.scene.BIMGeometryProperties
|
||||||
if not props.representation_obj:
|
if not props.representation_obj:
|
||||||
return
|
return
|
||||||
@@ -1499,7 +1503,7 @@ class Geometry(bonsai.core.tool.Geometry):
|
|||||||
cls.record_object_position(obj)
|
cls.record_object_position(obj)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def disable_item_mode(cls):
|
def disable_item_mode(cls) -> None:
|
||||||
props = bpy.context.scene.BIMGeometryProperties
|
props = bpy.context.scene.BIMGeometryProperties
|
||||||
if props.representation_obj:
|
if props.representation_obj:
|
||||||
props.representation_obj.hide_set(False)
|
props.representation_obj.hide_set(False)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from __future__ import annotations
|
|||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import ifcopenshell.util.attribute
|
||||||
import ifcopenshell.util.schema
|
import ifcopenshell.util.schema
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, NoReturn, Union, Optional, TYPE_CHECKING
|
from typing import Any, NoReturn, Union, Optional, TYPE_CHECKING
|
||||||
|
|||||||
Reference in New Issue
Block a user