Renaming constr_class back to ifc_class

This commit is contained in:
Carlos Villagrasa
2022-07-27 08:11:52 +02:00
parent 7a6005d0ea
commit 79453a6ae0
7 changed files with 145 additions and 145 deletions
@@ -40,14 +40,14 @@ class AuthoringData:
if not hasattr(cls, "data"): if not hasattr(cls, "data"):
cls.data = {} cls.data = {}
cls.props = bpy.context.scene.BIMModelProperties cls.props = bpy.context.scene.BIMModelProperties
cls.load_constr_classes() cls.load_ifc_classes()
cls.load_constr_types() cls.load_constr_types()
cls.load_constr_types_browser() cls.load_constr_types_browser()
cls.load_preview_constr_types() cls.load_preview_constr_types()
@classmethod @classmethod
def load_constr_classes(cls): def load_ifc_classes(cls):
cls.data["constr_classes"] = cls.constr_classes() cls.data["ifc_classes"] = cls.ifc_classes()
@classmethod @classmethod
def load_constr_types(cls): def load_constr_types(cls):
@@ -62,7 +62,7 @@ class AuthoringData:
cls.data["preview_constr_types"] = preview_icon_ids cls.data["preview_constr_types"] = preview_icon_ids
@classmethod @classmethod
def constr_classes(cls): def ifc_classes(cls):
results = [] results = []
classes = { classes = {
e.is_a() e.is_a()
@@ -74,63 +74,63 @@ class AuthoringData:
return results return results
@classmethod @classmethod
def constr_class_entities(cls, constr_class=None): def constr_class_entities(cls, ifc_class=None):
constr_classes = cls.data["constr_classes"] ifc_classes = cls.data["ifc_classes"]
if not constr_classes: if not ifc_classes:
return [] return []
results = [] results = []
if constr_class is None: if ifc_class is None:
constr_class = cls.props.constr_class ifc_class = cls.props.ifc_class
if not constr_class and constr_classes: if not ifc_class and ifc_classes:
constr_class = constr_classes[0][0] ifc_class = ifc_classes[0][0]
if constr_class: if ifc_class:
elements = sorted(tool.Ifc.get().by_type(constr_class), key=lambda s: s.Name) elements = sorted(tool.Ifc.get().by_type(ifc_class), key=lambda s: s.Name)
results.extend(elements) results.extend(elements)
return results return results
return [] return []
@classmethod @classmethod
def constr_types(cls, constr_class=None): def constr_types(cls, ifc_class=None):
return [ return [
(str(e.id()), e.Name, e.Description or "") for e in cls.constr_class_entities(constr_class=constr_class) (str(e.id()), e.Name, e.Description or "") for e in cls.constr_class_entities(ifc_class=ifc_class)
] ]
@classmethod @classmethod
def constr_types_browser(cls): def constr_types_browser(cls):
return cls.constr_types(constr_class=cls.props.constr_class_browser) return cls.constr_types(ifc_class=cls.props.ifc_class_browser)
@staticmethod @staticmethod
def new_constr_type_info(constr_class): def new_constr_type_info(ifc_class):
constr_type_info = bpy.context.scene.ConstrTypeInfo.add() constr_type_info = bpy.context.scene.ConstrTypeInfo.add()
constr_type_info.name = constr_class constr_type_info.name = ifc_class
return constr_type_info return constr_type_info
@classmethod @classmethod
def assetize_constr_class(cls, constr_class=None): def assetize_constr_class(cls, ifc_class=None):
if constr_class is None: if ifc_class is None:
constr_class = cls.props.constr_class ifc_class = cls.props.ifc_class
constr_type_info = cls.constr_type_info(constr_class) constr_type_info = cls.constr_type_info(ifc_class)
_ = cls.new_constr_type_info(constr_class) if constr_type_info is None else constr_type_info _ = cls.new_constr_type_info(ifc_class) if constr_type_info is None else constr_type_info
constr_class_occurrences = cls.constr_class_entities(constr_class) constr_class_occurrences = cls.constr_class_entities(ifc_class)
preview_constr_types = cls.data["preview_constr_types"] preview_constr_types = cls.data["preview_constr_types"]
for constr_class_entity in constr_class_occurrences: for constr_class_entity in constr_class_occurrences:
### handle asset regeneration when library entity is updated ¿? ### handle asset regeneration when library entity is updated ¿?
if (constr_class not in preview_constr_types if (ifc_class not in preview_constr_types
or str(constr_class_entity.id()) not in preview_constr_types[constr_class]): or str(constr_class_entity.id()) not in preview_constr_types[ifc_class]):
obj = tool.Ifc.get_object(constr_class_entity) obj = tool.Ifc.get_object(constr_class_entity)
cls.assetize_object(obj, constr_class, constr_class_entity) cls.assetize_object(obj, ifc_class, constr_class_entity)
constr_type_info = cls.constr_type_info(constr_class) constr_type_info = cls.constr_type_info(ifc_class)
constr_type_info.fully_loaded = True constr_type_info.fully_loaded = True
@classmethod @classmethod
def assetize_object(cls, obj, constr_class, constr_class_entity, from_selection=False): def assetize_object(cls, obj, ifc_class, ifc_class_entity, from_selection=False):
constr_type_id = constr_class_entity.id() constr_type_id = ifc_class_entity.id()
to_be_deleted = False to_be_deleted = False
if obj.type == 'EMPTY': if obj.type == 'EMPTY':
kwargs = {} kwargs = {}
if not from_selection: if not from_selection:
kwargs.update({'constr_class': constr_class, 'constr_type_id': constr_type_id}) kwargs.update({'ifc_class': ifc_class, 'constr_type_id': constr_type_id})
new_obj = cls.new_constr_type(**kwargs) new_obj = cls.new_constr_type(**kwargs)
if new_obj is not None: if new_obj is not None:
to_be_deleted = True to_be_deleted = True
@@ -138,18 +138,18 @@ class AuthoringData:
obj.asset_mark() obj.asset_mark()
obj.asset_generate_preview() obj.asset_generate_preview()
icon_id = obj.preview.icon_id icon_id = obj.preview.icon_id
if constr_class not in cls.data["preview_constr_types"]: if ifc_class not in cls.data["preview_constr_types"]:
cls.data["preview_constr_types"][constr_class] = {} cls.data["preview_constr_types"][ifc_class] = {}
cls.data["preview_constr_types"][constr_class][str(constr_type_id)] = {"icon_id": icon_id, "object": obj} cls.data["preview_constr_types"][ifc_class][str(constr_type_id)] = {"icon_id": icon_id, "object": obj}
if to_be_deleted: if to_be_deleted:
for col in obj.users_collection: for col in obj.users_collection:
col.objects.unlink(obj) col.objects.unlink(obj)
@classmethod @classmethod
def assetize_constr_type_from_selection(cls): def assetize_constr_type_from_selection(cls):
constr_class_browser = cls.props.constr_class_browser ifc_class_browser = cls.props.ifc_class_browser
constr_type_id_browser = cls.props.constr_type_id_browser constr_type_id_browser = cls.props.constr_type_id_browser
constr_class_occurrences = cls.constr_class_entities(constr_class=constr_class_browser) constr_class_occurrences = cls.constr_class_entities(ifc_class=ifc_class_browser)
constr_class_occurrences = [ constr_class_occurrences = [
entity for entity in constr_class_occurrences if entity.id() == int(constr_type_id_browser) entity for entity in constr_class_occurrences if entity.id() == int(constr_type_id_browser)
] ]
@@ -159,46 +159,46 @@ class AuthoringData:
obj = tool.Ifc.get_object(constr_class_entity) obj = tool.Ifc.get_object(constr_class_entity)
if obj is None: if obj is None:
return False return False
cls.assetize_object(obj, constr_class_browser, constr_class_entity, from_selection=True) cls.assetize_object(obj, ifc_class_browser, constr_class_entity, from_selection=True)
return True return True
@staticmethod @staticmethod
def constr_type_info(constr_class): def constr_type_info(ifc_class):
constr_type_infos = [element for element in bpy.context.scene.ConstrTypeInfo if element.name == constr_class] constr_type_infos = [element for element in bpy.context.scene.ConstrTypeInfo if element.name == ifc_class]
return None if len(constr_type_infos) == 0 else constr_type_infos[0] return None if len(constr_type_infos) == 0 else constr_type_infos[0]
@classmethod @classmethod
def new_constr_type(cls, constr_class=None, constr_type_id=None): def new_constr_type(cls, ifc_class=None, constr_type_id=None):
if constr_class is None: if ifc_class is None:
bpy.ops.bim.add_constr_type( bpy.ops.bim.add_constr_type(
constr_class=cls.props.constr_class_browser, constr_type_id=int(cls.props.constr_type_id_browser) ifc_class=cls.props.ifc_class_browser, constr_type_id=int(cls.props.constr_type_id_browser)
) )
else: else:
cls.props.constr_class = constr_class cls.props.ifc_class = ifc_class
cls.props.constr_type_id = str(constr_type_id) cls.props.constr_type_id = str(constr_type_id)
bpy.ops.bim.add_constr_type() bpy.ops.bim.add_constr_type()
return bpy.context.selected_objects[-1] return bpy.context.selected_objects[-1]
@staticmethod @staticmethod
def constr_type_name_by_id(constr_class, constr_type_id): def constr_type_name_by_id(ifc_class, constr_type_id):
file = IfcStore.get_file() file = IfcStore.get_file()
try: try:
constr_class_entity = file.by_id(int(constr_type_id)) constr_class_entity = file.by_id(int(constr_type_id))
except (RuntimeError, ValueError): except (RuntimeError, ValueError):
return None return None
return constr_class_entity.Name if constr_class_entity.is_a() == constr_class else None return constr_class_entity.Name if constr_class_entity.is_a() == ifc_class else None
@classmethod @classmethod
def constr_type_id_by_name(cls, constr_class, constr_type): def constr_type_id_by_name(cls, ifc_class, constr_type):
constr_types = [ct[0] for ct in cls.constr_types(constr_class=constr_class) if ct[1] == constr_type] constr_types = [ct[0] for ct in cls.constr_types(ifc_class=ifc_class) if ct[1] == constr_type]
return None if len(constr_types) == 0 else constr_types[0] return None if len(constr_types) == 0 else constr_types[0]
@classmethod @classmethod
def consolidate_constr_type(cls): def consolidate_constr_type(cls):
cls.props.constr_class = cls.props.constr_class_browser cls.props.ifc_class = cls.props.ifc_class_browser
cls.props.constr_type_id = cls.props.constr_type_id_browser cls.props.constr_type_id = cls.props.constr_type_id_browser
@classmethod @classmethod
def setup_constr_type_browser(cls): def setup_constr_type_browser(cls):
cls.props.constr_class_browser = cls.props.constr_class cls.props.ifc_class_browser = cls.props.ifc_class
cls.props.constr_type_id_browser = cls.props.constr_type_id cls.props.constr_type_id_browser = cls.props.constr_type_id
@@ -62,7 +62,7 @@ class AddConstrType(bpy.types.Operator):
bl_label = "Add" bl_label = "Add"
bl_options = {"REGISTER", "UNDO"} bl_options = {"REGISTER", "UNDO"}
bl_description = "Add Type Instance to the model" bl_description = "Add Type Instance to the model"
constr_class: bpy.props.StringProperty() ifc_class: bpy.props.StringProperty()
constr_type_id: bpy.props.IntProperty() constr_type_id: bpy.props.IntProperty()
from_invoke: bpy.props.BoolProperty(default=False) from_invoke: bpy.props.BoolProperty(default=False)
@@ -76,18 +76,18 @@ class AddConstrType(bpy.types.Operator):
def _execute(self, context): def _execute(self, context):
props = context.scene.BIMModelProperties props = context.scene.BIMModelProperties
constr_class = self.constr_class or props.constr_class ifc_class = self.ifc_class or props.ifc_class
constr_type_id = self.constr_type_id or props.constr_type_id constr_type_id = self.constr_type_id or props.constr_type_id
if not constr_class or not constr_type_id: if not ifc_class or not constr_type_id:
return {"FINISHED"} return {"FINISHED"}
if self.from_invoke: if self.from_invoke:
props.constr_class = self.constr_class props.ifc_class = self.ifc_class
props.constr_type_id = str(self.constr_type_id) props.constr_type_id = str(self.constr_type_id)
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
instance_class = ifcopenshell.util.type.get_applicable_entities(constr_class, self.file.schema)[0] instance_class = ifcopenshell.util.type.get_applicable_entities(ifc_class, self.file.schema)[0]
constr_type = self.file.by_id(int(constr_type_id)) constr_type = self.file.by_id(int(constr_type_id))
material = ifcopenshell.util.element.get_material(constr_type) material = ifcopenshell.util.element.get_material(constr_type)
@@ -95,7 +95,7 @@ class AddConstrType(bpy.types.Operator):
if profile.DumbProfileGenerator(constr_type).generate(): if profile.DumbProfileGenerator(constr_type).generate():
return {"FINISHED"} return {"FINISHED"}
elif material and material.is_a("IfcMaterialLayerSet"): elif material and material.is_a("IfcMaterialLayerSet"):
if self.generate_layered_element(constr_class, constr_type): if self.generate_layered_element(ifc_class, constr_type):
return {"FINISHED"} return {"FINISHED"}
if constr_type.is_a("IfcFlowSegmentType") and not constr_type.RepresentationMaps: if constr_type.is_a("IfcFlowSegmentType") and not constr_type.RepresentationMaps:
if mep.MepGenerator(constr_type).generate(): if mep.MepGenerator(constr_type).generate():
@@ -202,10 +202,10 @@ class DisplayConstrTypes(bpy.types.Operator):
AuthoringData.setup_constr_type_browser() AuthoringData.setup_constr_type_browser()
props = context.scene.BIMModelProperties props = context.scene.BIMModelProperties
if props.unfold_constr_types: if props.unfold_constr_types:
constr_class = props.constr_class_browser ifc_class = props.ifc_class_browser
constr_type_info = AuthoringData.constr_type_info(constr_class) constr_type_info = AuthoringData.constr_type_info(ifc_class)
if constr_type_info is None or not constr_type_info.fully_loaded: if constr_type_info is None or not constr_type_info.fully_loaded:
AuthoringData.assetize_constr_class(constr_class) AuthoringData.assetize_constr_class(ifc_class)
else: else:
prop.update_constr_type_browser(props, context) prop.update_constr_type_browser(props, context)
min_width = 250 min_width = 250
@@ -217,9 +217,9 @@ class DisplayConstrTypes(bpy.types.Operator):
props = context.scene.BIMModelProperties props = context.scene.BIMModelProperties
header_data = self.draw_header(props) header_data = self.draw_header(props)
if props.unfold_constr_types: if props.unfold_constr_types:
self.draw_by_constr_class(props, header_data) self.draw_by_ifc_class(props, header_data)
else: else:
self.draw_by_constr_class_and_type(props, header_data) self.draw_by_ifc_class_and_type(props, header_data)
def draw_header(self, props): def draw_header(self, props):
layout = self.layout layout = self.layout
@@ -234,10 +234,10 @@ class DisplayConstrTypes(bpy.types.Operator):
row.label(text="Select Construction Type:") row.label(text="Select Construction Type:")
col1.row().separator(factor=1.5) col1.row().separator(factor=1.5)
enabled = True enabled = True
if AuthoringData.data["constr_classes"]: if AuthoringData.data["ifc_classes"]:
subsplit = col1.split(factor=1./3) subsplit = col1.split(factor=1./3)
subsplit.column().row().label(text="Construction Class:", icon="FILE_VOLUME") subsplit.column().row().label(text="Construction Class:", icon="FILE_VOLUME")
prop_with_search(subsplit.column(), props, "constr_class_browser", text="") prop_with_search(subsplit.column(), props, "ifc_class_browser", text="")
col1.row().separator() col1.row().separator()
else: else:
enabled = False enabled = False
@@ -248,9 +248,9 @@ class DisplayConstrTypes(bpy.types.Operator):
col2.row().separator(factor=1) col2.row().separator(factor=1)
return {"enabled": enabled, "layout": inner_layout, "col1": col1, "col2": col2} return {"enabled": enabled, "layout": inner_layout, "col1": col1, "col2": col2}
def draw_by_constr_class(self, props, header_data): def draw_by_ifc_class(self, props, header_data):
enabled, layout = [header_data[key] for key in ["enabled", "layout"]] enabled, layout = [header_data[key] for key in ["enabled", "layout"]]
constr_class_browser = props.constr_class_browser ifc_class_browser = props.ifc_class_browser
num_cols = 3 num_cols = 3
layout.row().separator(factor=0.25) layout.row().separator(factor=0.25)
layout.row().label(text="Construction Types:", icon="FILE_3D") layout.row().label(text="Construction Types:", icon="FILE_3D")
@@ -267,22 +267,22 @@ class DisplayConstrTypes(bpy.types.Operator):
row = box.row() row = box.row()
if enabled: if enabled:
preview_constr_types = AuthoringData.data["preview_constr_types"] preview_constr_types = AuthoringData.data["preview_constr_types"]
if constr_class_browser in preview_constr_types: if ifc_class_browser in preview_constr_types:
preview_constr_class = preview_constr_types[constr_class_browser] preview_ifc_class = preview_constr_types[ifc_class_browser]
if constr_type_id_browser in preview_constr_class: if constr_type_id_browser in preview_ifc_class:
icon_id = preview_constr_class[constr_type_id_browser]["icon_id"] icon_id = preview_ifc_class[constr_type_id_browser]["icon_id"]
row.template_icon(icon_value=icon_id, scale=6.) row.template_icon(icon_value=icon_id, scale=6.)
box.row().separator(factor=0.2) box.row().separator(factor=0.2)
row = box.row() row = box.row()
split = row.split(factor=0.5) split = row.split(factor=0.5)
col = split.column() col = split.column()
op = col.operator("bim.select_construction_type", icon="RIGHTARROW_THIN") op = col.operator("bim.select_construction_type", icon="RIGHTARROW_THIN")
op.constr_class = constr_class_browser op.ifc_class = ifc_class_browser
op.constr_type_id = constr_type_id_browser op.constr_type_id = constr_type_id_browser
col = split.column() col = split.column()
op = col.operator("bim.add_constr_type", icon="ADD") op = col.operator("bim.add_constr_type", icon="ADD")
op.from_invoke = True op.from_invoke = True
op.constr_class = constr_class_browser op.ifc_class = ifc_class_browser
if constr_type_id_browser.isnumeric(): if constr_type_id_browser.isnumeric():
op.constr_type_id = int(constr_type_id_browser) op.constr_type_id = int(constr_type_id_browser)
factor = 2 if idx + 1 < math.ceil(num_types / num_cols) else 1.5 factor = 2 if idx + 1 < math.ceil(num_types / num_cols) else 1.5
@@ -292,9 +292,9 @@ class DisplayConstrTypes(bpy.types.Operator):
for _ in range(num_cols - last_row_cols): for _ in range(num_cols - last_row_cols):
flow.column() flow.column()
def draw_by_constr_class_and_type(self, props, header_data): def draw_by_ifc_class_and_type(self, props, header_data):
enabled, col1, col2 = [header_data[key] for key in ["enabled", "col1", "col2"]] enabled, col1, col2 = [header_data[key] for key in ["enabled", "col1", "col2"]]
constr_class_browser = props.constr_class_browser ifc_class_browser = props.ifc_class_browser
constr_type_id_browser = props.constr_type_id_browser constr_type_id_browser = props.constr_type_id_browser
if AuthoringData.data["constr_types_ids_browser"]: if AuthoringData.data["constr_types_ids_browser"]:
subsplit = col1.split(factor=1. / 3) subsplit = col1.split(factor=1. / 3)
@@ -307,11 +307,11 @@ class DisplayConstrTypes(bpy.types.Operator):
row = col1.row() row = col1.row()
row.enabled = enabled row.enabled = enabled
op = row.operator("bim.select_construction_type", icon="RIGHTARROW_THIN") op = row.operator("bim.select_construction_type", icon="RIGHTARROW_THIN")
op.constr_class = constr_class_browser op.ifc_class = ifc_class_browser
op.constr_type_id = constr_type_id_browser op.constr_type_id = constr_type_id_browser
op = row.operator("bim.add_constr_type", icon="ADD") op = row.operator("bim.add_constr_type", icon="ADD")
op.from_invoke = True op.from_invoke = True
op.constr_class = constr_class_browser op.ifc_class = ifc_class_browser
if constr_type_id_browser.isnumeric(): if constr_type_id_browser.isnumeric():
op.constr_type_id = int(constr_type_id_browser) op.constr_type_id = int(constr_type_id_browser)
col2.row().separator(factor=1.25) col2.row().separator(factor=1.25)
@@ -328,7 +328,7 @@ class SelectConstructionType(bpy.types.Operator):
bl_label = "Select" bl_label = "Select"
bl_options = {"REGISTER", "UNDO"} bl_options = {"REGISTER", "UNDO"}
bl_description = "Pick Type Instance as selection for subsequent operations" bl_description = "Pick Type Instance as selection for subsequent operations"
constr_class: bpy.props.StringProperty() ifc_class: bpy.props.StringProperty()
constr_type_id: bpy.props.StringProperty() constr_type_id: bpy.props.StringProperty()
def invoke(self, context, event): def invoke(self, context, event):
@@ -337,8 +337,8 @@ class SelectConstructionType(bpy.types.Operator):
def execute(self, context): def execute(self, context):
props = context.scene.BIMModelProperties props = context.scene.BIMModelProperties
if self.constr_class != "": if self.ifc_class != "":
props.constr_class = self.constr_class props.ifc_class = self.ifc_class
AuthoringData.load_constr_types() AuthoringData.load_constr_types()
if self.constr_type_id != "": if self.constr_type_id != "":
props.constr_type_id = self.constr_type_id props.constr_type_id = self.constr_type_id
@@ -21,10 +21,10 @@ from blenderbim.bim.module.model.data import AuthoringData
from bpy.types import PropertyGroup from bpy.types import PropertyGroup
def get_constr_class(self, context): def get_ifc_class(self, context):
if not AuthoringData.is_loaded: if not AuthoringData.is_loaded:
AuthoringData.load() AuthoringData.load()
return AuthoringData.data["constr_classes"] return AuthoringData.data["ifc_classes"]
def get_constr_type(self, context): def get_constr_type(self, context):
@@ -40,34 +40,34 @@ def get_constr_type_browser(self, context):
def update_icon_id(self, context): def update_icon_id(self, context):
constr_class_browser = self.constr_class_browser ifc_class_browser = self.ifc_class_browser
constr_type_id_browser = self.constr_type_id_browser constr_type_id_browser = self.constr_type_id_browser
constr_type_browser = AuthoringData.constr_type_name_by_id(constr_class_browser, constr_type_id_browser) constr_type_browser = AuthoringData.constr_type_name_by_id(ifc_class_browser, constr_type_id_browser)
if ((constr_class_browser not in AuthoringData.data["preview_constr_types"] if ((ifc_class_browser not in AuthoringData.data["preview_constr_types"]
or constr_type_id_browser not in AuthoringData.data["preview_constr_types"][constr_class_browser]) or constr_type_id_browser not in AuthoringData.data["preview_constr_types"][ifc_class_browser])
and constr_type_browser is not None): and constr_type_browser is not None):
if not AuthoringData.assetize_constr_type_from_selection(): if not AuthoringData.assetize_constr_type_from_selection():
return return
self.icon_id = AuthoringData.data["preview_constr_types"][constr_class_browser][constr_type_id_browser]["icon_id"] self.icon_id = AuthoringData.data["preview_constr_types"][ifc_class_browser][constr_type_id_browser]["icon_id"]
def update_constr_class(self, context): def update_ifc_class(self, context):
AuthoringData.load_constr_classes() AuthoringData.load_ifc_classes()
AuthoringData.load_constr_types() AuthoringData.load_constr_types()
self.constr_type_id = AuthoringData.data["constr_types_ids"][0][0] self.constr_type_id = AuthoringData.data["constr_types_ids"][0][0]
def update_constr_class_browser(self, context): def update_ifc_class_browser(self, context):
AuthoringData.load_constr_classes() AuthoringData.load_ifc_classes()
AuthoringData.load_constr_types_browser() AuthoringData.load_constr_types_browser()
props = context.scene.BIMModelProperties props = context.scene.BIMModelProperties
if props.unfold_constr_types: if props.unfold_constr_types:
constr_class_browser = props.constr_class_browser ifc_class_browser = props.ifc_class_browser
constr_type_info = AuthoringData.constr_type_info(constr_class_browser) constr_type_info = AuthoringData.constr_type_info(ifc_class_browser)
if constr_type_info is None or not constr_type_info.fully_loaded: if constr_type_info is None or not constr_type_info.fully_loaded:
curr_selection = props.constr_class, props.constr_type_id curr_selection = props.ifc_class, props.constr_type_id
AuthoringData.assetize_constr_class(constr_class_browser) AuthoringData.assetize_constr_class(ifc_class_browser)
props.constr_class, props.constr_type_id = curr_selection props.ifc_class, props.constr_type_id = curr_selection
else: else:
self.constr_type_id_browser = AuthoringData.data["constr_types_ids_browser"][0][0] self.constr_type_id_browser = AuthoringData.data["constr_types_ids_browser"][0][0]
@@ -78,14 +78,14 @@ def update_constr_type(self, context):
def update_constr_type_by_name(self, context): def update_constr_type_by_name(self, context):
AuthoringData.load_constr_types() AuthoringData.load_constr_types()
constr_type_id = AuthoringData.constr_type_id_by_name(self.constr_class, self.constr_type) constr_type_id = AuthoringData.constr_type_id_by_name(self.ifc_class, self.constr_type)
if constr_type_id is not None: if constr_type_id is not None:
self.constr_type_id = constr_type_id self.constr_type_id = constr_type_id
def update_constr_type_browser_by_name(self, context): def update_constr_type_browser_by_name(self, context):
AuthoringData.load_constr_types_browser() AuthoringData.load_constr_types_browser()
constr_type_id_browser = AuthoringData.constr_type_id_by_name(self.constr_class_browser, self.constr_type_browser) constr_type_id_browser = AuthoringData.constr_type_id_by_name(self.ifc_class_browser, self.constr_type_browser)
if constr_type_id_browser is not None: if constr_type_id_browser is not None:
self.constr_type_id_browser = constr_type_id_browser self.constr_type_id_browser = constr_type_id_browser
@@ -96,13 +96,13 @@ def update_constr_type_browser(self, context):
def update_unfold_constr_type(self, context): def update_unfold_constr_type(self, context):
update_constr_class_browser(self, context) update_ifc_class_browser(self, context)
class BIMModelProperties(PropertyGroup): class BIMModelProperties(PropertyGroup):
constr_class: bpy.props.EnumProperty(items=get_constr_class, name="Construction Class", update=update_constr_class) ifc_class: bpy.props.EnumProperty(items=get_ifc_class, name="Construction Class", update=update_ifc_class)
constr_class_browser: bpy.props.EnumProperty( ifc_class_browser: bpy.props.EnumProperty(
items=get_constr_class, name="Construction Class", update=update_constr_class_browser items=get_ifc_class, name="Construction Class", update=update_ifc_class_browser
) )
constr_type: bpy.props.StringProperty(update=update_constr_type_by_name) constr_type: bpy.props.StringProperty(update=update_constr_type_by_name)
constr_type_id: bpy.props.EnumProperty( constr_type_id: bpy.props.EnumProperty(
@@ -120,13 +120,13 @@ class BIMModelProperties(PropertyGroup):
) )
occurrence_name_function: bpy.props.StringProperty(name="Occurrence Name Function") occurrence_name_function: bpy.props.StringProperty(name="Occurrence Name Function")
getter_enum = { getter_enum = {
"constr_class_browser": get_constr_class, "ifc_class_browser": get_ifc_class,
"constr_type_browser": get_constr_type_browser "constr_type_browser": get_constr_type_browser
} }
def get_constr_type_info(self, context): def get_constr_type_info(self, context):
return AuthoringData.relating_types(constr_class=self.name) return AuthoringData.relating_types(ifc_class=self.name)
class ConstrTypeInfo(PropertyGroup): class ConstrTypeInfo(PropertyGroup):
@@ -62,40 +62,40 @@ class BimTool(WorkSpaceTool):
row.label(text="No IFC Project", icon="ERROR") row.label(text="No IFC Project", icon="ERROR")
return return
constr_classes = AuthoringData.data["constr_classes"] ifc_classes = AuthoringData.data["ifc_classes"]
constr_types_ids = AuthoringData.data["constr_types_ids"] constr_types_ids = AuthoringData.data["constr_types_ids"]
if is_tool_header: if is_tool_header:
row.operator("bim.help_constr_types", text="", icon="QUESTION") row.operator("bim.help_constr_types", text="", icon="QUESTION")
if constr_classes and is_tool_header: if ifc_classes and is_tool_header:
row.label(text="", icon="BLANK1") row.label(text="", icon="BLANK1")
row.operator("bim.display_constr_types", icon="COLLAPSEMENU") row.operator("bim.display_constr_types", icon="COLLAPSEMENU")
constr_class = props.constr_class ifc_class = props.ifc_class
constr_type_id = props.constr_type_id constr_type_id = props.constr_type_id
constr_type = AuthoringData.constr_type_name_by_id(constr_class, constr_type_id) constr_type = AuthoringData.constr_type_name_by_id(ifc_class, constr_type_id)
if is_tool_header: if is_tool_header:
row.label(text="", icon="BLANK1") row.label(text="", icon="BLANK1")
row = layout.row(align=True) row = layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT") row.label(text="", icon="EVENT_SHIFT")
row.label(text="", icon="EVENT_A") row.label(text="", icon="EVENT_A")
if constr_classes: if ifc_classes:
row.label(text=f" Add") row.label(text=f" Add")
row.label(text="", icon="FILE_VOLUME") row.label(text="", icon="FILE_VOLUME")
row.label(text=constr_class) row.label(text=ifc_class)
row.label(text="", icon="FILE_3D") row.label(text="", icon="FILE_3D")
row.label(text=f"{constr_type} ") row.label(text=f"{constr_type} ")
else: else:
row.label(text=f" Add instance") row.label(text=f" Add instance")
else: else:
txt_constr_class = constr_class if constr_classes else "No Construction Class" txt_ifc_class = ifc_class if ifc_classes else "No Construction Class"
txt_constr_type = constr_type if constr_types_ids else "No Construction Type" txt_constr_type = constr_type if constr_types_ids else "No Construction Type"
row = layout.row(align=True) row = layout.row(align=True)
row.label(text="Selected Construction Type:") row.label(text="Selected Construction Type:")
row = layout.row(align=True) row = layout.row(align=True)
row.label(text=txt_constr_class, icon="FILE_VOLUME") row.label(text=txt_ifc_class, icon="FILE_VOLUME")
row = layout.row(align=True) row = layout.row(align=True)
row.label(text=txt_constr_type, icon="FILE_3D") row.label(text=txt_constr_type, icon="FILE_3D")
row = layout.row(align=True) row = layout.row(align=True)
@@ -103,8 +103,8 @@ class BimTool(WorkSpaceTool):
row.label(text="", icon="EVENT_A") row.label(text="", icon="EVENT_A")
row.label(text=f" Add Type Instance") row.label(text=f" Add Type Instance")
if AuthoringData.data["constr_classes"]: if AuthoringData.data["ifc_classes"]:
if constr_class == "IfcWallType": if ifc_class == "IfcWallType":
row = layout.row() row = layout.row()
row.label(text="Join") row.label(text="Join")
row = layout.row(align=True) row = layout.row(align=True)
@@ -126,7 +126,7 @@ class BimTool(WorkSpaceTool):
row.label(text="", icon="EVENT_SHIFT") row.label(text="", icon="EVENT_SHIFT")
row.label(text="Split", icon="EVENT_S") row.label(text="Split", icon="EVENT_S")
if constr_class in ("IfcColumnType", "IfcBeamType", "IfcMemberType"): if ifc_class in ("IfcColumnType", "IfcBeamType", "IfcMemberType"):
row = layout.row() row = layout.row()
row.label(text="Join") row.label(text="Join")
row = layout.row(align=True) row = layout.row(align=True)
@@ -144,7 +144,7 @@ Scenario: Remove representation - remove an instanced representation from an act
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType" And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType" And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
And I press "bim.assign_class" And I press "bim.assign_class"
And I set "scene.BIMModelProperties.constr_class" to "IfcWallType" And I set "scene.BIMModelProperties.ifc_class" to "IfcWallType"
And the variable "cube" is "{ifc}.by_type('IfcWallType')[0].id()" And the variable "cube" is "{ifc}.by_type('IfcWallType')[0].id()"
And I set "scene.BIMModelProperties.constr_type_id" to "{cube}" And I set "scene.BIMModelProperties.constr_type_id" to "{cube}"
And I press "bim.add_constr_type" And I press "bim.add_constr_type"
@@ -163,7 +163,7 @@ Scenario: Remove representation - remove an instanced representation from an act
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType" And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType" And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
And I press "bim.assign_class" And I press "bim.assign_class"
And I set "scene.BIMModelProperties.constr_class" to "IfcWallType" And I set "scene.BIMModelProperties.ifc_class" to "IfcWallType"
And the variable "cube" is "{ifc}.by_type('IfcWallType')[0].id()" And the variable "cube" is "{ifc}.by_type('IfcWallType')[0].id()"
And I set "scene.BIMModelProperties.constr_type_id" to "{cube}" And I set "scene.BIMModelProperties.constr_type_id" to "{cube}"
And I press "bim.add_constr_type" And I press "bim.add_constr_type"
@@ -337,7 +337,7 @@ Scenario: Override duplicate move - copying a type instance with a representatio
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType" And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType" And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
And I press "bim.assign_class" And I press "bim.assign_class"
And I set "scene.BIMModelProperties.constr_class" to "IfcWallType" And I set "scene.BIMModelProperties.ifc_class" to "IfcWallType"
And the variable "cube" is "{ifc}.by_type('IfcWallType')[0].id()" And the variable "cube" is "{ifc}.by_type('IfcWallType')[0].id()"
And I set "scene.BIMModelProperties.constr_type_id" to "{cube}" And I set "scene.BIMModelProperties.constr_type_id" to "{cube}"
And I press "bim.add_constr_type" And I press "bim.add_constr_type"
@@ -8,7 +8,7 @@ Scenario: Add type instance - add from a mesh
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType" And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType" And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
And I press "bim.assign_class" And I press "bim.assign_class"
And I set "scene.BIMModelProperties.constr_class" to "IfcWallType" And I set "scene.BIMModelProperties.ifc_class" to "IfcWallType"
And the variable "cube" is "{ifc}.by_type('IfcWallType')[0].id()" And the variable "cube" is "{ifc}.by_type('IfcWallType')[0].id()"
And I set "scene.BIMModelProperties.constr_type_id" to "{cube}" And I set "scene.BIMModelProperties.constr_type_id" to "{cube}"
When I press "bim.add_constr_type" When I press "bim.add_constr_type"
@@ -21,7 +21,7 @@ Scenario: Add type instance - add from an empty
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType" And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType" And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
And I press "bim.assign_class" And I press "bim.assign_class"
And I set "scene.BIMModelProperties.constr_class" to "IfcWallType" And I set "scene.BIMModelProperties.ifc_class" to "IfcWallType"
And the variable "empty" is "{ifc}.by_type('IfcWallType')[0].id()" And the variable "empty" is "{ifc}.by_type('IfcWallType')[0].id()"
And I set "scene.BIMModelProperties.constr_type_id" to "{empty}" And I set "scene.BIMModelProperties.constr_type_id" to "{empty}"
When I press "bim.add_constr_type" When I press "bim.add_constr_type"
@@ -34,7 +34,7 @@ Scenario: Add type instance - add a mesh where existing instances have changed c
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType" And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType" And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
And I press "bim.assign_class" And I press "bim.assign_class"
And I set "scene.BIMModelProperties.constr_class" to "IfcWallType" And I set "scene.BIMModelProperties.ifc_class" to "IfcWallType"
And the variable "cube" is "{ifc}.by_type('IfcWallType')[0].id()" And the variable "cube" is "{ifc}.by_type('IfcWallType')[0].id()"
And I set "scene.BIMModelProperties.constr_type_id" to "{cube}" And I set "scene.BIMModelProperties.constr_type_id" to "{cube}"
And I press "bim.add_constr_type" And I press "bim.add_constr_type"
@@ -53,10 +53,10 @@ Scenario: Preview one type on the Construction Type Browser
And I load the demo construction library And I load the demo construction library
When I display the construction type browser When I display the construction type browser
And I preview only one asset on the construction type browser And I preview only one asset on the construction type browser
And I set "scene.BIMModelProperties.constr_class_browser" to "IfcColumnType" And I set "scene.BIMModelProperties.ifc_class_browser" to "IfcColumnType"
And I set "scene.BIMModelProperties.constr_type_browser" to "DEMO2" And I set "scene.BIMModelProperties.constr_type_browser" to "DEMO2"
And I select the browser construction type And I select the browser construction type
Then "scene.BIMModelProperties.constr_class" is "IfcColumnType" Then "scene.BIMModelProperties.ifc_class" is "IfcColumnType"
And construction type is DEMO2 And construction type is DEMO2
And objects starting with "IfcColumn/" do not exist And objects starting with "IfcColumn/" do not exist
And the construction type "IfcColumnType"/"DEMO2" has a preview And the construction type "IfcColumnType"/"DEMO2" has a preview
@@ -66,8 +66,8 @@ Scenario: Preview one class on the construction type browser
And I load the demo construction library And I load the demo construction library
When I display the construction type browser When I display the construction type browser
And I preview all available assets on the construction type browser And I preview all available assets on the construction type browser
And I set "scene.BIMModelProperties.constr_class_browser" to "IfcWallType" And I set "scene.BIMModelProperties.ifc_class_browser" to "IfcWallType"
Then "scene.BIMModelProperties.constr_class_browser" is "IfcWallType" Then "scene.BIMModelProperties.ifc_class_browser" is "IfcWallType"
And objects starting with "IfcWall/" do not exist And objects starting with "IfcWall/" do not exist
And all construction types for "IfcWallType" have a preview And all construction types for "IfcWallType" have a preview
@@ -76,7 +76,7 @@ Scenario: Add one type from the Construction Type Browser
And I load the demo construction library And I load the demo construction library
When I display the construction type browser When I display the construction type browser
And I preview only one asset on the construction type browser And I preview only one asset on the construction type browser
And I set "scene.BIMModelProperties.constr_class_browser" to "IfcColumnType" And I set "scene.BIMModelProperties.ifc_class_browser" to "IfcColumnType"
And I set "scene.BIMModelProperties.constr_type_browser" to "DEMO2" And I set "scene.BIMModelProperties.constr_type_browser" to "DEMO2"
And I add the browser construction type And I add the browser construction type
Then the object "IfcColumn/Column" exists Then the object "IfcColumn/Column" exists
+22 -22
View File
@@ -575,27 +575,27 @@ def the_object_name_has_no_modifiers(name):
assert len(the_object_name_exists(name).modifiers) == 0 assert len(the_object_name_exists(name).modifiers) == 0
@then(parsers.parse('the construction type "{constr_class}"/"{constr_type}" has a preview')) @then(parsers.parse('the construction type "{ifc_class}"/"{constr_type}" has a preview'))
def the_construction_type_has_a_preview(constr_class, constr_type): def the_construction_type_has_a_preview(ifc_class, constr_type):
if "preview_constr_types" not in AuthoringData.data: if "preview_constr_types" not in AuthoringData.data:
assert False, 'There are no previews loaded' assert False, 'There are no previews loaded'
preview_constr_types = AuthoringData.data["preview_constr_types"] preview_constr_types = AuthoringData.data["preview_constr_types"]
if constr_class not in preview_constr_types: if ifc_class not in preview_constr_types:
assert False, f'Construction class {constr_class} has no available previews' assert False, f'Construction class {ifc_class} has no available previews'
constr_type_id = AuthoringData.constr_type_id_by_name(constr_class, constr_type) constr_type_id = AuthoringData.constr_type_id_by_name(ifc_class, constr_type)
if constr_type_id is None: if constr_type_id is None:
assert False, f'No construction type {constr_class}/{constr_type} was found' assert False, f'No construction type {ifc_class}/{constr_type} was found'
if constr_type_id not in preview_constr_types[constr_class]: if constr_type_id not in preview_constr_types[ifc_class]:
assert False, f'Construction type {constr_class}/{constr_type} has no available previews' assert False, f'Construction type {ifc_class}/{constr_type} has no available previews'
preview_data = preview_constr_types[constr_class][constr_type_id] preview_data = preview_constr_types[ifc_class][constr_type_id]
if 'icon_id' not in preview_data: if 'icon_id' not in preview_data:
assert False, f'Construction type {constr_class}/{constr_type} has a preview, but no assigned icon_id' assert False, f'Construction type {ifc_class}/{constr_type} has a preview, but no assigned icon_id'
icon_id = preview_data["icon_id"] icon_id = preview_data["icon_id"]
if not isinstance(icon_id, int): if not isinstance(icon_id, int):
assert False, f'Construction type {constr_class}/{constr_type} has an invalid icon_id {icon_id}' assert False, f'Construction type {ifc_class}/{constr_type} has an invalid icon_id {icon_id}'
# Note: icon_id must be > 0 in UI mode, but asset_generate_preview() doesn't work headlessly -> skipping for now # Note: icon_id must be > 0 in UI mode, but asset_generate_preview() doesn't work headlessly -> skipping for now
# if icon_id == 0: # if icon_id == 0:
# assert False, f'Construction type {constr_class}/{constr_type} has the default null value for icon_id' # assert False, f'Construction type {ifc_class}/{constr_type} has the default null value for icon_id'
assert True assert True
@@ -605,16 +605,16 @@ def there_is_a_construction_type_preview():
assert props.icon_id > 0, f"There isn't a Construction Type preview" assert props.icon_id > 0, f"There isn't a Construction Type preview"
@then(parsers.parse('all construction types for "{constr_class}" have a preview')) @then(parsers.parse('all construction types for "{ifc_class}" have a preview'))
def all_construction_types_have_a_preview(constr_class): def all_construction_types_have_a_preview(ifc_class):
if "preview_constr_types" not in AuthoringData.data: if "preview_constr_types" not in AuthoringData.data:
assert False, 'There are no previews loaded' assert False, 'There are no previews loaded'
preview_constr_types = AuthoringData.data["preview_constr_types"] preview_constr_types = AuthoringData.data["preview_constr_types"]
if constr_class not in preview_constr_types: if ifc_class not in preview_constr_types:
assert False, f'Construction class {constr_class} has no available previews' assert False, f'Construction class {ifc_class} has no available previews'
constr_class_occurrences = AuthoringData.constr_class_entities(constr_class) constr_class_occurrences = AuthoringData.constr_class_entities(ifc_class)
for constr_class_entity in constr_class_occurrences: for constr_class_entity in constr_class_occurrences:
the_construction_type_has_a_preview(constr_class, constr_class_entity.Name) the_construction_type_has_a_preview(ifc_class, constr_class_entity.Name)
@given("I load the demo construction library") @given("I load the demo construction library")
@@ -647,7 +647,7 @@ def i_preview_all_construction_types():
def i_select_the_active_construction_type(): def i_select_the_active_construction_type():
props = bpy.context.scene.BIMModelProperties props = bpy.context.scene.BIMModelProperties
bpy.ops.bim.select_construction_type( bpy.ops.bim.select_construction_type(
constr_class=props.constr_class_browser, constr_type_id=props.constr_type_id_browser ifc_class=props.ifc_class_browser, constr_type_id=props.constr_type_id_browser
) )
@@ -656,14 +656,14 @@ def i_select_the_active_construction_type():
def i_add_the_active_construction_type(): def i_add_the_active_construction_type():
props = bpy.context.scene.BIMModelProperties props = bpy.context.scene.BIMModelProperties
bpy.ops.bim.add_constr_type( bpy.ops.bim.add_constr_type(
constr_class=props.constr_class_browser, constr_type_id=int(props.constr_type_id_browser) ifc_class=props.ifc_class_browser, constr_type_id=int(props.constr_type_id_browser)
) )
@then(parsers.parse("browser construction type is {constr_type_name}")) @then(parsers.parse("browser construction type is {constr_type_name}"))
def browser_construction_type(constr_type_name): def browser_construction_type(constr_type_name):
props = bpy.context.scene.BIMModelProperties props = bpy.context.scene.BIMModelProperties
constr_type_browser = AuthoringData.constr_type_name_by_id(props.constr_class_browser, props.constr_type_id_browser) constr_type_browser = AuthoringData.constr_type_name_by_id(props.ifc_class_browser, props.constr_type_id_browser)
assert constr_type_browser == constr_type_name, (f"Construction Type is a {constr_type_browser}, not " + assert constr_type_browser == constr_type_name, (f"Construction Type is a {constr_type_browser}, not " +
f"a {constr_type_name}") f"a {constr_type_name}")
@@ -671,7 +671,7 @@ def browser_construction_type(constr_type_name):
@then(parsers.parse("construction type is {constr_type_name}")) @then(parsers.parse("construction type is {constr_type_name}"))
def construction_type(constr_type_name): def construction_type(constr_type_name):
props = bpy.context.scene.BIMModelProperties props = bpy.context.scene.BIMModelProperties
constr_type = AuthoringData.constr_type_name_by_id(props.constr_class, props.constr_type_id) constr_type = AuthoringData.constr_type_name_by_id(props.ifc_class, props.constr_type_id)
assert constr_type == constr_type_name, f"Construction Type is a {constr_type}, not a {constr_type_name}" assert constr_type == constr_type_name, f"Construction Type is a {constr_type}, not a {constr_type_name}"