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"):
cls.data = {}
cls.props = bpy.context.scene.BIMModelProperties
cls.load_constr_classes()
cls.load_ifc_classes()
cls.load_constr_types()
cls.load_constr_types_browser()
cls.load_preview_constr_types()
@classmethod
def load_constr_classes(cls):
cls.data["constr_classes"] = cls.constr_classes()
def load_ifc_classes(cls):
cls.data["ifc_classes"] = cls.ifc_classes()
@classmethod
def load_constr_types(cls):
@@ -62,7 +62,7 @@ class AuthoringData:
cls.data["preview_constr_types"] = preview_icon_ids
@classmethod
def constr_classes(cls):
def ifc_classes(cls):
results = []
classes = {
e.is_a()
@@ -74,63 +74,63 @@ class AuthoringData:
return results
@classmethod
def constr_class_entities(cls, constr_class=None):
constr_classes = cls.data["constr_classes"]
if not constr_classes:
def constr_class_entities(cls, ifc_class=None):
ifc_classes = cls.data["ifc_classes"]
if not ifc_classes:
return []
results = []
if constr_class is None:
constr_class = cls.props.constr_class
if not constr_class and constr_classes:
constr_class = constr_classes[0][0]
if constr_class:
elements = sorted(tool.Ifc.get().by_type(constr_class), key=lambda s: s.Name)
if ifc_class is None:
ifc_class = cls.props.ifc_class
if not ifc_class and ifc_classes:
ifc_class = ifc_classes[0][0]
if ifc_class:
elements = sorted(tool.Ifc.get().by_type(ifc_class), key=lambda s: s.Name)
results.extend(elements)
return results
return []
@classmethod
def constr_types(cls, constr_class=None):
def constr_types(cls, ifc_class=None):
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
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
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.name = constr_class
constr_type_info.name = ifc_class
return constr_type_info
@classmethod
def assetize_constr_class(cls, constr_class=None):
if constr_class is None:
constr_class = cls.props.constr_class
constr_type_info = cls.constr_type_info(constr_class)
_ = cls.new_constr_type_info(constr_class) if constr_type_info is None else constr_type_info
constr_class_occurrences = cls.constr_class_entities(constr_class)
def assetize_constr_class(cls, ifc_class=None):
if ifc_class is None:
ifc_class = cls.props.ifc_class
constr_type_info = cls.constr_type_info(ifc_class)
_ = cls.new_constr_type_info(ifc_class) if constr_type_info is None else constr_type_info
constr_class_occurrences = cls.constr_class_entities(ifc_class)
preview_constr_types = cls.data["preview_constr_types"]
for constr_class_entity in constr_class_occurrences:
### handle asset regeneration when library entity is updated ¿?
if (constr_class not in preview_constr_types
or str(constr_class_entity.id()) not in preview_constr_types[constr_class]):
if (ifc_class not in preview_constr_types
or str(constr_class_entity.id()) not in preview_constr_types[ifc_class]):
obj = tool.Ifc.get_object(constr_class_entity)
cls.assetize_object(obj, constr_class, constr_class_entity)
constr_type_info = cls.constr_type_info(constr_class)
cls.assetize_object(obj, ifc_class, constr_class_entity)
constr_type_info = cls.constr_type_info(ifc_class)
constr_type_info.fully_loaded = True
@classmethod
def assetize_object(cls, obj, constr_class, constr_class_entity, from_selection=False):
constr_type_id = constr_class_entity.id()
def assetize_object(cls, obj, ifc_class, ifc_class_entity, from_selection=False):
constr_type_id = ifc_class_entity.id()
to_be_deleted = False
if obj.type == 'EMPTY':
kwargs = {}
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)
if new_obj is not None:
to_be_deleted = True
@@ -138,18 +138,18 @@ class AuthoringData:
obj.asset_mark()
obj.asset_generate_preview()
icon_id = obj.preview.icon_id
if constr_class not in cls.data["preview_constr_types"]:
cls.data["preview_constr_types"][constr_class] = {}
cls.data["preview_constr_types"][constr_class][str(constr_type_id)] = {"icon_id": icon_id, "object": obj}
if ifc_class not in cls.data["preview_constr_types"]:
cls.data["preview_constr_types"][ifc_class] = {}
cls.data["preview_constr_types"][ifc_class][str(constr_type_id)] = {"icon_id": icon_id, "object": obj}
if to_be_deleted:
for col in obj.users_collection:
col.objects.unlink(obj)
@classmethod
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_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 = [
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)
if obj is None:
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
@staticmethod
def constr_type_info(constr_class):
constr_type_infos = [element for element in bpy.context.scene.ConstrTypeInfo if element.name == constr_class]
def constr_type_info(ifc_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]
@classmethod
def new_constr_type(cls, constr_class=None, constr_type_id=None):
if constr_class is None:
def new_constr_type(cls, ifc_class=None, constr_type_id=None):
if ifc_class is None:
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:
cls.props.constr_class = constr_class
cls.props.ifc_class = ifc_class
cls.props.constr_type_id = str(constr_type_id)
bpy.ops.bim.add_constr_type()
return bpy.context.selected_objects[-1]
@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()
try:
constr_class_entity = file.by_id(int(constr_type_id))
except (RuntimeError, ValueError):
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
def constr_type_id_by_name(cls, constr_class, constr_type):
constr_types = [ct[0] for ct in cls.constr_types(constr_class=constr_class) if ct[1] == constr_type]
def constr_type_id_by_name(cls, ifc_class, 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]
@classmethod
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
@classmethod
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
@@ -62,7 +62,7 @@ class AddConstrType(bpy.types.Operator):
bl_label = "Add"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Add Type Instance to the model"
constr_class: bpy.props.StringProperty()
ifc_class: bpy.props.StringProperty()
constr_type_id: bpy.props.IntProperty()
from_invoke: bpy.props.BoolProperty(default=False)
@@ -76,18 +76,18 @@ class AddConstrType(bpy.types.Operator):
def _execute(self, context):
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
if not constr_class or not constr_type_id:
if not ifc_class or not constr_type_id:
return {"FINISHED"}
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)
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))
material = ifcopenshell.util.element.get_material(constr_type)
@@ -95,7 +95,7 @@ class AddConstrType(bpy.types.Operator):
if profile.DumbProfileGenerator(constr_type).generate():
return {"FINISHED"}
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"}
if constr_type.is_a("IfcFlowSegmentType") and not constr_type.RepresentationMaps:
if mep.MepGenerator(constr_type).generate():
@@ -202,10 +202,10 @@ class DisplayConstrTypes(bpy.types.Operator):
AuthoringData.setup_constr_type_browser()
props = context.scene.BIMModelProperties
if props.unfold_constr_types:
constr_class = props.constr_class_browser
constr_type_info = AuthoringData.constr_type_info(constr_class)
ifc_class = props.ifc_class_browser
constr_type_info = AuthoringData.constr_type_info(ifc_class)
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:
prop.update_constr_type_browser(props, context)
min_width = 250
@@ -217,9 +217,9 @@ class DisplayConstrTypes(bpy.types.Operator):
props = context.scene.BIMModelProperties
header_data = self.draw_header(props)
if props.unfold_constr_types:
self.draw_by_constr_class(props, header_data)
self.draw_by_ifc_class(props, header_data)
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):
layout = self.layout
@@ -234,10 +234,10 @@ class DisplayConstrTypes(bpy.types.Operator):
row.label(text="Select Construction Type:")
col1.row().separator(factor=1.5)
enabled = True
if AuthoringData.data["constr_classes"]:
if AuthoringData.data["ifc_classes"]:
subsplit = col1.split(factor=1./3)
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()
else:
enabled = False
@@ -248,9 +248,9 @@ class DisplayConstrTypes(bpy.types.Operator):
col2.row().separator(factor=1)
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"]]
constr_class_browser = props.constr_class_browser
ifc_class_browser = props.ifc_class_browser
num_cols = 3
layout.row().separator(factor=0.25)
layout.row().label(text="Construction Types:", icon="FILE_3D")
@@ -267,22 +267,22 @@ class DisplayConstrTypes(bpy.types.Operator):
row = box.row()
if enabled:
preview_constr_types = AuthoringData.data["preview_constr_types"]
if constr_class_browser in preview_constr_types:
preview_constr_class = preview_constr_types[constr_class_browser]
if constr_type_id_browser in preview_constr_class:
icon_id = preview_constr_class[constr_type_id_browser]["icon_id"]
if ifc_class_browser in preview_constr_types:
preview_ifc_class = preview_constr_types[ifc_class_browser]
if constr_type_id_browser in preview_ifc_class:
icon_id = preview_ifc_class[constr_type_id_browser]["icon_id"]
row.template_icon(icon_value=icon_id, scale=6.)
box.row().separator(factor=0.2)
row = box.row()
split = row.split(factor=0.5)
col = split.column()
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
col = split.column()
op = col.operator("bim.add_constr_type", icon="ADD")
op.from_invoke = True
op.constr_class = constr_class_browser
op.ifc_class = ifc_class_browser
if constr_type_id_browser.isnumeric():
op.constr_type_id = int(constr_type_id_browser)
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):
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"]]
constr_class_browser = props.constr_class_browser
ifc_class_browser = props.ifc_class_browser
constr_type_id_browser = props.constr_type_id_browser
if AuthoringData.data["constr_types_ids_browser"]:
subsplit = col1.split(factor=1. / 3)
@@ -307,11 +307,11 @@ class DisplayConstrTypes(bpy.types.Operator):
row = col1.row()
row.enabled = enabled
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 = row.operator("bim.add_constr_type", icon="ADD")
op.from_invoke = True
op.constr_class = constr_class_browser
op.ifc_class = ifc_class_browser
if constr_type_id_browser.isnumeric():
op.constr_type_id = int(constr_type_id_browser)
col2.row().separator(factor=1.25)
@@ -328,7 +328,7 @@ class SelectConstructionType(bpy.types.Operator):
bl_label = "Select"
bl_options = {"REGISTER", "UNDO"}
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()
def invoke(self, context, event):
@@ -337,8 +337,8 @@ class SelectConstructionType(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMModelProperties
if self.constr_class != "":
props.constr_class = self.constr_class
if self.ifc_class != "":
props.ifc_class = self.ifc_class
AuthoringData.load_constr_types()
if 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
def get_constr_class(self, context):
def get_ifc_class(self, context):
if not AuthoringData.is_loaded:
AuthoringData.load()
return AuthoringData.data["constr_classes"]
return AuthoringData.data["ifc_classes"]
def get_constr_type(self, context):
@@ -40,34 +40,34 @@ def get_constr_type_browser(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_browser = AuthoringData.constr_type_name_by_id(constr_class_browser, constr_type_id_browser)
if ((constr_class_browser not in AuthoringData.data["preview_constr_types"]
or constr_type_id_browser not in AuthoringData.data["preview_constr_types"][constr_class_browser])
constr_type_browser = AuthoringData.constr_type_name_by_id(ifc_class_browser, constr_type_id_browser)
if ((ifc_class_browser not in AuthoringData.data["preview_constr_types"]
or constr_type_id_browser not in AuthoringData.data["preview_constr_types"][ifc_class_browser])
and constr_type_browser is not None):
if not AuthoringData.assetize_constr_type_from_selection():
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):
AuthoringData.load_constr_classes()
def update_ifc_class(self, context):
AuthoringData.load_ifc_classes()
AuthoringData.load_constr_types()
self.constr_type_id = AuthoringData.data["constr_types_ids"][0][0]
def update_constr_class_browser(self, context):
AuthoringData.load_constr_classes()
def update_ifc_class_browser(self, context):
AuthoringData.load_ifc_classes()
AuthoringData.load_constr_types_browser()
props = context.scene.BIMModelProperties
if props.unfold_constr_types:
constr_class_browser = props.constr_class_browser
constr_type_info = AuthoringData.constr_type_info(constr_class_browser)
ifc_class_browser = props.ifc_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:
curr_selection = props.constr_class, props.constr_type_id
AuthoringData.assetize_constr_class(constr_class_browser)
props.constr_class, props.constr_type_id = curr_selection
curr_selection = props.ifc_class, props.constr_type_id
AuthoringData.assetize_constr_class(ifc_class_browser)
props.ifc_class, props.constr_type_id = curr_selection
else:
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):
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:
self.constr_type_id = constr_type_id
def update_constr_type_browser_by_name(self, context):
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:
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):
update_constr_class_browser(self, context)
update_ifc_class_browser(self, context)
class BIMModelProperties(PropertyGroup):
constr_class: bpy.props.EnumProperty(items=get_constr_class, name="Construction Class", update=update_constr_class)
constr_class_browser: bpy.props.EnumProperty(
items=get_constr_class, name="Construction Class", update=update_constr_class_browser
ifc_class: bpy.props.EnumProperty(items=get_ifc_class, name="Construction Class", update=update_ifc_class)
ifc_class_browser: bpy.props.EnumProperty(
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_id: bpy.props.EnumProperty(
@@ -120,13 +120,13 @@ class BIMModelProperties(PropertyGroup):
)
occurrence_name_function: bpy.props.StringProperty(name="Occurrence Name Function")
getter_enum = {
"constr_class_browser": get_constr_class,
"ifc_class_browser": get_ifc_class,
"constr_type_browser": get_constr_type_browser
}
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):
@@ -62,40 +62,40 @@ class BimTool(WorkSpaceTool):
row.label(text="No IFC Project", icon="ERROR")
return
constr_classes = AuthoringData.data["constr_classes"]
ifc_classes = AuthoringData.data["ifc_classes"]
constr_types_ids = AuthoringData.data["constr_types_ids"]
if is_tool_header:
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.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 = 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:
row.label(text="", icon="BLANK1")
row = layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
row.label(text="", icon="EVENT_A")
if constr_classes:
if ifc_classes:
row.label(text=f" Add")
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=f"{constr_type} ")
else:
row.label(text=f" Add instance")
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"
row = layout.row(align=True)
row.label(text="Selected Construction Type:")
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.label(text=txt_constr_type, icon="FILE_3D")
row = layout.row(align=True)
@@ -103,8 +103,8 @@ class BimTool(WorkSpaceTool):
row.label(text="", icon="EVENT_A")
row.label(text=f" Add Type Instance")
if AuthoringData.data["constr_classes"]:
if constr_class == "IfcWallType":
if AuthoringData.data["ifc_classes"]:
if ifc_class == "IfcWallType":
row = layout.row()
row.label(text="Join")
row = layout.row(align=True)
@@ -126,7 +126,7 @@ class BimTool(WorkSpaceTool):
row.label(text="", icon="EVENT_SHIFT")
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.label(text="Join")
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_class" to "IfcWallType"
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 I set "scene.BIMModelProperties.constr_type_id" to "{cube}"
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_class" to "IfcWallType"
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 I set "scene.BIMModelProperties.constr_type_id" to "{cube}"
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_class" to "IfcWallType"
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 I set "scene.BIMModelProperties.constr_type_id" to "{cube}"
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_class" to "IfcWallType"
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 I set "scene.BIMModelProperties.constr_type_id" to "{cube}"
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_class" to "IfcWallType"
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 I set "scene.BIMModelProperties.constr_type_id" to "{empty}"
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_class" to "IfcWallType"
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 I set "scene.BIMModelProperties.constr_type_id" to "{cube}"
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
When I display 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 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 objects starting with "IfcColumn/" do not exist
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
When I display 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"
Then "scene.BIMModelProperties.constr_class_browser" is "IfcWallType"
And I set "scene.BIMModelProperties.ifc_class_browser" to "IfcWallType"
Then "scene.BIMModelProperties.ifc_class_browser" is "IfcWallType"
And objects starting with "IfcWall/" do not exist
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
When I display 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 add the browser construction type
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
@then(parsers.parse('the construction type "{constr_class}"/"{constr_type}" has a preview'))
def the_construction_type_has_a_preview(constr_class, constr_type):
@then(parsers.parse('the construction type "{ifc_class}"/"{constr_type}" has a preview'))
def the_construction_type_has_a_preview(ifc_class, constr_type):
if "preview_constr_types" not in AuthoringData.data:
assert False, 'There are no previews loaded'
preview_constr_types = AuthoringData.data["preview_constr_types"]
if constr_class not in preview_constr_types:
assert False, f'Construction class {constr_class} has no available previews'
constr_type_id = AuthoringData.constr_type_id_by_name(constr_class, constr_type)
if ifc_class not in preview_constr_types:
assert False, f'Construction class {ifc_class} has no available previews'
constr_type_id = AuthoringData.constr_type_id_by_name(ifc_class, constr_type)
if constr_type_id is None:
assert False, f'No construction type {constr_class}/{constr_type} was found'
if constr_type_id not in preview_constr_types[constr_class]:
assert False, f'Construction type {constr_class}/{constr_type} has no available previews'
preview_data = preview_constr_types[constr_class][constr_type_id]
assert False, f'No construction type {ifc_class}/{constr_type} was found'
if constr_type_id not in preview_constr_types[ifc_class]:
assert False, f'Construction type {ifc_class}/{constr_type} has no available previews'
preview_data = preview_constr_types[ifc_class][constr_type_id]
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"]
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
# 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
@@ -605,16 +605,16 @@ def there_is_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'))
def all_construction_types_have_a_preview(constr_class):
@then(parsers.parse('all construction types for "{ifc_class}" have a preview'))
def all_construction_types_have_a_preview(ifc_class):
if "preview_constr_types" not in AuthoringData.data:
assert False, 'There are no previews loaded'
preview_constr_types = AuthoringData.data["preview_constr_types"]
if constr_class not in preview_constr_types:
assert False, f'Construction class {constr_class} has no available previews'
constr_class_occurrences = AuthoringData.constr_class_entities(constr_class)
if ifc_class not in preview_constr_types:
assert False, f'Construction class {ifc_class} has no available previews'
constr_class_occurrences = AuthoringData.constr_class_entities(ifc_class)
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")
@@ -647,7 +647,7 @@ def i_preview_all_construction_types():
def i_select_the_active_construction_type():
props = bpy.context.scene.BIMModelProperties
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():
props = bpy.context.scene.BIMModelProperties
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}"))
def browser_construction_type(constr_type_name):
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 " +
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}"))
def construction_type(constr_type_name):
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}"