diff --git a/src/blenderbim/blenderbim/bim/module/model/data.py b/src/blenderbim/blenderbim/bim/module/model/data.py index d5298bded5..b8d74ecf54 100644 --- a/src/blenderbim/blenderbim/bim/module/model/data.py +++ b/src/blenderbim/blenderbim/bim/module/model/data.py @@ -41,8 +41,8 @@ class AuthoringData: cls.data = {} cls.props = bpy.context.scene.BIMModelProperties cls.load_ifc_classes() - cls.load_constr_types() - cls.load_constr_types_browser() + cls.load_relating_types() + cls.load_relating_types_browser() cls.load_preview_constr_types() @classmethod @@ -50,12 +50,12 @@ class AuthoringData: cls.data["ifc_classes"] = cls.ifc_classes() @classmethod - def load_constr_types(cls): - cls.data["constr_types_ids"] = cls.constr_types() + def load_relating_types(cls): + cls.data["relating_types_ids"] = cls.relating_types() @classmethod - def load_constr_types_browser(cls): - cls.data["constr_types_ids_browser"] = cls.constr_types_browser() + def load_relating_types_browser(cls): + cls.data["relating_types_ids_browser"] = cls.relating_types_browser() @classmethod def load_preview_constr_types(cls): @@ -90,27 +90,27 @@ class AuthoringData: return [] @classmethod - def constr_types(cls, ifc_class=None): + def relating_types(cls, ifc_class=None): return [ (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(ifc_class=cls.props.ifc_class_browser) + def relating_types_browser(cls): + return cls.relating_types(ifc_class=cls.props.ifc_class_browser) @staticmethod - def new_constr_type_info(ifc_class): - constr_type_info = bpy.context.scene.ConstrTypeInfo.add() - constr_type_info.name = ifc_class - return constr_type_info + def new_relating_type_info(ifc_class): + relating_type_info = bpy.context.scene.ConstrTypeInfo.add() + relating_type_info.name = ifc_class + return relating_type_info @classmethod 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 + relating_type_info = cls.relating_type_info(ifc_class) + _ = cls.new_relating_type_info(ifc_class) if relating_type_info is None else relating_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: @@ -120,18 +120,18 @@ class AuthoringData: 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, ifc_class, constr_class_entity) - constr_type_info = cls.constr_type_info(ifc_class) - constr_type_info.fully_loaded = True + relating_type_info = cls.relating_type_info(ifc_class) + relating_type_info.fully_loaded = True @classmethod def assetize_object(cls, obj, ifc_class, ifc_class_entity, from_selection=False): - constr_type_id = ifc_class_entity.id() + relating_type_id = ifc_class_entity.id() to_be_deleted = False if obj.type == 'EMPTY': kwargs = {} if not from_selection: - kwargs.update({'ifc_class': ifc_class, 'constr_type_id': constr_type_id}) - new_obj = cls.new_constr_type(**kwargs) + kwargs.update({'ifc_class': ifc_class, 'relating_type_id': relating_type_id}) + new_obj = cls.new_relating_type(**kwargs) if new_obj is not None: to_be_deleted = True obj = new_obj @@ -140,18 +140,18 @@ class AuthoringData: icon_id = obj.preview.icon_id 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} + cls.data["preview_constr_types"][ifc_class][str(relating_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): + def assetize_relating_type_from_selection(cls): ifc_class_browser = cls.props.ifc_class_browser - constr_type_id_browser = cls.props.constr_type_id_browser + relating_type_id_browser = cls.props.relating_type_id_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) + entity for entity in constr_class_occurrences if entity.id() == int(relating_type_id_browser) ] if len(constr_class_occurrences) == 0: return False @@ -163,42 +163,42 @@ class AuthoringData: return True @staticmethod - 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] + def relating_type_info(ifc_class): + relating_type_infos = [element for element in bpy.context.scene.ConstrTypeInfo if element.name == ifc_class] + return None if len(relating_type_infos) == 0 else relating_type_infos[0] @classmethod - def new_constr_type(cls, ifc_class=None, constr_type_id=None): + def new_relating_type(cls, ifc_class=None, relating_type_id=None): if ifc_class is None: - bpy.ops.bim.add_constr_type( - ifc_class=cls.props.ifc_class_browser, constr_type_id=int(cls.props.constr_type_id_browser) + bpy.ops.bim.add_relating_type( + ifc_class=cls.props.ifc_class_browser, relating_type_id=int(cls.props.relating_type_id_browser) ) else: cls.props.ifc_class = ifc_class - cls.props.constr_type_id = str(constr_type_id) - bpy.ops.bim.add_constr_type() + cls.props.relating_type_id = str(relating_type_id) + bpy.ops.bim.add_relating_type() return bpy.context.selected_objects[-1] @staticmethod - def constr_type_name_by_id(ifc_class, constr_type_id): + def relating_type_name_by_id(ifc_class, relating_type_id): file = IfcStore.get_file() try: - constr_class_entity = file.by_id(int(constr_type_id)) + constr_class_entity = file.by_id(int(relating_type_id)) except (RuntimeError, ValueError): return None return constr_class_entity.Name if constr_class_entity.is_a() == ifc_class else None @classmethod - 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] + def relating_type_id_by_name(cls, ifc_class, relating_type): + relating_types = [ct[0] for ct in cls.relating_types(ifc_class=ifc_class) if ct[1] == relating_type] + return None if len(relating_types) == 0 else relating_types[0] @classmethod - def consolidate_constr_type(cls): + def consolidate_relating_type(cls): cls.props.ifc_class = cls.props.ifc_class_browser - cls.props.constr_type_id = cls.props.constr_type_id_browser + cls.props.relating_type_id = cls.props.relating_type_id_browser @classmethod - def setup_constr_type_browser(cls): + def setup_relating_type_browser(cls): cls.props.ifc_class_browser = cls.props.ifc_class - cls.props.constr_type_id_browser = cls.props.constr_type_id + cls.props.relating_type_id_browser = cls.props.relating_type_id diff --git a/src/blenderbim/blenderbim/bim/module/model/product.py b/src/blenderbim/blenderbim/bim/module/model/product.py index 5833e08731..bc70dd2ebb 100644 --- a/src/blenderbim/blenderbim/bim/module/model/product.py +++ b/src/blenderbim/blenderbim/bim/module/model/product.py @@ -58,12 +58,12 @@ def add_empty_type_button(self, context): class AddConstrType(bpy.types.Operator): - bl_idname = "bim.add_constr_type" + bl_idname = "bim.add_relating_type" bl_label = "Add" bl_options = {"REGISTER", "UNDO"} bl_description = "Add Type Instance to the model" ifc_class: bpy.props.StringProperty() - constr_type_id: bpy.props.IntProperty() + relating_type_id: bpy.props.IntProperty() from_invoke: bpy.props.BoolProperty(default=False) def invoke(self, context, event): @@ -77,28 +77,28 @@ class AddConstrType(bpy.types.Operator): def _execute(self, context): props = context.scene.BIMModelProperties ifc_class = self.ifc_class or props.ifc_class - constr_type_id = self.constr_type_id or props.constr_type_id + relating_type_id = self.relating_type_id or props.relating_type_id - if not ifc_class or not constr_type_id: + if not ifc_class or not relating_type_id: return {"FINISHED"} if self.from_invoke: props.ifc_class = self.ifc_class - props.constr_type_id = str(self.constr_type_id) + props.relating_type_id = str(self.relating_type_id) self.file = IfcStore.get_file() 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) + relating_type = self.file.by_id(int(relating_type_id)) + material = ifcopenshell.util.element.get_material(relating_type) if material and material.is_a("IfcMaterialProfileSet"): - if profile.DumbProfileGenerator(constr_type).generate(): + if profile.DumbProfileGenerator(relating_type).generate(): return {"FINISHED"} elif material and material.is_a("IfcMaterialLayerSet"): - if self.generate_layered_element(ifc_class, constr_type): + if self.generate_layered_element(ifc_class, relating_type): return {"FINISHED"} - if constr_type.is_a("IfcFlowSegmentType") and not constr_type.RepresentationMaps: - if mep.MepGenerator(constr_type).generate(): + if relating_type.is_a("IfcFlowSegmentType") and not relating_type.RepresentationMaps: + if mep.MepGenerator(relating_type).generate(): return {"FINISHED"} building_obj = None @@ -127,14 +127,14 @@ class AddConstrType(bpy.types.Operator): ] mesh = bpy.data.meshes.new(name="Instance") mesh.from_pydata(verts, edges, faces) - obj = bpy.data.objects.new(tool.Model.generate_occurrence_name(constr_type, instance_class), mesh) + obj = bpy.data.objects.new(tool.Model.generate_occurrence_name(relating_type, instance_class), mesh) obj.location = context.scene.cursor.location collection = context.view_layer.active_layer_collection.collection collection.objects.link(obj) collection_obj = bpy.data.objects.get(collection.name) bpy.ops.bim.assign_class(obj=obj.name, ifc_class=instance_class) element = tool.Ifc.get_entity(obj) - blenderbim.core.type.assign_type(tool.Ifc, tool.Type, element=element, type=constr_type) + blenderbim.core.type.assign_type(tool.Ifc, tool.Type, element=element, type=relating_type) if building_obj: if instance_class in ["IfcWindow", "IfcDoor"]: @@ -149,7 +149,7 @@ class AddConstrType(bpy.types.Operator): obj.location[2] = collection_obj.location[2] - min([v[2] for v in obj.bound_box]) unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) - for port in ifcopenshell.util.system.get_ports(constr_type): + for port in ifcopenshell.util.system.get_ports(relating_type): mat = ifcopenshell.util.placement.get_local_placement(port.ObjectPlacement) mat[0][3] *= unit_scale mat[1][3] *= unit_scale @@ -188,7 +188,7 @@ class AddConstrType(bpy.types.Operator): class DisplayConstrTypes(bpy.types.Operator): - bl_idname = "bim.display_constr_types" + bl_idname = "bim.display_relating_types" bl_label = "Browse Construction Types" bl_options = {"REGISTER", "UNDO"} bl_description = "Display all available Construction Types to add new instances" @@ -199,15 +199,15 @@ class DisplayConstrTypes(bpy.types.Operator): def invoke(self, context, event): if not AuthoringData.is_loaded: AuthoringData.load() - AuthoringData.setup_constr_type_browser() + AuthoringData.setup_relating_type_browser() props = context.scene.BIMModelProperties - if props.unfold_constr_types: + if props.unfold_relating_types: 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: + relating_type_info = AuthoringData.relating_type_info(ifc_class) + if relating_type_info is None or not relating_type_info.fully_loaded: AuthoringData.assetize_constr_class(ifc_class) else: - prop.update_constr_type_browser(props, context) + prop.update_relating_type_browser(props, context) min_width = 250 width_scaling = 5 ** -1 width = max([min_width, int(width_scaling * context.region.width)]) @@ -216,7 +216,7 @@ class DisplayConstrTypes(bpy.types.Operator): def draw(self, context): props = context.scene.BIMModelProperties header_data = self.draw_header(props) - if props.unfold_constr_types: + if props.unfold_relating_types: self.draw_by_ifc_class(props, header_data) else: self.draw_by_ifc_class_and_type(props, header_data) @@ -228,7 +228,7 @@ class DisplayConstrTypes(bpy.types.Operator): split = inner_layout.split(align=True, factor=2./3) col1 = split.column(align=True) row = col1.row() - row.prop(data=props, property="unfold_constr_types", text="Preview All Construction Types") + row.prop(data=props, property="unfold_relating_types", text="Preview All Construction Types") col1.row().separator(factor=1) row = col1.row() row.label(text="Select Construction Type:") @@ -244,7 +244,7 @@ class DisplayConstrTypes(bpy.types.Operator): col2 = split.column(align=True) subsplit = col2.split(factor=0.9) subcol = [subsplit.column() for _ in range(2)][-1] - subcol.operator("bim.help_constr_types", text="", icon="QUESTION") + subcol.operator("bim.help_relating_types", text="", icon="QUESTION") col2.row().separator(factor=1) return {"enabled": enabled, "layout": inner_layout, "col1": col1, "col2": col2} @@ -256,9 +256,9 @@ class DisplayConstrTypes(bpy.types.Operator): layout.row().label(text="Construction Types:", icon="FILE_3D") layout.row().separator(factor=0.25) flow = layout.grid_flow(row_major=True, columns=num_cols, even_columns=True, even_rows=True, align=True) - constr_types_browser = AuthoringData.constr_types_browser() - num_types = len(constr_types_browser) - for idx, (constr_type_id_browser, name, desc) in enumerate(constr_types_browser): + relating_types_browser = AuthoringData.relating_types_browser() + num_types = len(relating_types_browser) + for idx, (relating_type_id_browser, name, desc) in enumerate(relating_types_browser): outer_col = flow.column() box = outer_col.box() row = box.row() @@ -269,8 +269,8 @@ class DisplayConstrTypes(bpy.types.Operator): preview_constr_types = AuthoringData.data["preview_constr_types"] 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"] + if relating_type_id_browser in preview_ifc_class: + icon_id = preview_ifc_class[relating_type_id_browser]["icon_id"] row.template_icon(icon_value=icon_id, scale=6.) box.row().separator(factor=0.2) row = box.row() @@ -278,13 +278,13 @@ class DisplayConstrTypes(bpy.types.Operator): col = split.column() op = col.operator("bim.select_construction_type", icon="RIGHTARROW_THIN") op.ifc_class = ifc_class_browser - op.constr_type_id = constr_type_id_browser + op.relating_type_id = relating_type_id_browser col = split.column() - op = col.operator("bim.add_constr_type", icon="ADD") + op = col.operator("bim.add_relating_type", icon="ADD") op.from_invoke = True op.ifc_class = ifc_class_browser - if constr_type_id_browser.isnumeric(): - op.constr_type_id = int(constr_type_id_browser) + if relating_type_id_browser.isnumeric(): + op.relating_type_id = int(relating_type_id_browser) factor = 2 if idx + 1 < math.ceil(num_types / num_cols) else 1.5 outer_col.row().separator(factor=factor) last_row_cols = num_types % num_cols @@ -295,11 +295,11 @@ class DisplayConstrTypes(bpy.types.Operator): def draw_by_ifc_class_and_type(self, props, header_data): enabled, col1, col2 = [header_data[key] for key in ["enabled", "col1", "col2"]] ifc_class_browser = props.ifc_class_browser - constr_type_id_browser = props.constr_type_id_browser - if AuthoringData.data["constr_types_ids_browser"]: + relating_type_id_browser = props.relating_type_id_browser + if AuthoringData.data["relating_types_ids_browser"]: subsplit = col1.split(factor=1. / 3) subsplit.column().row().label(text="Construction Type:", icon="FILE_3D") - prop_with_search(subsplit.column(), props, "constr_type_id_browser", text="") + prop_with_search(subsplit.column(), props, "relating_type_id_browser", text="") col1.row().separator() else: enabled = False @@ -308,12 +308,12 @@ class DisplayConstrTypes(bpy.types.Operator): row.enabled = enabled op = row.operator("bim.select_construction_type", icon="RIGHTARROW_THIN") op.ifc_class = ifc_class_browser - op.constr_type_id = constr_type_id_browser - op = row.operator("bim.add_constr_type", icon="ADD") + op.relating_type_id = relating_type_id_browser + op = row.operator("bim.add_relating_type", icon="ADD") op.from_invoke = True op.ifc_class = ifc_class_browser - if constr_type_id_browser.isnumeric(): - op.constr_type_id = int(constr_type_id_browser) + if relating_type_id_browser.isnumeric(): + op.relating_type_id = int(relating_type_id_browser) col2.row().separator(factor=1.25) split = col2.split(factor=0.025) col = [split.column() for _ in range(2)][-1] @@ -329,7 +329,7 @@ class SelectConstructionType(bpy.types.Operator): bl_options = {"REGISTER", "UNDO"} bl_description = "Pick Type Instance as selection for subsequent operations" ifc_class: bpy.props.StringProperty() - constr_type_id: bpy.props.StringProperty() + relating_type_id: bpy.props.StringProperty() def invoke(self, context, event): close_operator_panel(event) @@ -339,14 +339,14 @@ class SelectConstructionType(bpy.types.Operator): props = context.scene.BIMModelProperties 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 + AuthoringData.load_relating_types() + if self.relating_type_id != "": + props.relating_type_id = self.relating_type_id return {"FINISHED"} class HelpConstrTypes(bpy.types.Operator): - bl_idname = "bim.help_constr_types" + bl_idname = "bim.help_relating_types" bl_label = "Construction Types Help" bl_options = {"REGISTER", "UNDO"} bl_description = "Click to read some contextual help" diff --git a/src/blenderbim/blenderbim/bim/module/model/prop.py b/src/blenderbim/blenderbim/bim/module/model/prop.py index f65a3cfe1d..9d6b7b3794 100644 --- a/src/blenderbim/blenderbim/bim/module/model/prop.py +++ b/src/blenderbim/blenderbim/bim/module/model/prop.py @@ -27,75 +27,75 @@ def get_ifc_class(self, context): return AuthoringData.data["ifc_classes"] -def get_constr_type(self, context): +def get_relating_type(self, context): if not AuthoringData.is_loaded: AuthoringData.load() - return AuthoringData.data["constr_types_ids"] + return AuthoringData.data["relating_types_ids"] -def get_constr_type_browser(self, context): +def get_relating_type_browser(self, context): if not AuthoringData.is_loaded: AuthoringData.load() - return AuthoringData.data["constr_types_ids_browser"] + return AuthoringData.data["relating_types_ids_browser"] def update_icon_id(self, context): 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(ifc_class_browser, constr_type_id_browser) + relating_type_id_browser = self.relating_type_id_browser + relating_type_browser = AuthoringData.relating_type_name_by_id(ifc_class_browser, relating_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(): + or relating_type_id_browser not in AuthoringData.data["preview_constr_types"][ifc_class_browser]) + and relating_type_browser is not None): + if not AuthoringData.assetize_relating_type_from_selection(): return - self.icon_id = AuthoringData.data["preview_constr_types"][ifc_class_browser][constr_type_id_browser]["icon_id"] + self.icon_id = AuthoringData.data["preview_constr_types"][ifc_class_browser][relating_type_id_browser]["icon_id"] 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] + AuthoringData.load_relating_types() + self.relating_type_id = AuthoringData.data["relating_types_ids"][0][0] def update_ifc_class_browser(self, context): AuthoringData.load_ifc_classes() - AuthoringData.load_constr_types_browser() + AuthoringData.load_relating_types_browser() props = context.scene.BIMModelProperties - if props.unfold_constr_types: + if props.unfold_relating_types: 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.ifc_class, props.constr_type_id + relating_type_info = AuthoringData.relating_type_info(ifc_class_browser) + if relating_type_info is None or not relating_type_info.fully_loaded: + curr_selection = props.ifc_class, props.relating_type_id AuthoringData.assetize_constr_class(ifc_class_browser) - props.ifc_class, props.constr_type_id = curr_selection + props.ifc_class, props.relating_type_id = curr_selection else: - self.constr_type_id_browser = AuthoringData.data["constr_types_ids_browser"][0][0] + self.relating_type_id_browser = AuthoringData.data["relating_types_ids_browser"][0][0] -def update_constr_type(self, context): - AuthoringData.load_constr_types() +def update_relating_type(self, context): + AuthoringData.load_relating_types() -def update_constr_type_by_name(self, context): - AuthoringData.load_constr_types() - 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_relating_type_by_name(self, context): + AuthoringData.load_relating_types() + relating_type_id = AuthoringData.relating_type_id_by_name(self.ifc_class, self.relating_type) + if relating_type_id is not None: + self.relating_type_id = relating_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.ifc_class_browser, self.constr_type_browser) - if constr_type_id_browser is not None: - self.constr_type_id_browser = constr_type_id_browser +def update_relating_type_browser_by_name(self, context): + AuthoringData.load_relating_types_browser() + relating_type_id_browser = AuthoringData.relating_type_id_by_name(self.ifc_class_browser, self.relating_type_browser) + if relating_type_id_browser is not None: + self.relating_type_id_browser = relating_type_id_browser -def update_constr_type_browser(self, context): - AuthoringData.load_constr_types_browser() +def update_relating_type_browser(self, context): + AuthoringData.load_relating_types_browser() update_icon_id(self, context) -def update_unfold_constr_type(self, context): +def update_unfold_relating_type(self, context): update_ifc_class_browser(self, context) @@ -104,16 +104,16 @@ class BIMModelProperties(PropertyGroup): 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( - items=get_constr_type, name="Construction Type", update=update_constr_type + relating_type: bpy.props.StringProperty(update=update_relating_type_by_name) + relating_type_id: bpy.props.EnumProperty( + items=get_relating_type, name="Construction Type", update=update_relating_type ) - constr_type_browser: bpy.props.StringProperty(update=update_constr_type_browser_by_name) - constr_type_id_browser: bpy.props.EnumProperty( - items=get_constr_type_browser, name="Construction Type", update=update_constr_type_browser + relating_type_browser: bpy.props.StringProperty(update=update_relating_type_browser_by_name) + relating_type_id_browser: bpy.props.EnumProperty( + items=get_relating_type_browser, name="Construction Type", update=update_relating_type_browser ) icon_id: bpy.props.IntProperty() - unfold_constr_types: bpy.props.BoolProperty(update=update_unfold_constr_type) + unfold_relating_types: bpy.props.BoolProperty(update=update_unfold_relating_type) occurrence_name_style: bpy.props.EnumProperty( items=[("CLASS", "By Class", ""), ("TYPE", "By Type", ""), ("CUSTOM", "Custom", "")], name="Occurrence Name Style", @@ -121,18 +121,18 @@ class BIMModelProperties(PropertyGroup): occurrence_name_function: bpy.props.StringProperty(name="Occurrence Name Function") getter_enum = { "ifc_class_browser": get_ifc_class, - "constr_type_browser": get_constr_type_browser + "relating_type_browser": get_relating_type_browser } -def get_constr_type_info(self, context): +def get_relating_type_info(self, context): return AuthoringData.relating_types(ifc_class=self.name) class ConstrTypeInfo(PropertyGroup): name: bpy.props.StringProperty(name="Construction class") - constr_type: bpy.props.EnumProperty( - name="Construction type", items=get_constr_type_info + relating_type: bpy.props.EnumProperty( + name="Construction type", items=get_relating_type_info ) fully_loaded: bpy.props.BoolProperty(default=False) diff --git a/src/blenderbim/blenderbim/bim/module/model/workspace.py b/src/blenderbim/blenderbim/bim/module/model/workspace.py index 8828d40e7a..d2f5d939cd 100644 --- a/src/blenderbim/blenderbim/bim/module/model/workspace.py +++ b/src/blenderbim/blenderbim/bim/module/model/workspace.py @@ -63,18 +63,18 @@ class BimTool(WorkSpaceTool): return ifc_classes = AuthoringData.data["ifc_classes"] - constr_types_ids = AuthoringData.data["constr_types_ids"] + relating_types_ids = AuthoringData.data["relating_types_ids"] if is_tool_header: - row.operator("bim.help_constr_types", text="", icon="QUESTION") + row.operator("bim.help_relating_types", text="", icon="QUESTION") if ifc_classes and is_tool_header: row.label(text="", icon="BLANK1") - row.operator("bim.display_constr_types", icon="COLLAPSEMENU") + row.operator("bim.display_relating_types", icon="COLLAPSEMENU") ifc_class = props.ifc_class - constr_type_id = props.constr_type_id - constr_type = AuthoringData.constr_type_name_by_id(ifc_class, constr_type_id) + relating_type_id = props.relating_type_id + relating_type = AuthoringData.relating_type_name_by_id(ifc_class, relating_type_id) if is_tool_header: row.label(text="", icon="BLANK1") @@ -86,18 +86,18 @@ class BimTool(WorkSpaceTool): row.label(text="", icon="FILE_VOLUME") row.label(text=ifc_class) row.label(text="", icon="FILE_3D") - row.label(text=f"{constr_type} ") + row.label(text=f"{relating_type} ") else: row.label(text=f" Add instance") else: 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_relating_type = relating_type if relating_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_ifc_class, icon="FILE_VOLUME") row = layout.row(align=True) - row.label(text=txt_constr_type, icon="FILE_3D") + row.label(text=txt_relating_type, icon="FILE_3D") row = layout.row(align=True) row.label(text="", icon="EVENT_SHIFT") row.label(text="", icon="EVENT_A") @@ -184,7 +184,7 @@ class Hotkey(bpy.types.Operator): return {"FINISHED"} def hotkey_S_A(self): - bpy.ops.bim.add_constr_type() + bpy.ops.bim.add_relating_type() def hotkey_S_C(self): if self.has_ifc_class and self.props.ifc_class == "IfcWallType": diff --git a/src/blenderbim/blenderbim/bim/module/type/ui.py b/src/blenderbim/blenderbim/bim/module/type/ui.py index 04178e7ebb..70e1006096 100644 --- a/src/blenderbim/blenderbim/bim/module/type/ui.py +++ b/src/blenderbim/blenderbim/bim/module/type/ui.py @@ -88,4 +88,4 @@ class BIM_PT_type(Panel): def add_object_button(self, context): - self.layout.operator("bim.add_constr_type", icon="PLUGIN") + self.layout.operator("bim.add_relating_type", icon="PLUGIN") diff --git a/src/blenderbim/test/bim/feature/geometry.feature b/src/blenderbim/test/bim/feature/geometry.feature index 4d79197486..aa42012036 100644 --- a/src/blenderbim/test/bim/feature/geometry.feature +++ b/src/blenderbim/test/bim/feature/geometry.feature @@ -31,8 +31,8 @@ Scenario: Add representation - add a new representation to a typed instance 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 press "bim.add_constr_type" - And I press "bim.add_constr_type" + And I press "bim.add_relating_type" + And I press "bim.add_relating_type" Then the object "IfcWall/Wall" data is a "Tessellation" representation of "Model/Body/MODEL_VIEW" And the object "IfcWall/Wall.001" data is a "Tessellation" representation of "Model/Body/MODEL_VIEW" When the object "IfcWall/Wall" is selected @@ -146,9 +146,9 @@ Scenario: Remove representation - remove an instanced representation from an act And I press "bim.assign_class" 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" - And I press "bim.add_constr_type" + And I set "scene.BIMModelProperties.relating_type_id" to "{cube}" + And I press "bim.add_relating_type" + And I press "bim.add_relating_type" And the object "IfcWallType/Cube" is selected When the variable "representation" is "{ifc}.by_type('IfcWallType')[0].RepresentationMaps[1].MappedRepresentation.id()" And I press "bim.remove_representation(representation_id={representation})" @@ -165,9 +165,9 @@ Scenario: Remove representation - remove an instanced representation from an act And I press "bim.assign_class" 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" - And I press "bim.add_constr_type" + And I set "scene.BIMModelProperties.relating_type_id" to "{cube}" + And I press "bim.add_relating_type" + And I press "bim.add_relating_type" And the object "IfcWall/Wall" is selected When the variable "representation" is "{ifc}.by_type('IfcWall')[0].Representation.Representations[1].id()" And I press "bim.remove_representation(representation_id={representation})" @@ -339,8 +339,8 @@ Scenario: Override duplicate move - copying a type instance with a representatio And I press "bim.assign_class" 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" + And I set "scene.BIMModelProperties.relating_type_id" to "{cube}" + And I press "bim.add_relating_type" And the object "IfcWall/Wall" is selected When I press "object.duplicate_move" Then the object "IfcWall/Wall.001" exists diff --git a/src/blenderbim/test/bim/feature/model.feature b/src/blenderbim/test/bim/feature/model.feature index ce0dc22616..7a44a94bd4 100644 --- a/src/blenderbim/test/bim/feature/model.feature +++ b/src/blenderbim/test/bim/feature/model.feature @@ -10,8 +10,8 @@ Scenario: Add type instance - add from a mesh And I press "bim.assign_class" 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" + And I set "scene.BIMModelProperties.relating_type_id" to "{cube}" + When I press "bim.add_relating_type" Then the object "IfcWall/Wall" exists Scenario: Add type instance - add from an empty @@ -23,8 +23,8 @@ Scenario: Add type instance - add from an empty And I press "bim.assign_class" 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" + And I set "scene.BIMModelProperties.relating_type_id" to "{empty}" + When I press "bim.add_relating_type" Then the object "IfcWall/Wall" exists Scenario: Add type instance - add a mesh where existing instances have changed context @@ -36,15 +36,15 @@ Scenario: Add type instance - add a mesh where existing instances have changed c And I press "bim.assign_class" 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" + And I set "scene.BIMModelProperties.relating_type_id" to "{cube}" + And I press "bim.add_relating_type" And the object "IfcWall/Wall" data is a "Tessellation" representation of "Model/Body/MODEL_VIEW" And the object "IfcWall/Wall" is selected And the variable "context" is "[c for c in {ifc}.by_type('IfcGeometricRepresentationSubContext') if c.TargetView == 'PLAN_VIEW'][0].id()" And I set "scene.BIMRootProperties.contexts" to "{context}" And I press "bim.add_representation" And the object "IfcWall/Wall" data is a "Annotation2D" representation of "Plan/Annotation/PLAN_VIEW" - When I press "bim.add_constr_type" + When I press "bim.add_relating_type" Then the object "IfcWall/Wall" data is a "Annotation2D" representation of "Plan/Annotation/PLAN_VIEW" And the object "IfcWall/Wall.001" data is a "Annotation2D" representation of "Plan/Annotation/PLAN_VIEW" @@ -54,7 +54,7 @@ Scenario: Preview one type on the Construction Type Browser When I display the construction type browser And I preview only one asset on the construction type browser 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.relating_type_browser" to "DEMO2" And I select the browser construction type Then "scene.BIMModelProperties.ifc_class" is "IfcColumnType" And construction type is DEMO2 @@ -77,7 +77,7 @@ Scenario: Add one type from the Construction Type Browser When I display the construction type browser And I preview only one asset on the construction type browser 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.relating_type_browser" to "DEMO2" And I add the browser construction type Then the object "IfcColumn/Column" exists diff --git a/src/blenderbim/test/bim/test_feature.py b/src/blenderbim/test/bim/test_feature.py index d5927207ed..67382b5f1a 100644 --- a/src/blenderbim/test/bim/test_feature.py +++ b/src/blenderbim/test/bim/test_feature.py @@ -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 "{ifc_class}"/"{constr_type}" has a preview')) -def the_construction_type_has_a_preview(ifc_class, constr_type): +@then(parsers.parse('the construction type "{ifc_class}"/"{relating_type}" has a preview')) +def the_construction_type_has_a_preview(ifc_class, relating_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 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 {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] + relating_type_id = AuthoringData.relating_type_id_by_name(ifc_class, relating_type) + if relating_type_id is None: + assert False, f'No construction type {ifc_class}/{relating_type} was found' + if relating_type_id not in preview_constr_types[ifc_class]: + assert False, f'Construction type {ifc_class}/{relating_type} has no available previews' + preview_data = preview_constr_types[ifc_class][relating_type_id] if 'icon_id' not in preview_data: - assert False, f'Construction type {ifc_class}/{constr_type} has a preview, but no assigned icon_id' + assert False, f'Construction type {ifc_class}/{relating_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 {ifc_class}/{constr_type} has an invalid icon_id {icon_id}' + assert False, f'Construction type {ifc_class}/{relating_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 {ifc_class}/{constr_type} has the default null value for icon_id' + # assert False, f'Construction type {ifc_class}/{relating_type} has the default null value for icon_id' assert True @@ -627,19 +627,19 @@ def i_add_a_construction_library(): @given("I display the construction type browser") @when("I display the construction type browser") def i_display_the_construction_type_browser(): - bpy.ops.bim.display_constr_types('INVOKE_DEFAULT') + bpy.ops.bim.display_relating_types('INVOKE_DEFAULT') @given("I preview only one asset on the construction type browser") @when("I preview only one asset on the construction type browser") def i_preview_one_construction_type(): - bpy.context.scene.BIMModelProperties.unfold_constr_types = False + bpy.context.scene.BIMModelProperties.unfold_relating_types = False @given("I preview all available assets on the construction type browser") @when("I preview all available assets on the construction type browser") def i_preview_all_construction_types(): - bpy.context.scene.BIMModelProperties.unfold_constr_types = True + bpy.context.scene.BIMModelProperties.unfold_relating_types = True @given("I select the browser construction type") @@ -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( - ifc_class=props.ifc_class_browser, constr_type_id=props.constr_type_id_browser + ifc_class=props.ifc_class_browser, relating_type_id=props.relating_type_id_browser ) @@ -655,24 +655,24 @@ def i_select_the_active_construction_type(): @when("I add the browser construction type") def i_add_the_active_construction_type(): props = bpy.context.scene.BIMModelProperties - bpy.ops.bim.add_constr_type( - ifc_class=props.ifc_class_browser, constr_type_id=int(props.constr_type_id_browser) + bpy.ops.bim.add_relating_type( + ifc_class=props.ifc_class_browser, relating_type_id=int(props.relating_type_id_browser) ) -@then(parsers.parse("browser construction type is {constr_type_name}")) -def browser_construction_type(constr_type_name): +@then(parsers.parse("browser construction type is {relating_type_name}")) +def browser_construction_type(relating_type_name): props = bpy.context.scene.BIMModelProperties - 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}") + relating_type_browser = AuthoringData.relating_type_name_by_id(props.ifc_class_browser, props.relating_type_id_browser) + assert relating_type_browser == relating_type_name, (f"Construction Type is a {relating_type_browser}, not " + + f"a {relating_type_name}") -@then(parsers.parse("construction type is {constr_type_name}")) -def construction_type(constr_type_name): +@then(parsers.parse("construction type is {relating_type_name}")) +def construction_type(relating_type_name): props = bpy.context.scene.BIMModelProperties - 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}" + relating_type = AuthoringData.relating_type_name_by_id(props.ifc_class, props.relating_type_id) + assert relating_type == relating_type_name, f"Construction Type is a {relating_type}, not a {relating_type_name}" @when("I move the cursor to the bottom left corner")