Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit e68fdb2

Browse files
committed
3d annotations for FALL, SECTION_LEVEL, PLAN_LEVEL IfcOpenShell#3145
Before that commit if you created those types of annotations and then reopened .ifc file (without .blend) then you would lose their z coordinate and therefore would lose their value (because they were created previously as 2d annotations). Now those annotations created as 3d to avoid that problem. I've also added temporary fallback that will turn your existing annotations to 3d next time you edit them.
1 parent ae9372c commit e68fdb2

7 files changed

Lines changed: 26 additions & 8 deletions

File tree

src/blenderbim/blenderbim/bim/module/drawing/workspace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def create_annotation_type(context):
108108
tool.Drawing.ensure_annotation_in_drawing_plane(obj)
109109

110110
drawing = tool.Ifc.get_entity(context.scene.camera)
111-
ifc_context = tool.Drawing.get_annotation_context(tool.Drawing.get_drawing_target_view(drawing))
111+
ifc_context = tool.Drawing.get_annotation_context(tool.Drawing.get_drawing_target_view(drawing), object_type)
112112

113113
element = tool.Drawing.run_root_assign_class(
114114
obj=obj,
@@ -133,7 +133,7 @@ def create_annotation_occurence(context):
133133
drawing = tool.Ifc.get_entity(context.scene.camera)
134134
obj = tool.Drawing.create_annotation_object(drawing, object_type)
135135
obj.name = relating_type.Name
136-
ifc_context = tool.Drawing.get_annotation_context(tool.Drawing.get_drawing_target_view(drawing))
136+
ifc_context = tool.Drawing.get_annotation_context(tool.Drawing.get_drawing_target_view(drawing), object_type)
137137
relating_type_repr = tool.Drawing.get_annotation_representation(relating_type)
138138
element = tool.Drawing.run_root_assign_class(
139139
obj=obj,

src/blenderbim/blenderbim/bim/module/geometry/operator.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ def update_obj_mesh_representation(self, context, obj):
199199
old_representation = self.file.by_id(obj.data.BIMMeshProperties.ifc_definition_id)
200200
context_of_items = old_representation.ContextOfItems
201201

202+
# TODO: remove this code a bit later
203+
# added this as a fallback for easier transition some annotation types to 3d
204+
# if they were create before as 2d
205+
element = tool.Ifc.get_entity(obj)
206+
if tool.Drawing.is_annotation_object_type(element, ("FALL", "SECTION_LEVEL", "PLAN_LEVEL")):
207+
context_of_items = tool.Drawing.get_annotation_context("MODEL_VIEW")
208+
202209
gprop = context.scene.BIMGeoreferenceProperties
203210
coordinate_offset = None
204211
if gprop.has_blender_offset and obj.BIMObjectProperties.blender_offset_type == "CARTESIAN_POINT":

src/blenderbim/blenderbim/core/drawing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,9 @@ def update_drawing_name(ifc, drawing_tool, drawing=None, name=None):
325325

326326

327327
def add_annotation(ifc, collector, drawing_tool, drawing=None, object_type=None):
328-
context = drawing_tool.get_annotation_context(target_view := drawing_tool.get_drawing_target_view(drawing))
328+
context = drawing_tool.get_annotation_context(
329+
target_view := drawing_tool.get_drawing_target_view(drawing), object_type
330+
)
329331
if not context:
330332
return f"No annotation context Annotation/{target_view} for drawing"
331333

src/blenderbim/blenderbim/core/tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def export_text_literal_attributes(cls, obj): pass
269269
def generate_drawing_matrix(cls, target_view, location_hint): pass
270270
def generate_drawing_name(cls, target_view, location_hint): pass
271271
def generate_sheet_identification(cls): pass
272-
def get_annotation_context(cls, target_view): pass
272+
def get_annotation_context(cls, target_view, object_type=None): pass
273273
def get_assigned_product(cls, element): pass
274274
def get_body_context(cls): pass
275275
def get_default_drawing_path(cls, name): pass

src/blenderbim/blenderbim/tool/drawing.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,13 @@ def export_text_literal_attributes(cls, obj):
315315
return literals
316316

317317
@classmethod
318-
def get_annotation_context(cls, target_view):
319-
if target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW"):
318+
def get_annotation_context(cls, target_view, object_type=None):
319+
# checking PLAN target view and annotation type that doesn't require 3d
320+
if target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW") and object_type not in (
321+
"FALL",
322+
"SECTION_LEVEL",
323+
"PLAN_LEVEL",
324+
):
320325
return ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Plan", "Annotation", target_view)
321326
return ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Annotation", target_view)
322327

src/blenderbim/test/core/test_drawing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ class TestAddAnnotation:
429429
def test_run(self, ifc, collector, drawing):
430430
drawing.show_decorations().should_be_called()
431431
drawing.get_drawing_target_view("drawing").should_be_called().will_return("target_view")
432-
drawing.get_annotation_context("target_view").should_be_called().will_return("context")
432+
drawing.get_annotation_context("target_view", "object_type").should_be_called().will_return("context")
433433
drawing.create_annotation_object("drawing", "object_type").should_be_called().will_return("obj")
434434
ifc.get_entity("obj").should_be_called().will_return(None)
435435
drawing.get_ifc_representation_class("object_type").should_be_called().will_return("ifc_representation_class")
@@ -449,5 +449,5 @@ def test_run(self, ifc, collector, drawing):
449449

450450
def test_do_not_add_without_an_annotation_context(self, ifc, collector, drawing):
451451
drawing.get_drawing_target_view("drawing").should_be_called().will_return("target_view")
452-
drawing.get_annotation_context("target_view").should_be_called().will_return(None)
452+
drawing.get_annotation_context("target_view", "object_type").should_be_called().will_return(None)
453453
subject.add_annotation(ifc, collector, drawing, drawing="drawing", object_type="object_type")

src/blenderbim/test/tool/test_drawing.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,13 @@ def test_run(self):
235235
context2 = ifc.createIfcGeometricRepresentationSubContext(
236236
ContextType="Model", ContextIdentifier="Annotation", TargetView="ELEVATION_VIEW"
237237
)
238+
context3 = ifc.createIfcGeometricRepresentationSubContext(
239+
ContextType="Model", ContextIdentifier="Annotation", TargetView="PLAN_VIEW"
240+
)
238241
tool.Ifc.set(ifc)
239242
assert subject.get_annotation_context("PLAN_VIEW") == context
240243
assert subject.get_annotation_context("ELEVATION_VIEW") == context2
244+
assert subject.get_annotation_context("PLAN_VIEW", "FALL") == context3
241245

242246

243247
class TestGetBodyContext(NewFile):

0 commit comments

Comments
 (0)