mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
typing
This commit is contained in:
@@ -219,8 +219,8 @@ def refresh_ui_data():
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
if isinstance(tool.Ifc.get(), ifcopenshell.sqlite):
|
||||
tool.Ifc.get().clear_cache()
|
||||
if isinstance(ifc_file := tool.Ifc.get(), ifcopenshell.sqlite):
|
||||
ifc_file.clear_cache()
|
||||
|
||||
props = tool.Drawing.get_document_props()
|
||||
props.should_draw_decorations = props.should_draw_decorations
|
||||
|
||||
@@ -128,6 +128,8 @@ class IfcStore:
|
||||
def get_cache() -> ifcopenshell.geom.serializers.hdf5 | None:
|
||||
if IfcStore.cache is None and IfcStore.path:
|
||||
prefs = tool.Blender.get_addon_preferences()
|
||||
assert IfcStore.file
|
||||
|
||||
ifc_key = IfcStore.path + IfcStore.file.wrapped_data.header.file_name.time_stamp
|
||||
ifc_hash = hashlib.md5(ifc_key.encode("utf-8")).hexdigest()
|
||||
os.makedirs(prefs.cache_dir, exist_ok=True)
|
||||
|
||||
@@ -18,13 +18,9 @@
|
||||
|
||||
import bpy
|
||||
import json
|
||||
from bpy.types import Context, OperatorProperties
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.util.attribute
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.pset
|
||||
import ifcopenshell.util.unit
|
||||
import bonsai.bim.schema
|
||||
import bonsai.tool as tool
|
||||
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):
|
||||
bl_idname = "bim.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):
|
||||
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:
|
||||
is_pset = tool.Ifc.get().by_id(pset_id).is_a("IfcPropertySet")
|
||||
else:
|
||||
is_pset = context.active_object.PsetProperties.active_pset_type == "PSET"
|
||||
pset_name = context.active_object.PsetProperties.active_pset_name
|
||||
prop = context.active_object.PsetProperties.properties.get(self.name)
|
||||
is_pset = props.active_pset_type == "PSET"
|
||||
pset_name = props.active_pset_name
|
||||
prop = props.properties[self.name]
|
||||
if prop.value_type == "IfcPropertySingleValue":
|
||||
prop_value = prop.metadata.get_value()
|
||||
elif prop.value_type == "IfcPropertyEnumeratedValue":
|
||||
|
||||
@@ -255,13 +255,16 @@ class BIM_PT_object_psets(Panel):
|
||||
if not ObjectPsetsData.is_loaded:
|
||||
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()
|
||||
assert self.layout
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
prop_with_search(row, props, "pset_name", text="")
|
||||
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.obj = context.active_object.name
|
||||
op.obj = obj.name
|
||||
op.obj_type = "Object"
|
||||
else:
|
||||
row = self.layout.row(align=True)
|
||||
@@ -269,7 +272,7 @@ class BIM_PT_object_psets(Panel):
|
||||
if self.bprops.property_filter_mode == "CLASS":
|
||||
row.prop(self.bprops, "should_filter_ifc_class", text="", icon="FILTER")
|
||||
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"
|
||||
|
||||
if len(self.bprops.classes):
|
||||
@@ -299,7 +302,7 @@ class BIM_PT_object_psets(Panel):
|
||||
elif self.bprops.property_filter_mode == "KEYWORD":
|
||||
row.prop(self.bprops, "keyword", text="")
|
||||
op = row.operator("bim.search_bsdd_properties", text="", icon="VIEWZOOM")
|
||||
op.obj = context.active_object.name
|
||||
op.obj = obj.name
|
||||
op.obj_type = "Object"
|
||||
|
||||
if len(self.bprops.properties):
|
||||
@@ -322,7 +325,7 @@ class BIM_PT_object_psets(Panel):
|
||||
|
||||
row = self.layout.row()
|
||||
op = row.operator("bim.add_bsdd_properties", icon="ADD")
|
||||
op.obj = context.active_object.name
|
||||
op.obj = obj.name
|
||||
op.obj_type = "Object"
|
||||
|
||||
global_props = tool.Pset.get_global_pset_props()
|
||||
@@ -398,11 +401,14 @@ class BIM_PT_object_qtos(Panel):
|
||||
if not ObjectQtosData.is_loaded:
|
||||
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)
|
||||
prop_with_search(row, props, "qto_name", text="")
|
||||
op = row.operator("bim.add_qto", icon="ADD", text="")
|
||||
op.obj = context.active_object.name
|
||||
op.obj = obj.name
|
||||
op.obj_type = "Object"
|
||||
|
||||
global_props = tool.Pset.get_global_pset_props()
|
||||
|
||||
@@ -66,6 +66,6 @@ class IfcSchema:
|
||||
ifc = IfcSchema()
|
||||
|
||||
|
||||
def reload(schema_identifier):
|
||||
def reload(schema_identifier: str) -> None:
|
||||
global ifc
|
||||
ifc = IfcSchema(schema_identifier)
|
||||
|
||||
@@ -74,9 +74,10 @@ class PsetQto:
|
||||
schema: ifcopenshell.util.schema.IFC_SCHEMA = "IFC4",
|
||||
) -> list[entity_instance]:
|
||||
any_class = not ifc_class
|
||||
entity = None
|
||||
if not any_class:
|
||||
entity: W.entity
|
||||
entity = self.schema.declaration_by_name(ifc_class)
|
||||
entity = self.schema.declaration_by_name(ifc_class).as_entity()
|
||||
assert entity
|
||||
result = []
|
||||
for template in self.templates:
|
||||
for prop_set in template.by_type("IfcPropertySetTemplate"):
|
||||
@@ -86,8 +87,11 @@ class PsetQto:
|
||||
if qto_only:
|
||||
if prop_set.TemplateType and prop_set.TemplateType.startswith("PSET_"):
|
||||
continue
|
||||
if any_class or self.is_applicable(
|
||||
entity, prop_set.ApplicableEntity or "IfcRoot", predefined_type, prop_set.TemplateType, schema
|
||||
if any_class or (
|
||||
entity
|
||||
and self.is_applicable(
|
||||
entity, prop_set.ApplicableEntity or "IfcRoot", predefined_type, prop_set.TemplateType, schema
|
||||
)
|
||||
):
|
||||
result.append(prop_set)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user