This commit is contained in:
Andrej730
2025-08-05 10:51:23 +05:00
parent 4cf4628e63
commit 9d83eec674
4 changed files with 12 additions and 9 deletions
@@ -94,6 +94,7 @@ class AddBSDDProperties(bpy.types.Operator, tool.Ifc.Operator):
psets.setdefault(selected_property.metadata, {})[selected_property.name] = selected_property.get_value() psets.setdefault(selected_property.metadata, {})[selected_property.name] = selected_property.get_value()
ifc_definition_id = tool.Blender.get_obj_ifc_definition_id(self.obj, self.obj_type, context) ifc_definition_id = tool.Blender.get_obj_ifc_definition_id(self.obj, self.obj_type, context)
assert ifc_definition_id
element = tool.Ifc.get().by_id(ifc_definition_id) element = tool.Ifc.get().by_id(ifc_definition_id)
current_psets = ifcopenshell.util.element.get_psets(element, verbose=True) current_psets = ifcopenshell.util.element.get_psets(element, verbose=True)
@@ -22,6 +22,7 @@ import bmesh
import numpy as np import numpy as np
import numpy.typing as npt import numpy.typing as npt
import ifcopenshell import ifcopenshell
import ifcopenshell.api.drawing
import ifcopenshell.api.group import ifcopenshell.api.group
import ifcopenshell.api.pset import ifcopenshell.api.pset
import ifcopenshell.api.geometry import ifcopenshell.api.geometry
@@ -51,6 +52,7 @@ from mathutils import Vector, Matrix, Quaternion
from time import time from time import time
from bonsai.bim.ifc import IfcStore from bonsai.bim.ifc import IfcStore
from ifcopenshell.util.shape_builder import ShapeBuilder from ifcopenshell.util.shape_builder import ShapeBuilder
from collections.abc import Sequence
from typing import Any, Union, Literal, get_args, TYPE_CHECKING, assert_never, NamedTuple from typing import Any, Union, Literal, get_args, TYPE_CHECKING, assert_never, NamedTuple
from bonsai.bim.module.model.decorator import ProfileDecorator from bonsai.bim.module.model.decorator import ProfileDecorator
@@ -1382,7 +1384,7 @@ class RefreshLinkedAggregate(bpy.types.Operator, tool.Ifc.Operator):
tool.Geometry.delete_ifc_object(tool.Ifc.get_object(element)) tool.Geometry.delete_ifc_object(tool.Ifc.get_object(element))
def get_assignments(element: ifcopenshell.entity_instance) -> list: def get_assignments(element: ifcopenshell.entity_instance) -> Sequence[ifcopenshell.entity_instance]:
annotations = [] annotations = []
inverse = list(tool.Ifc.get().get_inverse(element)) inverse = list(tool.Ifc.get().get_inverse(element))
assignments = [a for a in inverse if a.is_a("IfcRelAssignsToProduct")] assignments = [a for a in inverse if a.is_a("IfcRelAssignsToProduct")]
@@ -1393,7 +1395,8 @@ class RefreshLinkedAggregate(bpy.types.Operator, tool.Ifc.Operator):
annotations = assignment.RelatedObjects annotations = assignment.RelatedObjects
return annotations return annotations
def assign_to_annotations(obj, assignments): def assign_to_annotations(obj: bpy.types.Object, assignments: Sequence[ifcopenshell.entity_instance]) -> None:
ifc_file = tool.Ifc.get()
for assignment in assignments: for assignment in assignments:
product = tool.Ifc.get_entity(obj) product = tool.Ifc.get_entity(obj)
annotation = tool.Ifc.get_object(assignment) annotation = tool.Ifc.get_object(assignment)
@@ -1403,11 +1406,13 @@ class RefreshLinkedAggregate(bpy.types.Operator, tool.Ifc.Operator):
existing_product = tool.Drawing.get_assigned_product(assignment) existing_product = tool.Drawing.get_assigned_product(assignment)
if existing_product != product: if existing_product != product:
if existing_product: if existing_product:
tool.Ifc.run( ifcopenshell.api.drawing.unassign_product(
"drawing.unassign_product", relating_product=existing_product, related_object=assignment ifc_file, relating_product=existing_product, related_object=assignment
) )
if product: if product:
tool.Ifc.run("drawing.assign_product", relating_product=product, related_object=assignment) ifcopenshell.api.drawing.assign_product(
ifc_file, relating_product=product, related_object=assignment
)
tool.Blender.update_viewport() tool.Blender.update_viewport()
def get_original_data(element: ifcopenshell.entity_instance) -> dict[int, dict[int, str]]: def get_original_data(element: ifcopenshell.entity_instance) -> dict[int, dict[int, str]]:
@@ -104,7 +104,6 @@ def update_show_flat_colours(self: "BIMSearchProperties", context: bpy.types.Con
class BIMFilterClasses(PropertyGroup): class BIMFilterClasses(PropertyGroup):
name: StringProperty(name="Name")
is_selected: BoolProperty(name="Is Selected", default=True, update=update_is_class_selected) is_selected: BoolProperty(name="Is Selected", default=True, update=update_is_class_selected)
total: IntProperty(name="Total") total: IntProperty(name="Total")
unselected_objects: CollectionProperty(type=ObjProperty, name="Unfiltered Objects") unselected_objects: CollectionProperty(type=ObjProperty, name="Unfiltered Objects")
@@ -116,7 +115,6 @@ class BIMFilterClasses(PropertyGroup):
class BIMFilterBuildingStoreys(PropertyGroup): class BIMFilterBuildingStoreys(PropertyGroup):
name: StringProperty(name="Name")
is_selected: BoolProperty(name="Is Level Selected", default=True, update=update_is_container_selected) is_selected: BoolProperty(name="Is Level Selected", default=True, update=update_is_container_selected)
total: IntProperty(name="Total") total: IntProperty(name="Total")
unselected_objects: CollectionProperty(type=ObjProperty, name="Unfiltered Objects") unselected_objects: CollectionProperty(type=ObjProperty, name="Unfiltered Objects")
@@ -128,7 +126,6 @@ class BIMFilterBuildingStoreys(PropertyGroup):
class BIMColour(PropertyGroup): class BIMColour(PropertyGroup):
name: StringProperty(name="Name")
total: IntProperty(name="Total") total: IntProperty(name="Total")
colour: FloatVectorProperty(name="Colour", subtype="COLOR", default=(1, 0, 0), min=0.0, max=1.0) colour: FloatVectorProperty(name="Colour", subtype="COLOR", default=(1, 0, 0), min=0.0, max=1.0)
+1 -1
View File
@@ -475,7 +475,7 @@ class Bsdd(bonsai.core.tool.Bsdd):
return results return results
@classmethod @classmethod
def set_library_active(cls, uri: str, state: bool): def set_library_active(cls, uri: str, state: bool) -> None:
for dictionary in cls.get_bsdd_props().dictionaries: for dictionary in cls.get_bsdd_props().dictionaries:
if dictionary.uri == uri: if dictionary.uri == uri:
dictionary.is_active = state dictionary.is_active = state