mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 01:11:40 +00:00
Replace direct access to IfcStore with tool.Ifc
This commit is contained in:
@@ -60,7 +60,7 @@ def name_callback(obj: Union[bpy.types.Object, bpy.types.Material], data: str) -
|
||||
if props.is_renaming:
|
||||
props.is_renmaing = False
|
||||
return
|
||||
IfcStore.get_file().by_id(ifc_definition_id).Name = obj.name
|
||||
tool.Ifc.get().by_id(ifc_definition_id).Name = obj.name
|
||||
refresh_ui_data()
|
||||
return
|
||||
|
||||
@@ -71,7 +71,7 @@ def name_callback(obj: Union[bpy.types.Object, bpy.types.Material], data: str) -
|
||||
obj.BIMObjectProperties.is_renaming = False
|
||||
return
|
||||
|
||||
element = IfcStore.get_file().by_id(obj.BIMObjectProperties.ifc_definition_id)
|
||||
element = tool.Ifc.get().by_id(obj.BIMObjectProperties.ifc_definition_id)
|
||||
if "/" in obj.name:
|
||||
object_name = obj.name
|
||||
element_name = obj.name.split("/", 1)[1]
|
||||
@@ -231,9 +231,9 @@ def refresh_ui_data():
|
||||
def loadIfcStore(scene):
|
||||
IfcStore.purge()
|
||||
refresh_ui_data()
|
||||
if not IfcStore.get_file():
|
||||
if not tool.Ifc.get():
|
||||
return
|
||||
IfcStore.get_schema()
|
||||
tool.Ifc.schema()
|
||||
IfcStore.relink_all_objects()
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import ifcopenshell.util.element
|
||||
import ifcopenshell.util.unit
|
||||
from ifcopenshell.util.doc import get_attribute_doc, get_predefined_type_doc, get_property_doc
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from typing import Optional, Callable, Any, Union, Iterable, TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -119,7 +118,8 @@ def import_attributes(
|
||||
data: dict[str, Any],
|
||||
callback: Optional[ImportCallback] = None,
|
||||
) -> None:
|
||||
for attribute in IfcStore.get_schema().declaration_by_name(ifc_class).all_attributes():
|
||||
schema = tool.Ifc.schema()
|
||||
for attribute in schema.declaration_by_name(ifc_class).all_attributes():
|
||||
import_attribute(attribute, props, data, callback=callback)
|
||||
|
||||
|
||||
|
||||
@@ -881,7 +881,7 @@ class IfcImporter:
|
||||
self.ifc_import_settings.logger.info("loading file %s", self.ifc_import_settings.input_file)
|
||||
if not bpy.context.scene.BIMProperties.ifc_file:
|
||||
bpy.context.scene.BIMProperties.ifc_file = self.ifc_import_settings.input_file
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
|
||||
def calculate_unit_scale(self):
|
||||
self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(self.file)
|
||||
|
||||
@@ -23,7 +23,6 @@ import ifcopenshell.util.element
|
||||
import bonsai.tool as tool
|
||||
import bonsai.core.aggregate as core
|
||||
import bonsai.core.spatial
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
|
||||
|
||||
class BIM_OT_aggregate_assign_object(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
@@ -39,7 +39,7 @@ class BIM_PT_aggregate(Panel):
|
||||
props = context.active_object.BIMObjectProperties
|
||||
if not props.ifc_definition_id:
|
||||
return False
|
||||
if not IfcStore.get_element(props.ifc_definition_id):
|
||||
if not tool.Ifc.get_object_by_identifier(props.ifc_definition_id):
|
||||
return False
|
||||
if not IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcObjectDefinition"):
|
||||
return False
|
||||
@@ -120,9 +120,9 @@ class BIM_PT_linked_aggregate(Panel):
|
||||
props = context.active_object.BIMObjectProperties
|
||||
if not props.ifc_definition_id:
|
||||
return False
|
||||
if not IfcStore.get_element(props.ifc_definition_id):
|
||||
if not tool.Ifc.get_object_by_identifier(props.ifc_definition_id):
|
||||
return False
|
||||
if not IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcObjectDefinition"):
|
||||
if not tool.Ifc.get().by_id(props.ifc_definition_id).is_a("IfcObjectDefinition"):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import bonsai.bim.helper
|
||||
import bonsai.tool as tool
|
||||
import bonsai.core.attribute as core
|
||||
import bonsai.core.spatial
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
|
||||
|
||||
def get_objs_for_operation(operator_properties, context):
|
||||
@@ -117,7 +116,7 @@ class EditAttributes(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
obj = tool.Blender.get_active_object(is_selected=False)
|
||||
if not (element := tool.Ifc.get_entity(obj)):
|
||||
return
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.prop import StrProperty, Attribute
|
||||
from bpy.types import PropertyGroup
|
||||
from bpy.props import (
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
import bonsai.bim.helper
|
||||
from bpy.types import Panel
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.attribute.data import AttributesData
|
||||
import bonsai.tool as tool
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ import bonsai.tool as tool
|
||||
import bonsai.bim.module.bcf.prop as bcf_prop
|
||||
import bonsai.bim.module.bcf.bcfstore as bcfstore
|
||||
from pathlib import Path
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from math import radians, degrees, atan, tan, cos, sin
|
||||
from mathutils import Vector, Matrix, Euler, geometry
|
||||
from xsdata.models.datatype import XmlDateTime
|
||||
@@ -1206,7 +1205,7 @@ class ActivateBcfViewpoint(bpy.types.Operator):
|
||||
return True
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
bcfxml = bcfstore.BcfStore.get_bcfxml()
|
||||
assert bcfxml
|
||||
|
||||
@@ -1355,7 +1354,7 @@ class ActivateBcfViewpoint(bpy.types.Operator):
|
||||
|
||||
objs: list[bpy.types.Object] = []
|
||||
for global_id in exception_global_ids:
|
||||
obj = IfcStore.get_element(global_id)
|
||||
obj = tool.Ifc.get_object_by_identifier(global_id)
|
||||
if obj and context.view_layer.objects.get(obj.name):
|
||||
assert isinstance(obj, bpy.types.Object)
|
||||
objs.append(obj)
|
||||
@@ -1414,7 +1413,7 @@ class ActivateBcfViewpoint(bpy.types.Operator):
|
||||
return
|
||||
bpy.ops.object.select_all(action="DESELECT")
|
||||
for global_id in selected_global_ids:
|
||||
obj = IfcStore.get_element(global_id)
|
||||
obj = tool.Ifc.get_object_by_identifier(global_id)
|
||||
if obj:
|
||||
obj.select_set(True)
|
||||
obj.hide_set(False)
|
||||
@@ -1427,7 +1426,7 @@ class ActivateBcfViewpoint(bpy.types.Operator):
|
||||
for acomponent in acoloring.component:
|
||||
global_id_colours.setdefault(acomponent.ifc_guid, acoloring.color)
|
||||
for global_id, color in global_id_colours.items():
|
||||
obj = IfcStore.get_element(global_id)
|
||||
obj = tool.Ifc.get_object_by_identifier(global_id)
|
||||
if obj:
|
||||
obj.color = self.hex_to_rgb(color)
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
import bpy
|
||||
from bpy.types import Panel, UIList
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.module.boundary.data import SpaceBoundariesData
|
||||
|
||||
@@ -34,7 +33,7 @@ class BIM_PT_SceneBoundaries(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def draw(self, context):
|
||||
row = self.layout.row(align=True)
|
||||
@@ -58,9 +57,9 @@ class BIM_PT_Boundary(Panel):
|
||||
props = context.active_object.BIMObjectProperties
|
||||
if not props.ifc_definition_id:
|
||||
return False
|
||||
if not IfcStore.get_element(props.ifc_definition_id):
|
||||
if not tool.Ifc.get_object_by_identifier(props.ifc_definition_id):
|
||||
return False
|
||||
entity = IfcStore.get_file().by_id(props.ifc_definition_id)
|
||||
entity = tool.Ifc.get().by_id(props.ifc_definition_id)
|
||||
return entity.is_a("IfcRelSpaceBoundary")
|
||||
|
||||
def draw(self, context):
|
||||
@@ -134,7 +133,7 @@ class BIM_PT_SpaceBoundaries(Panel):
|
||||
props = context.active_object.BIMObjectProperties
|
||||
if not props.ifc_definition_id:
|
||||
return False
|
||||
if not IfcStore.get_element(props.ifc_definition_id):
|
||||
if not tool.Ifc.get_object_by_identifier(props.ifc_definition_id):
|
||||
return False
|
||||
element = tool.Ifc.get_entity(context.active_object)
|
||||
for ifc_class in ("IfcSpace", "IfcExternalSpatialElement"):
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
import bonsai.tool as tool
|
||||
from bpy.types import Panel, UIList
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
|
||||
|
||||
class BIM_PT_bsdd(Panel):
|
||||
|
||||
@@ -300,7 +300,7 @@ class SelectIfcClashResults(bpy.types.Operator):
|
||||
|
||||
def execute(self, context):
|
||||
# TODO refactor into new clash results system
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
self.filepath = bpy.path.ensure_ext(self.filepath, ".json")
|
||||
with open(self.filepath) as f:
|
||||
clash_sets = json.load(f)
|
||||
@@ -478,7 +478,7 @@ class SelectSmartGroup(bpy.types.Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file() and context.visible_objects and context.scene.BIMClashProperties.active_smart_group
|
||||
return tool.Ifc.get() and context.visible_objects and context.scene.BIMClashProperties.active_smart_group
|
||||
|
||||
def execute(self, context):
|
||||
selected_smart_group = context.scene.BIMClashProperties.active_smart_group
|
||||
|
||||
@@ -240,7 +240,7 @@ class RemoveClassification(bpy.types.Operator, tool.Ifc.Operator):
|
||||
classification: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"classification.remove_classification",
|
||||
tool.Ifc.get(),
|
||||
|
||||
@@ -21,7 +21,6 @@ import bonsai.bim.helper
|
||||
import bonsai.tool as tool
|
||||
import bonsai.bim.module.classification.prop as classification_prop
|
||||
from bpy.types import Panel, UIList
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.classification.data import (
|
||||
ClassificationsData,
|
||||
ClassificationReferencesData,
|
||||
@@ -124,7 +123,7 @@ class ReferenceUI:
|
||||
self.sprops = context.scene.BIMClassificationProperties
|
||||
self.bprops = context.scene.BIMBSDDProperties
|
||||
self.props = context.scene.BIMClassificationReferenceProperties
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
|
||||
self.draw_add_ui(context)
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import ifcopenshell.api.constraint
|
||||
import ifcopenshell.util.attribute
|
||||
import bonsai.bim.helper
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
|
||||
|
||||
class LoadObjectives(bpy.types.Operator):
|
||||
@@ -84,7 +83,7 @@ class AddObjective(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def _execute(self, context):
|
||||
result = ifcopenshell.api.run("constraint.add_objective", IfcStore.get_file())
|
||||
result = ifcopenshell.api.run("constraint.add_objective", tool.Ifc.get())
|
||||
bpy.ops.bim.load_objectives()
|
||||
bpy.ops.bim.enable_editing_constraint(constraint=result.id())
|
||||
return {"FINISHED"}
|
||||
@@ -116,7 +115,7 @@ class RemoveConstraint(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMConstraintProperties
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"constraint.remove_constraint", self.file, **{"constraint": self.file.by_id(self.constraint)}
|
||||
)
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bonsai.tool as tool
|
||||
from bpy.types import Panel, UIList
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.helper import draw_attributes
|
||||
from bonsai.bim.module.constraint.data import ConstraintsData, ObjectConstraintsData
|
||||
|
||||
@@ -33,7 +33,7 @@ class BIM_PT_constraints(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def draw(self, context):
|
||||
if not ConstraintsData.is_loaded:
|
||||
@@ -81,7 +81,7 @@ class BIM_PT_object_constraints(Panel):
|
||||
def poll(cls, context):
|
||||
if not context.active_object:
|
||||
return False
|
||||
if not IfcStore.get_element(context.active_object.BIMObjectProperties.ifc_definition_id):
|
||||
if not tool.Ifc.get_object_by_identifier(context.active_object.BIMObjectProperties.ifc_definition_id):
|
||||
return False
|
||||
return bool(context.active_object.BIMObjectProperties.ifc_definition_id)
|
||||
|
||||
@@ -93,7 +93,7 @@ class BIM_PT_object_constraints(Panel):
|
||||
self.oprops = obj.BIMObjectProperties
|
||||
self.sprops = context.scene.BIMConstraintProperties
|
||||
self.props = obj.BIMObjectConstraintProperties
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
|
||||
self.draw_add_ui()
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
import bpy
|
||||
import ifcopenshell.api
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.classification.data import CostClassificationsData
|
||||
from bonsai.bim.module.cost.data import CostSchedulesData, CostItemRatesData, CostItemQuantitiesData
|
||||
from bonsai.bim.prop import StrProperty, Attribute
|
||||
@@ -83,7 +82,7 @@ def update_cost_item_identification(self, context):
|
||||
props = context.scene.BIMCostProperties
|
||||
if not props.is_cost_update_enabled or self.identification == "XXX":
|
||||
return
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"cost.edit_cost_item",
|
||||
self.file,
|
||||
@@ -98,7 +97,7 @@ def update_cost_item_name(self, context):
|
||||
props = context.scene.BIMCostProperties
|
||||
if not props.is_cost_update_enabled or self.name == "Unnamed":
|
||||
return
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"cost.edit_cost_item",
|
||||
self.file,
|
||||
|
||||
@@ -21,7 +21,6 @@ import bonsai.bim.helper
|
||||
import bonsai.bim.module.cost.prop as CostProp
|
||||
import bonsai.tool as tool
|
||||
from bpy.types import Panel, UIList
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.cost.data import CostSchedulesData
|
||||
from typing import Any
|
||||
|
||||
@@ -37,7 +36,7 @@ class BIM_PT_cost_schedules(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
return file and hasattr(file, "schema") and file.schema != "IFC2X3"
|
||||
|
||||
def draw(self, context):
|
||||
|
||||
@@ -20,8 +20,8 @@ import bpy
|
||||
import json
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
import bonsai.tool as tool
|
||||
from math import degrees, atan2
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
|
||||
from .api import Api
|
||||
|
||||
@@ -92,7 +92,7 @@ class RunAnalysis(bpy.types.Operator):
|
||||
bl_label = "Run Analysis"
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
self.inputs = {
|
||||
"floors": [],
|
||||
"walls": [],
|
||||
|
||||
@@ -27,7 +27,6 @@ import ifcopenshell
|
||||
import ifcopenshell.util.selector
|
||||
import bonsai.tool as tool
|
||||
import bonsai.bim.module.drawing.scheduler as scheduler
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.handler import refresh_ui_data
|
||||
from typing import TYPE_CHECKING
|
||||
from collections import Counter
|
||||
@@ -212,7 +211,7 @@ class ExportIfcCsv(bpy.types.Operator):
|
||||
props = context.scene.CsvProperties
|
||||
self.filepath = bpy.path.ensure_ext(self.filepath, f".{props.format}")
|
||||
if props.should_load_from_memory:
|
||||
ifc_file = IfcStore.get_file()
|
||||
ifc_file = tool.Ifc.get()
|
||||
else:
|
||||
ifc_file = ifcopenshell.open(props.csv_ifc_file)
|
||||
results = ifcopenshell.util.selector.filter_elements(
|
||||
@@ -314,7 +313,7 @@ class ImportIfcCsv(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
props = context.scene.CsvProperties
|
||||
if props.should_load_from_memory:
|
||||
ifc_file = IfcStore.get_file()
|
||||
ifc_file = tool.Ifc.get()
|
||||
else:
|
||||
ifc_file = ifcopenshell.open(props.csv_ifc_file)
|
||||
ifc_csv = ifccsv.IfcCsv()
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bonsai.bim.helper
|
||||
import bonsai.tool as tool
|
||||
from bpy.types import Panel
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.search.data import SearchData
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class BIM_PT_ifccsv(Panel):
|
||||
scene = context.scene
|
||||
props = scene.CsvProperties
|
||||
|
||||
if IfcStore.get_file():
|
||||
if tool.Ifc.get():
|
||||
row = layout.row(align=True)
|
||||
row.prop(props, "should_load_from_memory")
|
||||
row.operator("bim.import_csv_attributes", icon="IMPORT", text="")
|
||||
@@ -49,7 +49,7 @@ class BIM_PT_ifccsv(Panel):
|
||||
row.operator("bim.export_csv_attributes", icon="EXPORT", text="")
|
||||
row.prop(props, "should_show_settings", icon="PREFERENCES", text="")
|
||||
|
||||
if not IfcStore.get_file() or not props.should_load_from_memory:
|
||||
if not tool.Ifc.get() or not props.should_load_from_memory:
|
||||
row = layout.row(align=True)
|
||||
row.prop(props, "csv_ifc_file")
|
||||
row.operator("bim.select_csv_ifc_file", icon="FILE_FOLDER", text="")
|
||||
|
||||
@@ -78,10 +78,10 @@ class PrintIfcFile(bpy.types.Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def execute(self, context):
|
||||
print(IfcStore.get_file().wrapped_data.to_string())
|
||||
print(tool.Ifc.get().wrapped_data.to_string())
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -184,10 +184,10 @@ class CreateAllShapes(bpy.types.Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
elements = self.file.by_type("IfcElement") + self.file.by_type("IfcSpace")
|
||||
|
||||
total = len(elements)
|
||||
@@ -328,10 +328,10 @@ class InspectFromStepId(bpy.types.Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
debug_props = tool.Debug.get_debug_props()
|
||||
debug_props.active_step_id = self.step_id
|
||||
crumb = debug_props.step_id_breadcrumb.add()
|
||||
@@ -422,7 +422,7 @@ class PrintObjectPlacement(bpy.types.Operator):
|
||||
return self.execute(context)
|
||||
|
||||
def execute(self, context):
|
||||
placement = ifcopenshell.util.placement.get_local_placement(IfcStore.get_file().by_id(self.step_id))
|
||||
placement = ifcopenshell.util.placement.get_local_placement(tool.Ifc.get().by_id(self.step_id))
|
||||
if self.create_empty_object:
|
||||
bpy.ops.object.empty_add(type="ARROWS")
|
||||
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from bpy.types import Panel
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.diff.data import DiffData
|
||||
import bonsai.bim.helper
|
||||
import bonsai.tool as tool
|
||||
|
||||
@@ -24,7 +24,6 @@ import ifcopenshell.util.element
|
||||
import bonsai.bim.handler
|
||||
import bonsai.tool as tool
|
||||
import bonsai.core.document as core
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
|
||||
|
||||
class LoadProjectDocuments(bpy.types.Operator):
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bonsai.tool as tool
|
||||
from bpy.types import Panel, UIList
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.helper import draw_attributes
|
||||
from bonsai.bim.module.document.data import DocumentData, ObjectDocumentData
|
||||
|
||||
@@ -33,7 +33,7 @@ class BIM_PT_documents(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def draw(self, context):
|
||||
if not DocumentData.is_loaded:
|
||||
@@ -92,7 +92,7 @@ class BIM_PT_object_documents(Panel):
|
||||
def poll(cls, context):
|
||||
if not context.active_object:
|
||||
return False
|
||||
if not IfcStore.get_element(context.active_object.BIMObjectProperties.ifc_definition_id):
|
||||
if not tool.Ifc.get_object_by_identifier(context.active_object.BIMObjectProperties.ifc_definition_id):
|
||||
return False
|
||||
return bool(context.active_object.BIMObjectProperties.ifc_definition_id)
|
||||
|
||||
@@ -103,7 +103,7 @@ class BIM_PT_object_documents(Panel):
|
||||
obj = context.active_object
|
||||
self.oprops = obj.BIMObjectProperties
|
||||
self.props = context.scene.BIMDocumentProperties
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
|
||||
self.draw_add_ui()
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ class CreateDrawing(bpy.types.Operator):
|
||||
self.camera = context.scene.camera
|
||||
self.camera_element = tool.Ifc.get_entity(self.camera)
|
||||
self.camera_document = tool.Drawing.get_drawing_document(self.camera_element)
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
|
||||
with profile("Drawing generation process"):
|
||||
with profile("Initialize drawing generation process"):
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
import bonsai.tool as tool
|
||||
from bpy.types import Panel
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.fm.data import FMData
|
||||
|
||||
|
||||
@@ -40,11 +39,11 @@ class BIM_PT_fm(Panel):
|
||||
scene = context.scene
|
||||
props = scene.BIMFMProperties
|
||||
|
||||
if IfcStore.get_file():
|
||||
if tool.Ifc.get():
|
||||
row = layout.row()
|
||||
row.prop(props, "should_load_from_memory")
|
||||
|
||||
if not IfcStore.get_file() or not props.should_load_from_memory:
|
||||
if not tool.Ifc.get() or not props.should_load_from_memory:
|
||||
row = layout.row()
|
||||
props.ifc_files.layout_file_select(row, "*.ifc;*.ifczip;*.ifcxml", "IFC File(s)")
|
||||
|
||||
|
||||
@@ -609,7 +609,7 @@ class UpdateParametricRepresentation(bpy.types.Operator):
|
||||
return (obj := context.active_object) and obj.mode == "OBJECT" and tool.Geometry.has_mesh_properties(obj.data)
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
obj = context.active_object
|
||||
assert obj and tool.Geometry.has_mesh_properties(obj.data)
|
||||
props = tool.Geometry.get_mesh_props(obj.data)
|
||||
@@ -834,7 +834,7 @@ class OverrideOutlinerDelete(bpy.types.Operator):
|
||||
# unintended IFC spatial modifications. To make life less confusing for
|
||||
# the user, Delete means Delete. End of story.
|
||||
# Deep magick from the dawn of time
|
||||
if IfcStore.get_file():
|
||||
if tool.Ifc.get():
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
# https://blender.stackexchange.com/questions/203729/python-get-selected-objects-in-outliner
|
||||
objects_to_delete = set()
|
||||
@@ -958,7 +958,7 @@ class OverrideDuplicateMove(bpy.types.Operator):
|
||||
@staticmethod
|
||||
def execute_duplicate_operator(self, context, linked=False):
|
||||
# Deep magick from the dawn of time
|
||||
if IfcStore.get_file():
|
||||
if tool.Ifc.get():
|
||||
IfcStore.execute_ifc_operator(self, context)
|
||||
if self.new_active_obj:
|
||||
context.view_layer.objects.active = self.new_active_obj
|
||||
@@ -3218,7 +3218,7 @@ class OverrideMove(bpy.types.Operator):
|
||||
|
||||
def execute(self, context):
|
||||
# Deep magick from the dawn of time
|
||||
if IfcStore.get_file():
|
||||
if tool.Ifc.get():
|
||||
IfcStore.execute_ifc_operator(self, context)
|
||||
if self.new_active_obj:
|
||||
context.view_layer.objects.active = self.new_active_obj
|
||||
|
||||
@@ -20,7 +20,6 @@ import bpy
|
||||
import bonsai.bim
|
||||
import bonsai.tool as tool
|
||||
from bpy.types import Panel, Menu, UIList
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.helper import prop_with_search
|
||||
from bonsai.bim.module.geometry.data import (
|
||||
RepresentationsData,
|
||||
@@ -337,9 +336,9 @@ class BIM_PT_connections(Panel):
|
||||
def poll(cls, context):
|
||||
if not context.active_object:
|
||||
return False
|
||||
if not IfcStore.get_element(context.active_object.BIMObjectProperties.ifc_definition_id):
|
||||
if not tool.Ifc.get_object_by_identifier(context.active_object.BIMObjectProperties.ifc_definition_id):
|
||||
return False
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def draw(self, context):
|
||||
if not ConnectionsData.is_loaded:
|
||||
|
||||
@@ -22,7 +22,6 @@ import ifcopenshell.api.group
|
||||
import ifcopenshell.util.attribute
|
||||
import bonsai.bim.helper
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
import json
|
||||
|
||||
|
||||
@@ -129,8 +128,7 @@ class RemoveGroup(bpy.types.Operator, tool.Ifc.Operator):
|
||||
group: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMGroupProperties
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run("group.remove_group", self.file, **{"group": self.file.by_id(self.group)})
|
||||
bpy.ops.bim.load_groups()
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import bonsai.tool as tool
|
||||
from bpy.types import Panel, UIList
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.helper import draw_attributes
|
||||
from bonsai.bim.module.group.data import GroupsData, ObjectGroupsData
|
||||
|
||||
@@ -34,7 +34,7 @@ class BIM_PT_groups(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def draw(self, context):
|
||||
if not GroupsData.is_loaded:
|
||||
@@ -93,7 +93,7 @@ class BIM_PT_object_groups(Panel):
|
||||
def poll(cls, context):
|
||||
if not context.active_object:
|
||||
return False
|
||||
return IfcStore.get_file() and context.active_object.BIMObjectProperties.ifc_definition_id
|
||||
return tool.Ifc.get() and context.active_object.BIMObjectProperties.ifc_definition_id
|
||||
|
||||
def draw(self, context):
|
||||
if not ObjectGroupsData.is_loaded:
|
||||
|
||||
@@ -24,7 +24,6 @@ import ifcopenshell.util.element
|
||||
import ifcopenshell.util.attribute
|
||||
import bonsai.bim.helper
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
|
||||
|
||||
class LoadLayers(bpy.types.Operator):
|
||||
@@ -33,7 +32,7 @@ class LoadLayers(bpy.types.Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
props = context.scene.BIMLayerProperties
|
||||
props.layers.clear()
|
||||
for layer in tool.Ifc.get().by_type("IfcPresentationLayerAssignment"):
|
||||
@@ -126,7 +125,7 @@ class RemovePresentationLayer(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMLayerProperties
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run("layer.remove_layer", self.file, **{"layer": self.file.by_id(self.layer)})
|
||||
bpy.ops.bim.load_layers()
|
||||
return {"FINISHED"}
|
||||
@@ -142,7 +141,7 @@ class AssignPresentationLayer(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
item = bpy.data.meshes.get(self.item) if self.item else context.active_object.data
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"layer.assign_layer",
|
||||
self.file,
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import bonsai.tool as tool
|
||||
from bpy.types import Panel, UIList, Mesh
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.helper import draw_attributes
|
||||
from bonsai.bim.module.layer.data import LayersData
|
||||
|
||||
@@ -34,7 +34,7 @@ class BIM_PT_layers(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def draw(self, context):
|
||||
if not LayersData.is_loaded:
|
||||
|
||||
@@ -29,7 +29,6 @@ import bonsai.tool as tool
|
||||
import bonsai.core.style
|
||||
import bonsai.core.material as core
|
||||
import bonsai.bim.module.model.profile as model_profile
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from typing import Any, Union, TYPE_CHECKING
|
||||
from bonsai.bim.module.model import wall, slab
|
||||
|
||||
@@ -118,7 +117,7 @@ class AssignParameterizedProfile(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
profile = ifcopenshell.api.run(
|
||||
"profile.add_parameterized_profile",
|
||||
self.file,
|
||||
@@ -292,7 +291,7 @@ class AddConstituent(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"material.add_constituent",
|
||||
self.file,
|
||||
@@ -328,7 +327,7 @@ class AddProfile(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
props = tool.Material.get_material_props()
|
||||
ifcopenshell.api.run(
|
||||
"material.add_profile",
|
||||
@@ -387,7 +386,7 @@ class ReorderMaterialSetItem(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
material_set = self.file.by_id(self.material_set)
|
||||
ifcopenshell.api.run(
|
||||
"material.reorder_set_item",
|
||||
@@ -443,7 +442,7 @@ class AddListItem(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"material.add_list_item",
|
||||
self.file,
|
||||
@@ -463,7 +462,7 @@ class RemoveListItem(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"material.remove_list_item",
|
||||
self.file,
|
||||
@@ -557,7 +556,7 @@ class EditAssignedMaterial(bpy.types.Operator, tool.Ifc.Operator):
|
||||
material_set_usage: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
active_obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
||||
props = active_obj.BIMObjectMaterialProperties
|
||||
element = tool.Ifc.get_entity(active_obj)
|
||||
@@ -663,7 +662,7 @@ class EnableEditingMaterialSetItem(bpy.types.Operator):
|
||||
material_set_item: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
||||
self.mprops = tool.Material.get_material_props()
|
||||
self.props = obj.BIMObjectMaterialProperties
|
||||
@@ -707,7 +706,7 @@ class EditMaterialSetItem(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
props = obj.BIMObjectMaterialProperties
|
||||
mprops = tool.Material.get_material_props()
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
|
||||
@@ -22,7 +22,6 @@ from ifcopenshell.util.doc import get_entity_doc
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.module.material.data import MaterialsData, ObjectMaterialData
|
||||
from bonsai.bim.module.profile.data import ProfileData
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.prop import StrProperty, Attribute
|
||||
from bpy.types import PropertyGroup
|
||||
from bpy.props import (
|
||||
|
||||
@@ -21,7 +21,6 @@ import bonsai.bim.helper
|
||||
import bonsai.tool as tool
|
||||
import bpy
|
||||
from bpy.types import Panel, UIList
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.helper import draw_attributes
|
||||
from bonsai.bim.helper import prop_with_search
|
||||
from bonsai.bim.module.material.data import MaterialsData, ObjectMaterialData
|
||||
@@ -43,7 +42,7 @@ class BIM_PT_materials(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def draw(self, context):
|
||||
if not MaterialsData.is_loaded:
|
||||
@@ -143,9 +142,9 @@ class BIM_PT_object_material(Panel):
|
||||
props = context.active_object.BIMObjectProperties
|
||||
if not props.ifc_definition_id:
|
||||
return False
|
||||
if not IfcStore.get_element(props.ifc_definition_id):
|
||||
if not tool.Ifc.get_object_by_identifier(props.ifc_definition_id):
|
||||
return False
|
||||
if not hasattr(IfcStore.get_file().by_id(props.ifc_definition_id), "HasAssociations"):
|
||||
if not hasattr(tool.Ifc.get().by_id(props.ifc_definition_id), "HasAssociations"):
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -153,7 +152,7 @@ class BIM_PT_object_material(Panel):
|
||||
if not ObjectMaterialData.is_loaded:
|
||||
ObjectMaterialData.load()
|
||||
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
self.oprops = context.active_object.BIMObjectProperties
|
||||
self.props = context.active_object.BIMObjectMaterialProperties
|
||||
self.mprops = tool.Material.get_material_props()
|
||||
|
||||
@@ -20,7 +20,6 @@ import bpy
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
from bonsai.bim.module.model import product, wall, slab, profile, opening, task
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bpy.app.handlers import persistent
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ import bonsai.tool as tool
|
||||
import bonsai.core.geometry
|
||||
import bonsai.bim.import_ifc as import_ifc
|
||||
from collections import defaultdict
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from math import pi, radians
|
||||
from mathutils import Vector, Matrix
|
||||
from bpy.types import Operator
|
||||
|
||||
@@ -35,7 +35,6 @@ import bonsai.core.root
|
||||
import bonsai.core.geometry
|
||||
import bonsai.core.model as core
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from math import pi, sin, cos, degrees, tan, radians
|
||||
from mathutils import Vector, Matrix, Quaternion
|
||||
from bonsai.bim.module.model.opening import FilledOpeningGenerator
|
||||
|
||||
@@ -757,7 +757,7 @@ def regenerate_profile_usage(usecase_path, ifc_file, settings):
|
||||
elements.append(element)
|
||||
|
||||
for element in elements:
|
||||
obj = IfcStore.get_element(element.id())
|
||||
obj = tool.Ifc.get_object_by_identifier(element.id())
|
||||
if not obj:
|
||||
continue
|
||||
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||
|
||||
@@ -889,7 +889,7 @@ class DrawPolylineSlab(bpy.types.Operator, PolylineOperator, tool.Ifc.Operator):
|
||||
model_props = tool.Model.get_model_props()
|
||||
direction_sense = model_props.direction_sense
|
||||
offset = model_props.offset
|
||||
model = IfcStore.get_file()
|
||||
model = tool.Ifc.get()
|
||||
element = tool.Ifc.get_entity(slab)
|
||||
material = ifcopenshell.util.element.get_material(element)
|
||||
material_set_usage = model.by_id(material.id())
|
||||
|
||||
@@ -377,7 +377,7 @@ class DrawPolylineWall(bpy.types.Operator, PolylineOperator, tool.Ifc.Operator):
|
||||
|
||||
walls, is_polyline_closed = DumbWallGenerator(self.relating_type).generate("POLYLINE")
|
||||
for wall in walls:
|
||||
model = IfcStore.get_file()
|
||||
model = tool.Ifc.get()
|
||||
element = tool.Ifc.get_entity(wall["obj"])
|
||||
material = ifcopenshell.util.element.get_material(element)
|
||||
material_set_usage = model.by_id(material.id())
|
||||
@@ -598,7 +598,7 @@ class DumbWallGenerator:
|
||||
self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||
|
||||
def generate(self, insertion_type="CURSOR"):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
self.layers = tool.Model.get_material_layer_parameters(self.relating_type)
|
||||
if not self.layers["thickness"]:
|
||||
return
|
||||
|
||||
@@ -21,7 +21,6 @@ import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
import bonsai.tool as tool
|
||||
import bonsai.core.nest as core
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
|
||||
|
||||
class BIM_OT_nest_assign_object(bpy.types.Operator, tool.Ifc.Operator):
|
||||
@@ -113,7 +112,7 @@ class BIM_OT_select_components(bpy.types.Operator):
|
||||
obj: bpy.props.StringProperty()
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
obj = bpy.data.objects.get(self.obj) or context.active_object
|
||||
components = ifcopenshell.util.element.get_components(tool.Ifc.get_entity(obj))
|
||||
component_objs = set(tool.Ifc.get_object(c) for c in components)
|
||||
@@ -132,7 +131,7 @@ class BIM_OT_select_nest(bpy.types.Operator):
|
||||
obj: bpy.props.StringProperty()
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
obj = bpy.data.objects.get(self.obj) or context.active_object
|
||||
nest = ifcopenshell.util.element.get_nest(tool.Ifc.get_entity(obj))
|
||||
nest_obj = tool.Ifc.get_object(nest)
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bonsai.tool as tool
|
||||
from bpy.types import Panel
|
||||
from bonsai.bim.module.nest.data import NestData
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
|
||||
|
||||
class BIM_PT_nest(Panel):
|
||||
@@ -37,9 +37,9 @@ class BIM_PT_nest(Panel):
|
||||
props = context.active_object.BIMObjectProperties
|
||||
if not props.ifc_definition_id:
|
||||
return False
|
||||
if not IfcStore.get_element(props.ifc_definition_id):
|
||||
if not tool.Ifc.get_object_by_identifier(props.ifc_definition_id):
|
||||
return False
|
||||
if not IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcObjectDefinition"):
|
||||
if not tool.Ifc.get().by_id(props.ifc_definition_id).is_a("IfcObjectDefinition"):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import ifcopenshell
|
||||
import ifcopenshell.util.schema
|
||||
import ifcopenshell.util.attribute
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.prop import StrProperty, Attribute
|
||||
from bonsai.bim.module.profile.data import ProfileData
|
||||
from bpy.types import PropertyGroup
|
||||
|
||||
@@ -503,10 +503,10 @@ class AppendEntireLibrary(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
self.library = IfcStore.library_file
|
||||
|
||||
query = ", ".join(tool.Project.get_appendable_asset_types())
|
||||
@@ -523,10 +523,10 @@ class AppendLibraryElementByQuery(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
self.library = IfcStore.library_file
|
||||
|
||||
for element in ifcopenshell.util.selector.filter_elements(self.library, self.query):
|
||||
@@ -556,7 +556,7 @@ class AppendLibraryElement(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
poll = bool(IfcStore.get_file())
|
||||
poll = bool(tool.Ifc.get())
|
||||
if not poll:
|
||||
cls.poll_message_set("Please create or load a project first.")
|
||||
return poll
|
||||
@@ -602,7 +602,7 @@ class AppendLibraryElement(bpy.types.Operator, tool.Ifc.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
def import_material_from_ifc(self, element: ifcopenshell.entity_instance, context: bpy.types.Context) -> None:
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
logger = logging.getLogger("ImportIFC")
|
||||
ifc_import_settings = import_ifc.IfcImportSettings.factory(context, IfcStore.path, logger)
|
||||
ifc_importer = import_ifc.IfcImporter(ifc_import_settings)
|
||||
@@ -620,7 +620,7 @@ class AppendLibraryElement(bpy.types.Operator, tool.Ifc.Operator):
|
||||
ifc_importer.create_style(style)
|
||||
|
||||
def import_product_from_ifc(self, element: ifcopenshell.entity_instance, context: bpy.types.Context) -> None:
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
logger = logging.getLogger("ImportIFC")
|
||||
ifc_import_settings = import_ifc.IfcImportSettings.factory(context, IfcStore.path, logger)
|
||||
ifc_importer = import_ifc.IfcImporter(ifc_import_settings)
|
||||
@@ -633,7 +633,7 @@ class AppendLibraryElement(bpy.types.Operator, tool.Ifc.Operator):
|
||||
ifc_importer.place_objects_in_collections()
|
||||
|
||||
def import_type_from_ifc(self, element: ifcopenshell.entity_instance, context: bpy.types.Context) -> None:
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
logger = logging.getLogger("ImportIFC")
|
||||
ifc_import_settings = import_ifc.IfcImportSettings.factory(context, IfcStore.path, logger)
|
||||
|
||||
@@ -648,7 +648,7 @@ class AppendLibraryElement(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def import_materials(self, element: ifcopenshell.entity_instance, ifc_importer: import_ifc.IfcImporter) -> None:
|
||||
for material in ifcopenshell.util.element.get_materials(element):
|
||||
if IfcStore.get_element(material.id()):
|
||||
if tool.Ifc.get_object_by_identifier(material.id()):
|
||||
continue
|
||||
self.import_material_styles(material, ifc_importer)
|
||||
|
||||
@@ -662,7 +662,7 @@ class AppendLibraryElement(bpy.types.Operator, tool.Ifc.Operator):
|
||||
if not element.is_a("IfcRepresentationItem") or not element.StyledByItem:
|
||||
continue
|
||||
for element2 in self.file.traverse(element.StyledByItem[0]):
|
||||
if element2.is_a("IfcSurfaceStyle") and not IfcStore.get_element(element2.id()):
|
||||
if element2.is_a("IfcSurfaceStyle") and not tool.Ifc.get_object_by_identifier(element2.id()):
|
||||
ifc_importer.create_style(element2)
|
||||
|
||||
def import_material_styles(
|
||||
@@ -673,7 +673,7 @@ class AppendLibraryElement(bpy.types.Operator, tool.Ifc.Operator):
|
||||
if not material.HasRepresentation:
|
||||
return
|
||||
for element in self.file.traverse(material.HasRepresentation[0]):
|
||||
if element.is_a("IfcSurfaceStyle") and not IfcStore.get_element(element.id()):
|
||||
if element.is_a("IfcSurfaceStyle") and not tool.Ifc.get_object_by_identifier(element.id()):
|
||||
ifc_importer.create_style(element)
|
||||
|
||||
|
||||
@@ -770,14 +770,14 @@ class EnableEditingHeader(bpy.types.Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def execute(self, context):
|
||||
self.file = tool.Ifc.get()
|
||||
props = tool.Project.get_project_props()
|
||||
props.is_editing = True
|
||||
|
||||
mvd = "".join(IfcStore.get_file().wrapped_data.header.file_description.description)
|
||||
mvd = "".join(tool.Ifc.get().wrapped_data.header.file_description.description)
|
||||
if "[" in mvd:
|
||||
props.mvd = mvd.split("[")[1][0:-1]
|
||||
else:
|
||||
@@ -807,7 +807,7 @@ class EditHeader(bpy.types.Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def execute(self, context):
|
||||
IfcStore.begin_transaction(self)
|
||||
@@ -832,7 +832,7 @@ class EditHeader(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
def record_state(self):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
return {
|
||||
"description": self.file.wrapped_data.header.file_description.description,
|
||||
"author": self.file.wrapped_data.header.file_name.author,
|
||||
@@ -841,14 +841,14 @@ class EditHeader(bpy.types.Operator):
|
||||
}
|
||||
|
||||
def rollback(self, data):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
file.wrapped_data.header.file_description.description = data["old"]["description"]
|
||||
file.wrapped_data.header.file_name.author = data["old"]["author"]
|
||||
file.wrapped_data.header.file_name.organization = data["old"]["organisation"]
|
||||
file.wrapped_data.header.file_name.authorization = data["old"]["authorisation"]
|
||||
|
||||
def commit(self, data):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
file.wrapped_data.header.file_description.description = data["new"]["description"]
|
||||
file.wrapped_data.header.file_name.author = data["new"]["author"]
|
||||
file.wrapped_data.header.file_name.organization = data["new"]["organisation"]
|
||||
|
||||
@@ -121,7 +121,7 @@ def update_filter_mode(self: "BIMProjectProperties", context: bpy.types.Context)
|
||||
self.filter_categories.clear()
|
||||
if self.filter_mode == "NONE":
|
||||
return
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
if self.filter_mode == "DECOMPOSITION":
|
||||
if file.schema == "IFC2X3":
|
||||
elements = file.by_type("IfcSpatialStructureElement")
|
||||
|
||||
@@ -153,7 +153,7 @@ class BIM_PT_project(Panel):
|
||||
self.layout.use_property_split = True
|
||||
props = context.scene.BIMProperties
|
||||
pprops = self.props = tool.Project.get_project_props()
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
if pprops.is_loading:
|
||||
self.draw_advanced_loading_ui(context)
|
||||
elif self.file or props.ifc_file:
|
||||
@@ -247,7 +247,7 @@ class BIM_PT_project(Panel):
|
||||
|
||||
def draw_editing_buttons(self, context, row):
|
||||
pprops = self.props
|
||||
if IfcStore.get_file():
|
||||
if tool.Ifc.get():
|
||||
if pprops.is_editing:
|
||||
row.operator("bim.edit_header", icon="CHECKMARK", text="")
|
||||
row.operator("bim.disable_editing_header", icon="CANCEL", text="")
|
||||
@@ -257,10 +257,10 @@ class BIM_PT_project(Panel):
|
||||
def draw_editable_file_info(self, context):
|
||||
pprops = self.props
|
||||
|
||||
if IfcStore.get_file():
|
||||
if tool.Ifc.get():
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="IFC Schema", icon="FILE_CACHE")
|
||||
row.label(text=IfcStore.get_file().schema)
|
||||
row.label(text=tool.Ifc.get().schema)
|
||||
|
||||
if pprops.is_editing:
|
||||
row = self.layout.row(align=True)
|
||||
@@ -281,7 +281,7 @@ class BIM_PT_project(Panel):
|
||||
else:
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="IFC MVD", icon="FILE_HIDDEN")
|
||||
mvd = "".join(IfcStore.get_file().wrapped_data.header.file_description.description)
|
||||
mvd = "".join(tool.Ifc.get().wrapped_data.header.file_description.description)
|
||||
if "[" in mvd:
|
||||
mvd = mvd.split("[")[1][0:-1]
|
||||
row.label(text=mvd)
|
||||
|
||||
@@ -94,7 +94,7 @@ class EditPset(bpy.types.Operator, tool.Ifc.Operator):
|
||||
properties: bpy.props.StringProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
props = tool.Pset.get_pset_props(self.obj, self.obj_type)
|
||||
ifc_definition_id = tool.Blender.get_obj_ifc_definition_id(self.obj, self.obj_type, context)
|
||||
element = tool.Ifc.get().by_id(ifc_definition_id)
|
||||
@@ -226,7 +226,7 @@ class AddQto(bpy.types.Operator, tool.Ifc.Operator):
|
||||
obj_type: bpy.props.StringProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
qto_name = tool.Pset.get_pset_name(self.obj, self.obj_type, pset_type="QTO")
|
||||
bpy.ops.bim.enable_pset_editing(
|
||||
pset_id=0, pset_name=qto_name, pset_type="QTO", obj=self.obj, obj_type=self.obj_type
|
||||
@@ -314,7 +314,7 @@ class BIM_OT_rename_parameters(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
props_to_map = context.scene.RenameProperties
|
||||
ifc_file = IfcStore.get_file()
|
||||
ifc_file = tool.Ifc.get()
|
||||
all_ifc_elements = ifc_file.by_type("IfcElement")
|
||||
|
||||
for ifc_element in all_ifc_elements:
|
||||
@@ -347,7 +347,7 @@ class BIM_OT_add_edit_custom_property(bpy.types.Operator, tool.Ifc.Operator):
|
||||
index: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
props = context.scene.AddEditProperties
|
||||
|
||||
for obj in tool.Blender.get_selected_objects():
|
||||
@@ -402,7 +402,7 @@ class BIM_OT_bulk_remove_psets(bpy.types.Operator, tool.Ifc.Operator):
|
||||
index: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
props = context.scene.DeletePsets
|
||||
|
||||
for obj in tool.Blender.get_selected_objects():
|
||||
|
||||
@@ -26,7 +26,6 @@ import bonsai.tool as tool
|
||||
from bonsai.bim.prop import Attribute, StrProperty
|
||||
from bonsai.bim.module.pset.data import AddEditCustomPropertiesData, ObjectPsetsData, MaterialPsetsData
|
||||
from bonsai.bim.module.material.data import ObjectMaterialData
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bpy.types import PropertyGroup
|
||||
from bpy.props import (
|
||||
PointerProperty,
|
||||
@@ -135,7 +134,7 @@ def get_resource_pset_names(self, context):
|
||||
global psetnames
|
||||
rprops = context.scene.BIMResourceProperties
|
||||
rtprops = context.scene.BIMResourceTreeProperties
|
||||
ifc_class = IfcStore.get_file().by_id(rtprops.resources[rprops.active_resource_index].ifc_definition_id).is_a()
|
||||
ifc_class = tool.Ifc.get().by_id(rtprops.resources[rprops.active_resource_index].ifc_definition_id).is_a()
|
||||
if ifc_class not in psetnames:
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True, schema=tool.Ifc.get_schema())
|
||||
psetnames[ifc_class] = blender_formatted_enum_from_psets(psets)
|
||||
@@ -146,7 +145,7 @@ def get_resource_qto_names(self, context):
|
||||
global qtonames
|
||||
rprops = context.scene.BIMResourceProperties
|
||||
rtprops = context.scene.BIMResourceTreeProperties
|
||||
ifc_class = IfcStore.get_file().by_id(rtprops.resources[rprops.active_resource_index].ifc_definition_id).is_a()
|
||||
ifc_class = tool.Ifc.get().by_id(rtprops.resources[rprops.active_resource_index].ifc_definition_id).is_a()
|
||||
if ifc_class not in qtonames:
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, qto_only=True, schema=tool.Ifc.get_schema())
|
||||
qtonames[ifc_class] = blender_formatted_enum_from_psets(psets)
|
||||
@@ -174,7 +173,7 @@ def get_group_qto_names(self, context):
|
||||
def get_profile_pset_names(self, context):
|
||||
global psetnames
|
||||
pprops = tool.Profile.get_profile_props()
|
||||
ifc_class = IfcStore.get_file().by_id(pprops.profiles[pprops.active_profile_index].ifc_definition_id).is_a()
|
||||
ifc_class = tool.Ifc.get().by_id(pprops.profiles[pprops.active_profile_index].ifc_definition_id).is_a()
|
||||
if ifc_class not in psetnames:
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True, schema=tool.Ifc.get_schema())
|
||||
psetnames[ifc_class] = blender_formatted_enum_from_psets(psets)
|
||||
@@ -290,7 +289,8 @@ class AddEditProperties(PropertyGroup):
|
||||
enum_values: CollectionProperty(name="Enum Values", type=Attribute)
|
||||
|
||||
def get_value_name(self) -> Union[Literal["string_value", "bool_value", "int_value", "float_value"], None]:
|
||||
ifc_data_type = IfcStore.get_schema().declaration_by_name(self.primary_measure_type)
|
||||
schema = tool.Ifc.schema()
|
||||
ifc_data_type = schema.declaration_by_name(self.primary_measure_type)
|
||||
data_type = ifcopenshell.util.attribute.get_primitive_type(ifc_data_type)
|
||||
if data_type == "string":
|
||||
return "string_value"
|
||||
|
||||
@@ -20,7 +20,6 @@ from __future__ import annotations
|
||||
import bpy
|
||||
import bonsai.tool as tool
|
||||
from bpy.types import Panel
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.helper import prop_with_search, get_display_value
|
||||
from bonsai.bim.module.pset.data import (
|
||||
ObjectPsetsData,
|
||||
@@ -247,7 +246,7 @@ class BIM_PT_object_psets(Panel):
|
||||
props = context.active_object.BIMObjectProperties
|
||||
if not props.ifc_definition_id:
|
||||
return False
|
||||
if not IfcStore.get_element(props.ifc_definition_id):
|
||||
if not tool.Ifc.get_object_by_identifier(props.ifc_definition_id):
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -325,7 +324,7 @@ class BIM_PT_object_qtos(Panel):
|
||||
props = context.active_object.BIMObjectProperties
|
||||
if not props.ifc_definition_id:
|
||||
return False
|
||||
if not IfcStore.get_element(props.ifc_definition_id):
|
||||
if not tool.Ifc.get_object_by_identifier(props.ifc_definition_id):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
@@ -183,7 +183,8 @@ class PropTemplate(PropertyGroup):
|
||||
def get_value_name(self) -> str:
|
||||
if self.primary_measure_type == "-":
|
||||
return "string_value"
|
||||
ifc_data_type = IfcStore.get_schema().declaration_by_name(self.primary_measure_type)
|
||||
schema = tool.Ifc.schema()
|
||||
ifc_data_type = schema.declaration_by_name(self.primary_measure_type)
|
||||
data_type = ifcopenshell.util.attribute.get_primitive_type(ifc_data_type)
|
||||
if data_type == "string":
|
||||
return "string_value"
|
||||
|
||||
@@ -21,7 +21,6 @@ import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import bonsai.tool as tool
|
||||
import bonsai.core.qto as core
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.qto import helper
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
import bpy
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.resource
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
import bonsai.tool as tool
|
||||
import bonsai.bim.module.pset.data
|
||||
import bonsai.bim.module.resource.data
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import bonsai.tool as tool
|
||||
import bonsai.bim.helper
|
||||
from bpy.types import Panel, UIList
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.resource.data import ResourceData
|
||||
from typing import Any
|
||||
|
||||
@@ -35,7 +35,7 @@ class BIM_PT_resources(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
return file and hasattr(file, "schema") and file.schema != "IFC2X3"
|
||||
|
||||
def draw(self, context):
|
||||
|
||||
@@ -57,8 +57,9 @@ class EnableReassignClass(bpy.types.Operator):
|
||||
"IfcAnnotation",
|
||||
"IfcRelSpaceBoundary",
|
||||
]
|
||||
schema = tool.Ifc.schema()
|
||||
for ifc_product in ifc_products:
|
||||
if ifcopenshell.util.schema.is_a(IfcStore.get_schema().declaration_by_name(ifc_class), ifc_product):
|
||||
if schema.declaration_by_name(ifc_class).is_a(ifc_product):
|
||||
context.scene.BIMRootProperties.ifc_product = ifc_product
|
||||
element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
|
||||
context.scene.BIMRootProperties.ifc_class = element.is_a()
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import bonsai.tool as tool
|
||||
import bonsai.bim.module.root.prop as root_prop
|
||||
from bpy.types import Panel
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.helper import prop_with_search
|
||||
from bonsai.bim.module.root.data import IfcClassData
|
||||
from bonsai.bim.module.model.data import AuthoringData
|
||||
@@ -38,7 +38,7 @@ class BIM_PT_class(Panel):
|
||||
def poll(cls, context):
|
||||
if not context.active_object:
|
||||
return False
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def draw(self, context):
|
||||
if not IfcClassData.is_loaded:
|
||||
|
||||
@@ -31,7 +31,6 @@ import ifcopenshell.util.sequence
|
||||
import ifcopenshell.util.selector
|
||||
from datetime import datetime
|
||||
from dateutil import parser, relativedelta
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bpy_extras.io_utils import ImportHelper
|
||||
from typing import get_args, TYPE_CHECKING
|
||||
from typing_extensions import assert_never
|
||||
@@ -700,7 +699,7 @@ class ImportP6(bpy.types.Operator, tool.Ifc.Operator, ImportHelper):
|
||||
def _execute(self, context):
|
||||
from ifc4d.p62ifc import P62Ifc
|
||||
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
start = time.time()
|
||||
p62ifc = P62Ifc()
|
||||
p62ifc.xml = self.filepath
|
||||
@@ -728,7 +727,7 @@ class ImportP6XER(bpy.types.Operator, tool.Ifc.Operator, ImportHelper):
|
||||
def _execute(self, context):
|
||||
from ifc4d.p6xer2ifc import P6XER2Ifc
|
||||
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
start = time.time()
|
||||
p6xer2ifc = P6XER2Ifc()
|
||||
p6xer2ifc.xer = self.filepath
|
||||
@@ -756,7 +755,7 @@ class ImportPP(bpy.types.Operator, tool.Ifc.Operator, ImportHelper):
|
||||
def _execute(self, context):
|
||||
from ifc4d.pp2ifc import PP2Ifc
|
||||
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
start = time.time()
|
||||
pp2ifc = PP2Ifc()
|
||||
pp2ifc.pp = self.filepath
|
||||
@@ -784,7 +783,7 @@ class ImportMSP(bpy.types.Operator, tool.Ifc.Operator, ImportHelper):
|
||||
def _execute(self, context):
|
||||
from ifc4d.msp2ifc import MSP2Ifc
|
||||
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
start = time.time()
|
||||
msp2ifc = MSP2Ifc()
|
||||
msp2ifc.xml = self.filepath
|
||||
@@ -814,7 +813,7 @@ class ExportMSP(bpy.types.Operator, ImportHelper):
|
||||
def execute(self, context):
|
||||
from ifc4d.ifc2msp import Ifc2Msp
|
||||
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
start = time.time()
|
||||
ifc2msp = Ifc2Msp()
|
||||
ifc2msp.work_schedule = self.file.by_type("IfcWorkSchedule")[0]
|
||||
@@ -847,7 +846,7 @@ class ExportP6(bpy.types.Operator, ImportHelper):
|
||||
def execute(self, context):
|
||||
from ifc4d.ifc2p6 import Ifc2P6
|
||||
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
start = time.time()
|
||||
ifc2p6 = Ifc2P6()
|
||||
ifc2p6.xml = bpy.path.ensure_ext(self.filepath, ".xml")
|
||||
|
||||
@@ -23,7 +23,6 @@ import ifcopenshell.util.attribute
|
||||
import ifcopenshell.util.date
|
||||
import bonsai.tool as tool
|
||||
import bonsai.core.sequence as core
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.sequence.data import SequenceData, AnimationColorSchemeData, refresh as refresh_sequence_data
|
||||
import bonsai.bim.module.resource.data
|
||||
import bonsai.bim.module.pset.data
|
||||
|
||||
@@ -22,7 +22,6 @@ import isodate
|
||||
import bonsai.tool as tool
|
||||
import bonsai.bim.helper
|
||||
from bpy.types import Panel, UIList
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.helper import draw_attributes
|
||||
from bonsai.bim.module.sequence.data import (
|
||||
WorkPlansData,
|
||||
@@ -45,7 +44,7 @@ class BIM_PT_status(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def draw(self, context):
|
||||
self.props = context.scene.BIMStatusProperties
|
||||
@@ -77,7 +76,7 @@ class BIM_PT_work_plans(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
return file and file.schema != "IFC2X3"
|
||||
|
||||
def draw(self, context):
|
||||
@@ -147,7 +146,7 @@ class BIM_PT_work_schedules(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
return file and hasattr(file, "schema") and file.schema != "IFC2X3"
|
||||
|
||||
def draw(self, context):
|
||||
@@ -592,7 +591,7 @@ class BIM_PT_animation_Color_Scheme(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
return file and hasattr(file, "schema") and file.schema != "IFC2X3"
|
||||
|
||||
def draw(self, context):
|
||||
@@ -980,7 +979,7 @@ class BIM_PT_work_calendars(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
return file and hasattr(file, "schema") and file.schema != "IFC2X3"
|
||||
|
||||
def draw(self, context):
|
||||
|
||||
@@ -26,7 +26,6 @@ import ifcopenshell.api
|
||||
import ifcopenshell.util.attribute
|
||||
import ifcopenshell.util.unit as ifcunit
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.structural.shader import DecorationShader
|
||||
from typing import Literal, TypedDict, Iterable
|
||||
|
||||
@@ -307,7 +306,7 @@ class ShaderInfo:
|
||||
|
||||
props = bpy.context.scene.BIMStructuralProperties
|
||||
group_definition_id = int(props.load_group_to_show)
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
groups = [file.by_id(group_definition_id)]
|
||||
recursive_subgroups(groups, 10, props.activity_type)
|
||||
|
||||
@@ -333,7 +332,7 @@ class ShaderInfo:
|
||||
orientation = np.eye(3)
|
||||
if reference_frame == "LOCAL_COORDS":
|
||||
orientation = rotation
|
||||
blender_object: bpy.types.Object = IfcStore.get_element(getattr(surf, "GlobalId", None))
|
||||
blender_object: bpy.types.Object = tool.Ifc.get_object_by_identifier(getattr(surf, "GlobalId", None))
|
||||
mat = blender_object.matrix_world
|
||||
mesh: bpy.types.Mesh = blender_object.data
|
||||
|
||||
@@ -454,7 +453,7 @@ class ShaderInfo:
|
||||
activity_list = value["activities"]
|
||||
if len(activity_list) == 0:
|
||||
continue
|
||||
blender_object = IfcStore.get_element(getattr(conn, "GlobalId", None))
|
||||
blender_object = tool.Ifc.get_object_by_identifier(getattr(conn, "GlobalId", None))
|
||||
if blender_object.type == "MESH":
|
||||
conn_location = blender_object.matrix_world @ blender_object.data.vertices[0].co
|
||||
rotation = self.get_point_connection_rotation(conn)
|
||||
@@ -580,7 +579,7 @@ class ShaderInfo:
|
||||
if len(activity_list) == 0:
|
||||
continue
|
||||
|
||||
blender_object = IfcStore.get_element(getattr(member, "GlobalId", None))
|
||||
blender_object = tool.Ifc.get_object_by_identifier(getattr(member, "GlobalId", None))
|
||||
|
||||
start_co = blender_object.matrix_world @ blender_object.data.vertices[0].co
|
||||
end_co = blender_object.matrix_world @ blender_object.data.vertices[1].co
|
||||
|
||||
@@ -20,13 +20,13 @@ import bpy
|
||||
import json
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.structural
|
||||
import ifcopenshell.util.attribute
|
||||
import bonsai.bim.helper
|
||||
import bonsai.core.structural as core
|
||||
import bonsai.tool as tool
|
||||
from math import degrees
|
||||
from mathutils import Vector, Matrix
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.structural.decorator import LoadsDecorator
|
||||
|
||||
|
||||
@@ -77,13 +77,12 @@ class AddStructuralMemberConnection(bpy.types.Operator, tool.Ifc.Operator):
|
||||
obj = context.active_object
|
||||
oprops = obj.BIMObjectProperties
|
||||
props = obj.BIMStructuralProperties
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
related_structural_connection = file.by_id(oprops.ifc_definition_id)
|
||||
relating_structural_member = file.by_id(props.relating_structural_member.BIMObjectProperties.ifc_definition_id)
|
||||
if not relating_structural_member.is_a("IfcStructuralMember"):
|
||||
return {"FINISHED"}
|
||||
ifcopenshell.api.run(
|
||||
"structural.add_structural_member_connection",
|
||||
ifcopenshell.api.structural.add_structural_member_connection(
|
||||
file,
|
||||
relating_structural_member=relating_structural_member,
|
||||
related_structural_connection=related_structural_connection,
|
||||
@@ -125,7 +124,7 @@ class RemoveStructuralConnectionCondition(bpy.types.Operator, tool.Ifc.Operator)
|
||||
connects_structural_member: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
relation = file.by_id(self.connects_structural_member)
|
||||
connection = relation.RelatedStructuralConnection
|
||||
ifcopenshell.api.run("structural.remove_structural_connection_condition", file, **{"relation": relation})
|
||||
@@ -139,7 +138,7 @@ class AddStructuralBoundaryCondition(bpy.types.Operator, tool.Ifc.Operator):
|
||||
connection: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
connection = file.by_id(self.connection)
|
||||
ifcopenshell.api.run("structural.add_structural_boundary_condition", file, **{"connection": connection})
|
||||
return {"FINISHED"}
|
||||
@@ -152,7 +151,7 @@ class RemoveStructuralBoundaryCondition(bpy.types.Operator, tool.Ifc.Operator):
|
||||
connection: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
connection = file.by_id(self.connection)
|
||||
ifcopenshell.api.run("structural.remove_structural_boundary_condition", file, **{"connection": connection})
|
||||
return {"FINISHED"}
|
||||
@@ -170,8 +169,9 @@ class EnableEditingStructuralBoundaryCondition(bpy.types.Operator):
|
||||
props.boundary_condition_attributes.clear()
|
||||
|
||||
condition = tool.Ifc.get().by_id(self.boundary_condition)
|
||||
schema = tool.Ifc.schema()
|
||||
|
||||
for attribute in IfcStore.get_schema().declaration_by_name(condition.is_a()).all_attributes():
|
||||
for attribute in schema.declaration_by_name(condition.is_a()).all_attributes():
|
||||
value = getattr(condition, attribute.name(), None)
|
||||
data_type = ifcopenshell.util.attribute.get_primitive_type(attribute)
|
||||
new = props.boundary_condition_attributes.add()
|
||||
@@ -207,7 +207,7 @@ class EditStructuralBoundaryCondition(bpy.types.Operator, tool.Ifc.Operator):
|
||||
obj = context.active_object
|
||||
props = obj.BIMStructuralProperties
|
||||
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
connection = file.by_id(self.connection)
|
||||
condition = connection.AppliedCondition
|
||||
|
||||
@@ -353,7 +353,7 @@ class EnableEditingStructuralItemAxis(bpy.types.Operator):
|
||||
oprops = obj.BIMObjectProperties
|
||||
props = obj.BIMStructuralProperties
|
||||
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
item = self.file.by_id(oprops.ifc_definition_id)
|
||||
z_axis = Vector(item.Axis.DirectionRatios).normalized() @ obj.matrix_world if item.Axis else None
|
||||
x_axis = (obj.data.vertices[1].co - obj.data.vertices[0].co).normalized()
|
||||
@@ -407,7 +407,7 @@ class EditStructuralItemAxis(bpy.types.Operator, tool.Ifc.Operator):
|
||||
props = obj.BIMStructuralProperties
|
||||
relative_matrix = props.axis_empty.matrix_world @ obj.matrix_world.inverted()
|
||||
z_axis = relative_matrix.col[2][0:3]
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"structural.edit_structural_item_axis",
|
||||
self.file,
|
||||
@@ -428,7 +428,7 @@ class EnableEditingStructuralConnectionCS(bpy.types.Operator):
|
||||
oprops = obj.BIMObjectProperties
|
||||
props = obj.BIMStructuralProperties
|
||||
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
item = self.file.by_id(oprops.ifc_definition_id)
|
||||
|
||||
location = obj.data.vertices[0].co
|
||||
@@ -496,7 +496,7 @@ class EditStructuralConnectionCS(bpy.types.Operator, tool.Ifc.Operator):
|
||||
relative_matrix = props.ccs_empty.matrix_world @ obj.matrix_world.inverted()
|
||||
x_axis = relative_matrix.col[0][0:3]
|
||||
z_axis = relative_matrix.col[2][0:3]
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"structural.edit_structural_connection_cs",
|
||||
self.file,
|
||||
@@ -515,7 +515,7 @@ class AssignStructuralLoadCase(bpy.types.Operator, tool.Ifc.Operator):
|
||||
load_case: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"aggregate.assign_object",
|
||||
self.file,
|
||||
@@ -534,7 +534,7 @@ class UnassignStructuralLoadCase(bpy.types.Operator, tool.Ifc.Operator):
|
||||
load_case: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"aggregate.unassign_object",
|
||||
self.file,
|
||||
@@ -552,7 +552,7 @@ class AddStructuralLoadCase(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def _execute(self, context):
|
||||
ifcopenshell.api.run("structural.add_structural_load_case", IfcStore.get_file())
|
||||
ifcopenshell.api.run("structural.add_structural_load_case", tool.Ifc.get())
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -564,7 +564,7 @@ class EditStructuralLoadCase(bpy.types.Operator, tool.Ifc.Operator):
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMStructuralProperties
|
||||
attributes = bonsai.bim.helper.export_attributes(props.load_case_attributes)
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"structural.edit_structural_load_case",
|
||||
self.file,
|
||||
@@ -581,7 +581,7 @@ class RemoveStructuralLoadCase(bpy.types.Operator, tool.Ifc.Operator):
|
||||
load_case: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"structural.remove_structural_load_case", self.file, load_case=self.file.by_id(self.load_case)
|
||||
)
|
||||
@@ -639,7 +639,7 @@ class AddStructuralLoadGroup(bpy.types.Operator, tool.Ifc.Operator):
|
||||
load_case: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
load_group = ifcopenshell.api.run("structural.add_structural_load_group", self.file)
|
||||
ifcopenshell.api.run(
|
||||
"group.assign_group", self.file, products=[load_group], group=self.file.by_id(self.load_case)
|
||||
@@ -654,7 +654,7 @@ class RemoveStructuralLoadGroup(bpy.types.Operator, tool.Ifc.Operator):
|
||||
load_group: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"structural.remove_structural_load_group", self.file, load_group=self.file.by_id(self.load_group)
|
||||
)
|
||||
@@ -668,7 +668,7 @@ class EnableEditingStructuralLoadGroupActivities(bpy.types.Operator):
|
||||
load_group: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
self.props = context.scene.BIMStructuralProperties
|
||||
self.props.active_load_group_id = self.load_group
|
||||
self.props.load_group_editing_type = "ACTIVITY"
|
||||
@@ -693,7 +693,7 @@ class AddStructuralActivity(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
self.props = context.scene.BIMStructuralProperties
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
for obj in context.selected_objects:
|
||||
if not obj.BIMObjectProperties.ifc_definition_id:
|
||||
continue
|
||||
@@ -741,7 +741,7 @@ class LoadStructuralLoads(bpy.types.Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
props = context.scene.BIMStructuralProperties
|
||||
props.structural_loads.clear()
|
||||
loads = tool.Ifc.get().by_type("IfcStructuralLoad")
|
||||
@@ -787,7 +787,7 @@ class AddStructuralLoad(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
result = ifcopenshell.api.run(
|
||||
"structural.add_structural_load", IfcStore.get_file(), name="New Load", ifc_class=self.ifc_class
|
||||
"structural.add_structural_load", tool.Ifc.get(), name="New Load", ifc_class=self.ifc_class
|
||||
)
|
||||
bpy.ops.bim.load_structural_loads()
|
||||
bpy.ops.bim.enable_editing_structural_load(structural_load=result.id())
|
||||
@@ -828,7 +828,7 @@ class RemoveStructuralLoad(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMStructuralProperties
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"structural.remove_structural_load",
|
||||
self.file,
|
||||
@@ -846,7 +846,7 @@ class EditStructuralLoad(bpy.types.Operator, tool.Ifc.Operator):
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMStructuralProperties
|
||||
attributes = bonsai.bim.helper.export_attributes(props.structural_load_attributes)
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"structural.edit_structural_load",
|
||||
self.file,
|
||||
@@ -877,7 +877,7 @@ class LoadBoundaryConditions(bpy.types.Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
props = context.scene.BIMStructuralProperties
|
||||
props.boundary_conditions.clear()
|
||||
conditions = tool.Ifc.get().by_type("IfcBoundaryCondition")
|
||||
@@ -936,7 +936,7 @@ class AddBoundaryCondition(bpy.types.Operator, tool.Ifc.Operator):
|
||||
def _execute(self, context):
|
||||
result = ifcopenshell.api.run(
|
||||
"structural.add_structural_boundary_condition",
|
||||
IfcStore.get_file(),
|
||||
tool.Ifc.get(),
|
||||
name="New Load",
|
||||
ifc_class=self.ifc_class,
|
||||
)
|
||||
@@ -957,7 +957,8 @@ class EnableEditingBoundaryCondition(bpy.types.Operator):
|
||||
|
||||
boundary_condition = tool.Ifc.get().by_id(self.boundary_condition)
|
||||
# bonsai.bim.helper.import_attributes(data["type"], props.boundary_condition_attributes, data)
|
||||
for attribute in IfcStore.get_schema().declaration_by_name(boundary_condition.is_a()).all_attributes():
|
||||
schema = tool.Ifc.schema()
|
||||
for attribute in schema.declaration_by_name(boundary_condition.is_a()).all_attributes():
|
||||
value = getattr(boundary_condition, attribute.name(), None)
|
||||
data_type = ifcopenshell.util.attribute.get_primitive_type(attribute)
|
||||
new = props.boundary_condition_attributes.add()
|
||||
@@ -1000,7 +1001,7 @@ class RemoveBoundaryCondition(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMStructuralProperties
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
ifcopenshell.api.run(
|
||||
"structural.remove_structural_boundary_condition",
|
||||
self.file,
|
||||
@@ -1017,7 +1018,7 @@ class EditBoundaryCondition(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMStructuralProperties
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
# attributes = bonsai.bim.helper.export_attributes(props.boundary_condition_attributes)
|
||||
attributes = {}
|
||||
for attribute in props.boundary_condition_attributes:
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
from math import radians
|
||||
import bpy
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.prop import StrProperty, Attribute
|
||||
from bonsai.bim.module.structural.data import (
|
||||
StructuralLoadCasesData,
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import bonsai.tool as tool
|
||||
import bonsai.bim.helper
|
||||
from bpy.types import Panel, UIList
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.helper import draw_attributes, prop_with_search
|
||||
from bonsai.bim.module.structural.data import (
|
||||
StructuralBoundaryConditionsData,
|
||||
@@ -90,9 +90,9 @@ class BIM_PT_structural_boundary_conditions(Panel):
|
||||
props = context.active_object.BIMObjectProperties
|
||||
if not props.ifc_definition_id:
|
||||
return False
|
||||
if not IfcStore.get_element(props.ifc_definition_id):
|
||||
if not tool.Ifc.get_object_by_identifier(props.ifc_definition_id):
|
||||
return False
|
||||
if not IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcStructuralConnection"):
|
||||
if not tool.Ifc.get().by_id(props.ifc_definition_id).is_a("IfcStructuralConnection"):
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -125,9 +125,9 @@ class BIM_PT_connected_structural_members(Panel):
|
||||
props = context.active_object.BIMObjectProperties
|
||||
if not props.ifc_definition_id:
|
||||
return False
|
||||
if not IfcStore.get_element(props.ifc_definition_id):
|
||||
if not tool.Ifc.get_object_by_identifier(props.ifc_definition_id):
|
||||
return False
|
||||
if not IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcStructuralConnection"):
|
||||
if not tool.Ifc.get().by_id(props.ifc_definition_id).is_a("IfcStructuralConnection"):
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -178,9 +178,9 @@ class BIM_PT_structural_member(Panel):
|
||||
props = context.active_object.BIMObjectProperties
|
||||
if not props.ifc_definition_id:
|
||||
return False
|
||||
if not IfcStore.get_element(props.ifc_definition_id):
|
||||
if not tool.Ifc.get_object_by_identifier(props.ifc_definition_id):
|
||||
return False
|
||||
if not IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcStructuralMember"):
|
||||
if not tool.Ifc.get().by_id(props.ifc_definition_id).is_a("IfcStructuralMember"):
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -221,9 +221,9 @@ class BIM_PT_structural_connection(Panel):
|
||||
props = context.active_object.BIMObjectProperties
|
||||
if not props.ifc_definition_id:
|
||||
return False
|
||||
if not IfcStore.get_element(props.ifc_definition_id):
|
||||
if not tool.Ifc.get_object_by_identifier(props.ifc_definition_id):
|
||||
return False
|
||||
if not IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcStructuralConnection"):
|
||||
if not tool.Ifc.get().by_id(props.ifc_definition_id).is_a("IfcStructuralConnection"):
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -274,7 +274,7 @@ class BIM_PT_structural_analysis_models(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
return file and hasattr(file, "schema") and file.schema != "IFC2X3"
|
||||
|
||||
def draw(self, context):
|
||||
@@ -348,7 +348,7 @@ class BIM_PT_structural_load_cases(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
return file and hasattr(file, "schema") and file.schema != "IFC2X3"
|
||||
|
||||
def draw(self, context):
|
||||
@@ -443,7 +443,7 @@ class BIM_PT_show_structural_activities(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
return file and hasattr(file, "schema") and file.schema != "IFC2X3"
|
||||
|
||||
def draw(self, context):
|
||||
@@ -474,7 +474,7 @@ class BIM_PT_structural_loads(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
return file and hasattr(file, "schema") and file.schema != "IFC2X3"
|
||||
|
||||
def draw(self, context):
|
||||
@@ -543,7 +543,7 @@ class BIM_PT_boundary_conditions(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
return file and hasattr(file, "schema") and file.schema != "IFC2X3"
|
||||
|
||||
def draw(self, context):
|
||||
|
||||
@@ -20,9 +20,7 @@ import bpy
|
||||
import bonsai.bim.helper
|
||||
import bonsai.tool as tool
|
||||
from bpy.types import Panel, UIList
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.style.data import StylesData, BlenderMaterialStyleData
|
||||
from typing import Union
|
||||
|
||||
|
||||
class BIM_PT_styles(Panel):
|
||||
@@ -36,7 +34,7 @@ class BIM_PT_styles(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file()
|
||||
return tool.Ifc.get()
|
||||
|
||||
def draw(self, context):
|
||||
if not StylesData.is_loaded:
|
||||
|
||||
@@ -21,9 +21,7 @@ import ifcopenshell.api
|
||||
import bonsai.tool as tool
|
||||
import bonsai.core.system as core
|
||||
import bonsai.bim.helper
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.system.data import PortData
|
||||
from mathutils import Matrix
|
||||
|
||||
|
||||
class LoadSystems(bpy.types.Operator):
|
||||
|
||||
@@ -29,7 +29,6 @@ import bonsai.tool as tool
|
||||
import bonsai.core.geometry
|
||||
import bonsai.core.type as core
|
||||
import bonsai.core.root
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
|
||||
|
||||
class AssignType(bpy.types.Operator, tool.Ifc.Operator):
|
||||
@@ -66,7 +65,7 @@ class UnassignType(bpy.types.Operator, tool.Ifc.Operator):
|
||||
def exclude_callback(attribute):
|
||||
return attribute.is_a("IfcProfileDef") and attribute.ProfileName
|
||||
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
objs = [bpy.data.objects.get(self.related_object)] if self.related_object else context.selected_objects
|
||||
for obj in objs:
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
@@ -187,7 +186,7 @@ class SelectSimilarType(bpy.types.Operator):
|
||||
related_object: bpy.props.StringProperty()
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
objects = bpy.context.selected_objects
|
||||
|
||||
# store relating types to avoid selecting same elements multiple times
|
||||
@@ -229,7 +228,7 @@ class SelectTypeObjects(bpy.types.Operator):
|
||||
relating_type: bpy.props.StringProperty()
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
relating_type = bpy.data.objects.get(self.relating_type) if self.relating_type else context.active_object
|
||||
at_least_one_selectable_typed_object = False
|
||||
for element in ifcopenshell.util.element.get_types(tool.Ifc.get_entity(relating_type)):
|
||||
|
||||
@@ -20,8 +20,6 @@ import bpy
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.type
|
||||
from bonsai.bim.module.type.data import TypeData
|
||||
from bonsai.bim.prop import StrProperty, Attribute
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
import bonsai.tool as tool
|
||||
from bpy.types import PropertyGroup
|
||||
from bpy.props import (
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
import bonsai.tool as tool
|
||||
import bonsai.bim.module.type.prop as type_prop
|
||||
from bpy.types import Panel
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.helper import prop_with_search
|
||||
from bonsai.bim.module.type.data import TypeData
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.prop import StrProperty, Attribute
|
||||
from bonsai.bim.module.unit.data import UnitsData
|
||||
from bpy.types import PropertyGroup
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bonsai.bim.helper
|
||||
import bonsai.tool as tool
|
||||
from bpy.types import Panel, UIList
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.helper import prop_with_search
|
||||
from bonsai.bim.module.unit.data import UnitsData
|
||||
|
||||
@@ -34,7 +34,7 @@ class BIM_PT_units(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
file = IfcStore.get_file()
|
||||
file = tool.Ifc.get()
|
||||
return file
|
||||
|
||||
def draw(self, context):
|
||||
|
||||
@@ -24,7 +24,6 @@ import bonsai.tool as tool
|
||||
import bonsai.core.geometry
|
||||
import bonsai.core.root
|
||||
import bonsai.bim.handler
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.model.opening import FilledOpeningGenerator
|
||||
|
||||
|
||||
@@ -98,7 +97,7 @@ class AddOpening(bpy.types.Operator, tool.Ifc.Operator):
|
||||
break
|
||||
|
||||
element_had_openings = tool.Geometry.has_openings(voided_element)
|
||||
body_context = ifcopenshell.util.representation.get_context(IfcStore.get_file(), "Model", "Body")
|
||||
body_context = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Body")
|
||||
if not element2:
|
||||
element2 = bonsai.core.root.assign_class(
|
||||
tool.Ifc,
|
||||
@@ -215,7 +214,7 @@ class AddFilling(bpy.types.Operator, tool.Ifc.Operator):
|
||||
opening = context.scene.objects.get(self.opening, context.scene.VoidProperties.desired_opening)
|
||||
if opening is None:
|
||||
return {"FINISHED"}
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
element_id = obj.BIMObjectProperties.ifc_definition_id
|
||||
opening_id = opening.BIMObjectProperties.ifc_definition_id
|
||||
if not element_id or not opening_id or element_id == opening_id:
|
||||
|
||||
@@ -129,9 +129,13 @@ class Ifc(bonsai.core.tool.Ifc):
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def get_object(cls, element: ifcopenshell.entity_instance) -> IFC_CONNECTED_TYPE:
|
||||
def get_object(cls, element: ifcopenshell.entity_instance) -> Union[IFC_CONNECTED_TYPE, None]:
|
||||
return IfcStore.get_element(element.id())
|
||||
|
||||
@classmethod
|
||||
def get_object_by_identifier(cls, id_or_guid: Union[int, str]) -> Union[IFC_CONNECTED_TYPE, None]:
|
||||
return IfcStore.get_element(id_or_guid)
|
||||
|
||||
@classmethod
|
||||
def rebuild_element_maps(cls) -> None:
|
||||
"""Rebuilds the id_map and guid_map
|
||||
|
||||
@@ -23,8 +23,6 @@ import json
|
||||
import bonsai.bim.helper
|
||||
import bonsai.core.tool
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from pprint import pprint
|
||||
from typing import Union, Any
|
||||
|
||||
|
||||
@@ -129,7 +127,8 @@ class Structural(bonsai.core.tool.Structural):
|
||||
def load_structural_analysis_model_attributes(cls, data: dict[str, Any]) -> None:
|
||||
props = bpy.context.scene.BIMStructuralProperties
|
||||
props.structural_analysis_model_attributes.clear()
|
||||
for attribute in IfcStore.get_schema().declaration_by_name("IfcStructuralAnalysisModel").all_attributes():
|
||||
schema = tool.Ifc.schema()
|
||||
for attribute in schema.declaration_by_name("IfcStructuralAnalysisModel").all_attributes():
|
||||
data_type = str(attribute.type_of_attribute)
|
||||
if "<entity" in data_type:
|
||||
continue
|
||||
|
||||
@@ -62,7 +62,7 @@ Instead, stuff happens in Blender operators.
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
ifcopenshell.api.run("foo.bar", IfcStore.get_file())
|
||||
ifcopenshell.api.run("foo.bar", tool.Ifc.get())
|
||||
return {"FINISHED"}
|
||||
|
||||
When your operator manipulates (creates, removes, or edits) IFC data directly or
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import bpy
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
|
||||
# When federating, you may wish to manually specify the origin to ensure models
|
||||
# with different or arbitrary origin conventions will turn up in the right spot.
|
||||
|
||||
@@ -174,14 +174,14 @@ def the_object_name_exists(name):
|
||||
|
||||
|
||||
def an_ifc_file_exists():
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
if not ifc:
|
||||
assert False, "No IFC file is available"
|
||||
return ifc
|
||||
|
||||
|
||||
def an_ifc_file_does_not_exist():
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
if ifc:
|
||||
assert False, "An IFC is available"
|
||||
|
||||
@@ -283,7 +283,7 @@ def the_object_name1_has_no_boolean_difference_by_name2(name1, name2):
|
||||
|
||||
|
||||
def the_object_name_is_voided_by_void(name, void):
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
||||
for rel in element.HasOpenings:
|
||||
if rel.RelatedOpeningElement.Name == void:
|
||||
@@ -292,7 +292,7 @@ def the_object_name_is_voided_by_void(name, void):
|
||||
|
||||
|
||||
def the_object_name_is_not_voided_by_void(name, void):
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
||||
for rel in element.HasOpenings:
|
||||
if rel.RelatedOpeningElement.Name == void:
|
||||
@@ -300,21 +300,21 @@ def the_object_name_is_not_voided_by_void(name, void):
|
||||
|
||||
|
||||
def the_object_name_is_not_voided(name):
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
||||
if any(element.HasOpenings):
|
||||
assert False, "An opening was found"
|
||||
|
||||
|
||||
def the_object_name_is_not_a_void(name):
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
||||
if any(element.VoidsElements):
|
||||
assert False, "A void was found"
|
||||
|
||||
|
||||
def the_void_name_is_filled_by_filling(name, filling):
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
||||
if any(rel.RelatedBuildingElement.Name == filling for rel in element.HasFillings):
|
||||
return True
|
||||
@@ -322,14 +322,14 @@ def the_void_name_is_filled_by_filling(name, filling):
|
||||
|
||||
|
||||
def the_void_name_is_not_filled_by_filling(name, filling):
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
||||
if any(rel.RelatedBuildingElement.Name == filling for rel in element.HasFillings):
|
||||
assert False, "A filling was found"
|
||||
|
||||
|
||||
def the_object_name_is_not_a_filling(name):
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
||||
if any(element.FillsVoids):
|
||||
assert False, "A filling was found"
|
||||
|
||||
@@ -786,14 +786,14 @@ def the_ifc_material_name_does_not_exist(name):
|
||||
|
||||
@then("an IFC file does not exist")
|
||||
def an_ifc_file_does_not_exist():
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
if ifc:
|
||||
assert False, "An IFC is available"
|
||||
|
||||
|
||||
@then("an IFC file exists")
|
||||
def an_ifc_file_exists():
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
if not ifc:
|
||||
assert False, "No IFC file is available"
|
||||
return ifc
|
||||
@@ -807,7 +807,7 @@ def the_object_name_should_display_as_mode(name, mode):
|
||||
|
||||
@then(parsers.parse('the object "{name}" is voided by "{void}"'))
|
||||
def the_object_name_is_voided_by_void(name, void):
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
||||
assert any((rel for rel in element.HasOpenings if rel.RelatedOpeningElement.Name == void)), "No void found"
|
||||
|
||||
@@ -823,14 +823,14 @@ def the_object_name_is_not_voided_by_void(name, void):
|
||||
|
||||
@then(parsers.parse('the object "{name}" is not voided'))
|
||||
def the_object_name_is_not_voided(name):
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
||||
assert not element.HasOpenings, "A void was found"
|
||||
|
||||
|
||||
@then(parsers.parse('the object "{name}" is a void'))
|
||||
def the_object_name_is_a_void(name):
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
obj = the_object_name_exists(name)
|
||||
element = ifc.by_id(obj.BIMObjectProperties.ifc_definition_id)
|
||||
assert any((element.VoidsElements)), "No void was found"
|
||||
@@ -936,7 +936,7 @@ def the_object_name_has_number_vertices(name, number):
|
||||
|
||||
@then(parsers.parse('the void "{name}" is filled by "{filling}"'))
|
||||
def the_void_name_is_filled_by_filling(name, filling):
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
||||
assert any((rel.RelatedBuildingElement.Name == filling for rel in element.HasFillings)), "No filling found"
|
||||
|
||||
@@ -953,7 +953,7 @@ def the_void_name_is_not_filled_by_filling(name, filling):
|
||||
@when(parsers.parse('the object "{name}" is not a filling'))
|
||||
@then(parsers.parse('the object "{name}" is not a filling'))
|
||||
def the_object_name_is_not_a_filling(name):
|
||||
ifc = IfcStore.get_file()
|
||||
ifc = tool.Ifc.get()
|
||||
element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
||||
assert not any(element.FillsVoids), "A filling was found"
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import bonsai.core.tool
|
||||
import bonsai.tool as tool
|
||||
from test.bim.bootstrap import NewFile
|
||||
from bonsai.tool.drawing import Drawing as subject
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.drawing.data import DecoratorData
|
||||
from mathutils import Vector
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import test.bim.bootstrap
|
||||
import bonsai.core.tool
|
||||
import bonsai.tool as tool
|
||||
from bonsai.tool.misc import Misc as subject
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
|
||||
|
||||
class TestImplementsTool(test.bim.bootstrap.NewFile):
|
||||
|
||||
@@ -71,7 +71,6 @@ class Patcher:
|
||||
import bonsai.tool as tool
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from mathutils import Vector, Matrix
|
||||
|
||||
if len(bpy.data.objects) > 0:
|
||||
@@ -114,8 +113,8 @@ class Patcher:
|
||||
bpy.ops.bim.update_representation(
|
||||
ifc_representation_class="IfcExtrudedAreaSolid/IfcArbitraryProfileDefWithVoids"
|
||||
)
|
||||
for context in IfcStore.get_file().by_type("IfcGeometricRepresentationContext", include_subtypes=False):
|
||||
for context in tool.Ifc.get().by_type("IfcGeometricRepresentationContext", include_subtypes=False):
|
||||
if context.Precision:
|
||||
context.Precision = 10
|
||||
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
|
||||
Reference in New Issue
Block a user