diff --git a/src/blenderbim/blenderbim/bim/module/drawing/operator.py b/src/blenderbim/blenderbim/bim/module/drawing/operator.py index 75b026a49a..b15cfc425d 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/operator.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/operator.py @@ -1070,8 +1070,10 @@ class CopyGrid(bpy.types.Operator): return helper.get_active_drawing(context.scene)[0] is not None def execute(self, context): + drawing = tool.Ifc.get_entity(context.scene.camera) + target_view = tool.Drawing.get_drawing_target_view(drawing) subcontext = ifcopenshell.util.representation.get_context( - IfcStore.get_file(), "Plan", "Annotation", context.scene.camera.data.BIMCameraProperties.target_view + IfcStore.get_file(), "Plan", "Annotation", target_view ) if not subcontext: return {"FINISHED"} @@ -1080,8 +1082,8 @@ class CopyGrid(bpy.types.Operator): view_coll, camera = helper.get_active_drawing(context.scene) is_ortho = camera.data.type == "ORTHO" bounds = helper.ortho_view_frame(camera.data) if is_ortho else None - clipping = is_ortho and camera.data.BIMCameraProperties.target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW") - elevating = is_ortho and camera.data.BIMCameraProperties.target_view in ("ELEVATION_VIEW", "SECTION_VIEW") + clipping = is_ortho and target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW") + elevating = is_ortho and target_view in ("ELEVATION_VIEW", "SECTION_VIEW") def grep(coll): results = [] diff --git a/src/blenderbim/blenderbim/bim/module/drawing/prop.py b/src/blenderbim/blenderbim/bim/module/drawing/prop.py index 31f36cfc3f..6e9dadb80e 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/prop.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/prop.py @@ -199,6 +199,7 @@ class Variable(PropertyGroup): class Drawing(PropertyGroup): ifc_definition_id: IntProperty(name="IFC Definition ID") name: StringProperty(name="Name", update=update_drawing_name) + target_view: StringProperty(name="Target View") class Schedule(PropertyGroup): diff --git a/src/blenderbim/blenderbim/bim/module/drawing/ui.py b/src/blenderbim/blenderbim/bim/module/drawing/ui.py index 43ee18a7c1..c68a76c6aa 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/ui.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/ui.py @@ -369,7 +369,16 @@ class BIM_UL_drawinglist(bpy.types.UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname): if item: row = layout.row(align=True) - row.prop(item, "name", text="", emboss=False) + icon = "UV_FACESEL" + if item.target_view == "ELEVATION_VIEW": + icon = "UV_VERTEXSEL" + elif item.target_view == "SECTION_VIEW": + icon = "UV_EDGESEL" + elif item.target_view == "REFLECTED_PLAN_VIEW": + icon = "XRAY" + elif item.target_view == "MODEL_VIEW": + icon = "SNAP_VOLUME" + row.prop(item, "name", text="", icon=icon, emboss=False) else: layout.label(text="", translate=False) diff --git a/src/blenderbim/blenderbim/core/drawing.py b/src/blenderbim/blenderbim/core/drawing.py index 28a228c1b0..754cf053cd 100644 --- a/src/blenderbim/blenderbim/core/drawing.py +++ b/src/blenderbim/blenderbim/core/drawing.py @@ -99,7 +99,7 @@ def disable_editing_drawings(drawing): def add_drawing(ifc, collector, drawing, target_view=None, location_hint=None): - drawing_name = drawing.ensure_unique_drawing_name("UNTITLED") + drawing_name = drawing.ensure_unique_drawing_name(drawing.generate_drawing_name(target_view, location_hint)) drawing_matrix = drawing.generate_drawing_matrix(target_view, location_hint) camera = drawing.create_camera(drawing_name, drawing_matrix) element = drawing.run_root_assign_class( diff --git a/src/blenderbim/blenderbim/core/tool.py b/src/blenderbim/blenderbim/core/tool.py index e37a93a967..dd50034085 100644 --- a/src/blenderbim/blenderbim/core/tool.py +++ b/src/blenderbim/blenderbim/core/tool.py @@ -172,6 +172,7 @@ class Drawing: def ensure_unique_identification(cls, identification): pass def export_text_literal_attributes(cls, obj): pass def generate_drawing_matrix(cls, target_view, location_hint): pass + def generate_drawing_name(cls, target_view, location_hint): pass def generate_sheet_identification(cls): pass def get_annotation_context(cls, target_view): pass def get_body_context(cls): pass diff --git a/src/blenderbim/blenderbim/tool/drawing.py b/src/blenderbim/blenderbim/tool/drawing.py index 8971e3b2d5..173730e817 100644 --- a/src/blenderbim/blenderbim/tool/drawing.py +++ b/src/blenderbim/blenderbim/tool/drawing.py @@ -260,6 +260,7 @@ class Drawing(blenderbim.core.tool.Drawing): new = bpy.context.scene.DocProperties.drawings.add() new.ifc_definition_id = drawing.id() new.name = drawing.Name or "Unnamed" + new.target_view = cls.get_drawing_target_view(drawing) @classmethod def import_sheets(cls): @@ -349,3 +350,16 @@ class Drawing(blenderbim.core.tool.Drawing): for variable in re.findall("{{.*?}}", value): value = value.replace(variable, selector.get_element_value(product, variable[2:-2]) or "") obj.BIMTextProperties.value = value + + # TODO below this point is highly experimental prototype code with no tests + + @classmethod + def generate_drawing_name(cls, target_view, location_hint): + if target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW") and location_hint: + location = tool.Ifc.get().by_id(location_hint) + if target_view == "REFLECTED_PLAN_VIEW": + target_view = "RCP_VIEW" + return (location.Name or "UNNAMED").upper() + " " + target_view.split("_")[0] + elif target_view in ("SECTION_VIEW", "ELEVATION_VIEW") and location_hint: + return location_hint + " " + target_view.split("_")[0] + return target_view diff --git a/src/blenderbim/test/tool/test_drawing.py b/src/blenderbim/test/tool/test_drawing.py index 7680dfff88..91b96f46dd 100644 --- a/src/blenderbim/test/tool/test_drawing.py +++ b/src/blenderbim/test/tool/test_drawing.py @@ -399,10 +399,13 @@ class TestImportDrawings(NewFile): ifc = ifcopenshell.file() tool.Ifc.set(ifc) drawing = ifc.createIfcAnnotation(Name="FOOBAR", ObjectType="DRAWING") + pset = ifcopenshell.api.run("pset.add_pset", ifc, product=drawing, name="EPset_Drawing") + ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"TargetView": "PLAN_VIEW"}) subject.import_drawings() props = bpy.context.scene.DocProperties assert props.drawings[0].ifc_definition_id == drawing.id() assert props.drawings[0].name == "FOOBAR" + assert props.drawings[0].target_view == "PLAN_VIEW" class TestImportSheets(NewFile):