This commit is contained in:
Andrej730
2025-08-06 14:39:49 +05:00
parent 2f23f3cdd7
commit d7d592de6f
6 changed files with 37 additions and 23 deletions
+2 -2
View File
@@ -219,8 +219,8 @@ def refresh_ui_data():
except AttributeError: except AttributeError:
pass pass
if isinstance(tool.Ifc.get(), ifcopenshell.sqlite): if isinstance(ifc_file := tool.Ifc.get(), ifcopenshell.sqlite):
tool.Ifc.get().clear_cache() ifc_file.clear_cache()
props = tool.Drawing.get_document_props() props = tool.Drawing.get_document_props()
props.should_draw_decorations = props.should_draw_decorations props.should_draw_decorations = props.should_draw_decorations
+2
View File
@@ -128,6 +128,8 @@ class IfcStore:
def get_cache() -> ifcopenshell.geom.serializers.hdf5 | None: def get_cache() -> ifcopenshell.geom.serializers.hdf5 | None:
if IfcStore.cache is None and IfcStore.path: if IfcStore.cache is None and IfcStore.path:
prefs = tool.Blender.get_addon_preferences() prefs = tool.Blender.get_addon_preferences()
assert IfcStore.file
ifc_key = IfcStore.path + IfcStore.file.wrapped_data.header.file_name.time_stamp ifc_key = IfcStore.path + IfcStore.file.wrapped_data.header.file_name.time_stamp
ifc_hash = hashlib.md5(ifc_key.encode("utf-8")).hexdigest() ifc_hash = hashlib.md5(ifc_key.encode("utf-8")).hexdigest()
os.makedirs(prefs.cache_dir, exist_ok=True) os.makedirs(prefs.cache_dir, exist_ok=True)
+11 -9
View File
@@ -18,13 +18,9 @@
import bpy import bpy
import json import json
from bpy.types import Context, OperatorProperties
import ifcopenshell.api import ifcopenshell.api
import ifcopenshell.api.pset import ifcopenshell.api.pset
import ifcopenshell.util.attribute
import ifcopenshell.util.element import ifcopenshell.util.element
import ifcopenshell.util.pset
import ifcopenshell.util.unit
import bonsai.bim.schema import bonsai.bim.schema
import bonsai.tool as tool import bonsai.tool as tool
import bonsai.core.pset as core import bonsai.core.pset as core
@@ -240,16 +236,22 @@ class AddQto(bpy.types.Operator, tool.Ifc.Operator):
class CopyPropertyToSelection(bpy.types.Operator, tool.Ifc.Operator): class CopyPropertyToSelection(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.copy_property_to_selection" bl_idname = "bim.copy_property_to_selection"
bl_label = "Copy Property To Selection" bl_label = "Copy Property To Selection"
name: bpy.props.StringProperty()
name: bpy.props.StringProperty() # pyright: ignore[reportRedeclaration]
if TYPE_CHECKING:
name: str
def _execute(self, context): def _execute(self, context):
pset_id = context.active_object.PsetProperties.active_pset_id assert (obj := context.active_object)
props = tool.Pset.get_pset_props(obj.name, "Object")
pset_id = props.active_pset_id
if pset_id: if pset_id:
is_pset = tool.Ifc.get().by_id(pset_id).is_a("IfcPropertySet") is_pset = tool.Ifc.get().by_id(pset_id).is_a("IfcPropertySet")
else: else:
is_pset = context.active_object.PsetProperties.active_pset_type == "PSET" is_pset = props.active_pset_type == "PSET"
pset_name = context.active_object.PsetProperties.active_pset_name pset_name = props.active_pset_name
prop = context.active_object.PsetProperties.properties.get(self.name) prop = props.properties[self.name]
if prop.value_type == "IfcPropertySingleValue": if prop.value_type == "IfcPropertySingleValue":
prop_value = prop.metadata.get_value() prop_value = prop.metadata.get_value()
elif prop.value_type == "IfcPropertyEnumeratedValue": elif prop.value_type == "IfcPropertyEnumeratedValue":
+13 -7
View File
@@ -255,13 +255,16 @@ class BIM_PT_object_psets(Panel):
if not ObjectPsetsData.is_loaded: if not ObjectPsetsData.is_loaded:
ObjectPsetsData.load() ObjectPsetsData.load()
props = context.active_object.PsetProperties assert (obj := context.active_object)
props = tool.Pset.get_pset_props(obj.name, "Object")
self.bprops = tool.Bsdd.get_bsdd_props() self.bprops = tool.Bsdd.get_bsdd_props()
assert self.layout
row = self.layout.row(align=True) row = self.layout.row(align=True)
prop_with_search(row, props, "pset_name", text="") prop_with_search(row, props, "pset_name", text="")
if props.pset_name != "BBIM_BSDD" and not props.pset_name.startswith(tool.Bsdd.identifier_url): if props.pset_name != "BBIM_BSDD" and not props.pset_name.startswith(tool.Bsdd.identifier_url):
op = row.operator("bim.add_pset", icon="ADD", text="") op = row.operator("bim.add_pset", icon="ADD", text="")
op.obj = context.active_object.name op.obj = obj.name
op.obj_type = "Object" op.obj_type = "Object"
else: else:
row = self.layout.row(align=True) row = self.layout.row(align=True)
@@ -269,7 +272,7 @@ class BIM_PT_object_psets(Panel):
if self.bprops.property_filter_mode == "CLASS": if self.bprops.property_filter_mode == "CLASS":
row.prop(self.bprops, "should_filter_ifc_class", text="", icon="FILTER") row.prop(self.bprops, "should_filter_ifc_class", text="", icon="FILTER")
op = row.operator("bim.import_bsdd_classes", text="", icon="FILE_REFRESH") op = row.operator("bim.import_bsdd_classes", text="", icon="FILE_REFRESH")
op.obj = context.active_object.name op.obj = obj.name
op.obj_type = "Object" op.obj_type = "Object"
if len(self.bprops.classes): if len(self.bprops.classes):
@@ -299,7 +302,7 @@ class BIM_PT_object_psets(Panel):
elif self.bprops.property_filter_mode == "KEYWORD": elif self.bprops.property_filter_mode == "KEYWORD":
row.prop(self.bprops, "keyword", text="") row.prop(self.bprops, "keyword", text="")
op = row.operator("bim.search_bsdd_properties", text="", icon="VIEWZOOM") op = row.operator("bim.search_bsdd_properties", text="", icon="VIEWZOOM")
op.obj = context.active_object.name op.obj = obj.name
op.obj_type = "Object" op.obj_type = "Object"
if len(self.bprops.properties): if len(self.bprops.properties):
@@ -322,7 +325,7 @@ class BIM_PT_object_psets(Panel):
row = self.layout.row() row = self.layout.row()
op = row.operator("bim.add_bsdd_properties", icon="ADD") op = row.operator("bim.add_bsdd_properties", icon="ADD")
op.obj = context.active_object.name op.obj = obj.name
op.obj_type = "Object" op.obj_type = "Object"
global_props = tool.Pset.get_global_pset_props() global_props = tool.Pset.get_global_pset_props()
@@ -398,11 +401,14 @@ class BIM_PT_object_qtos(Panel):
if not ObjectQtosData.is_loaded: if not ObjectQtosData.is_loaded:
ObjectQtosData.load() ObjectQtosData.load()
props = context.active_object.PsetProperties assert (obj := context.active_object)
props = tool.Pset.get_pset_props(obj.name, "Object")
assert self.layout
row = self.layout.row(align=True) row = self.layout.row(align=True)
prop_with_search(row, props, "qto_name", text="") prop_with_search(row, props, "qto_name", text="")
op = row.operator("bim.add_qto", icon="ADD", text="") op = row.operator("bim.add_qto", icon="ADD", text="")
op.obj = context.active_object.name op.obj = obj.name
op.obj_type = "Object" op.obj_type = "Object"
global_props = tool.Pset.get_global_pset_props() global_props = tool.Pset.get_global_pset_props()
+1 -1
View File
@@ -66,6 +66,6 @@ class IfcSchema:
ifc = IfcSchema() ifc = IfcSchema()
def reload(schema_identifier): def reload(schema_identifier: str) -> None:
global ifc global ifc
ifc = IfcSchema(schema_identifier) ifc = IfcSchema(schema_identifier)
@@ -74,9 +74,10 @@ class PsetQto:
schema: ifcopenshell.util.schema.IFC_SCHEMA = "IFC4", schema: ifcopenshell.util.schema.IFC_SCHEMA = "IFC4",
) -> list[entity_instance]: ) -> list[entity_instance]:
any_class = not ifc_class any_class = not ifc_class
entity = None
if not any_class: if not any_class:
entity: W.entity entity = self.schema.declaration_by_name(ifc_class).as_entity()
entity = self.schema.declaration_by_name(ifc_class) assert entity
result = [] result = []
for template in self.templates: for template in self.templates:
for prop_set in template.by_type("IfcPropertySetTemplate"): for prop_set in template.by_type("IfcPropertySetTemplate"):
@@ -86,8 +87,11 @@ class PsetQto:
if qto_only: if qto_only:
if prop_set.TemplateType and prop_set.TemplateType.startswith("PSET_"): if prop_set.TemplateType and prop_set.TemplateType.startswith("PSET_"):
continue continue
if any_class or self.is_applicable( if any_class or (
entity, prop_set.ApplicableEntity or "IfcRoot", predefined_type, prop_set.TemplateType, schema entity
and self.is_applicable(
entity, prop_set.ApplicableEntity or "IfcRoot", predefined_type, prop_set.TemplateType, schema
)
): ):
result.append(prop_set) result.append(prop_set)
return result return result