#1153 New annotation objects have their placement Z in the drawing direction to allow for 2D geometry.

This commit is contained in:
Dion Moult
2022-05-15 11:45:47 +10:00
parent fdaae048c2
commit 970b24b63b
7 changed files with 21 additions and 11 deletions
@@ -35,7 +35,7 @@ text { fill: black; stroke: none; }
.PredefinedType-RADIUS { marker-end: url(#radius-marker-end); }
.PredefinedType-DIAMETER { marker-start: url(#diameter-marker-start); marker-end: url(#diameter-marker-end); }
.PredefinedType-HIDDENLINE { stroke-dasharray: 3, 2; }
.PredefinedType-STAIR { marker-start: url(#stair-marker-start); marker-end: url(#stair-marker-end); }
.PredefinedType-STAIRARROW { marker-start: url(#stair-marker-start); marker-end: url(#stair-marker-end); }
.PredefinedType-BOUNDARY { fill: none; stroke: red; stroke-width: 1; stroke-dasharray: 12, 4, 3, 4, 3, 4; }
.PredefinedType-BATTING { marker-start: url(#batting); stroke: none; }
.PredefinedType-SEALANT { fill: url(#crosshatch1); stroke-width: 0.25; }
@@ -151,10 +151,17 @@ class Annotator:
return obj
@staticmethod
def get_annotation_obj(object_type, data_type):
collection = bpy.context.scene.camera.users_collection[0]
def get_annotation_obj(drawing, object_type, data_type):
camera = tool.Ifc.get_object(drawing)
co1, _, _, _ = Annotator.get_placeholder_coords(camera)
matrix_world = camera.matrix_world.copy()
matrix_world[0][3] = co1.x
matrix_world[1][3] = co1.y
matrix_world[2][3] = co1.z
collection = camera.users_collection[0]
if object_type == "TEXT":
obj = bpy.data.objects.new(object_type, None)
obj.matrix_world = matrix_world
collection.objects.link(obj)
return obj
elif object_type in ("TEXT_LEADER", "SECTION_LEVEL"):
@@ -162,6 +169,7 @@ class Annotator:
data.dimensions = "3D"
data.resolution_u = 2
obj = bpy.data.objects.new(object_type, data)
obj.matrix_world = matrix_world
collection.objects.link(obj)
return obj
if object_type != "ANGLE":
@@ -176,12 +184,14 @@ class Annotator:
data.dimensions = "3D"
data.resolution_u = 2
obj = bpy.data.objects.new(object_type, data)
obj.matrix_world = matrix_world
collection.objects.link(obj)
return obj
@staticmethod
def get_placeholder_coords():
camera = bpy.context.scene.camera
def get_placeholder_coords(camera=None):
if not camera:
camera = bpy.context.scene.camera
z_offset = camera.matrix_world.to_quaternion() @ Vector((0, 0, -1))
if bpy.context.scene.render.resolution_x > bpy.context.scene.render.resolution_y:
y = (
@@ -90,7 +90,7 @@ class ObjectMaterialData:
def type_material(cls):
element = tool.Ifc.get_entity(bpy.context.active_object)
element_type = ifcopenshell.util.element.get_type(element)
if element_type != element:
if element_type and element_type != element:
material = ifcopenshell.util.element.get_material(element_type)
if not material:
return
+1 -1
View File
@@ -192,7 +192,7 @@ def add_annotation(ifc, collector, drawing_tool, drawing=None, object_type=None)
if not context:
return
drawing_tool.show_decorations()
obj = drawing_tool.create_annotation_object(object_type)
obj = drawing_tool.create_annotation_object(drawing, object_type)
element = ifc.get_entity(obj)
if not element:
element = drawing_tool.run_root_assign_class(
+1 -1
View File
@@ -154,7 +154,7 @@ class Document:
@interface
class Drawing:
def create_annotation_object(cls, object_type): pass
def create_annotation_object(cls, drawing, object_type): pass
def create_camera(cls, name, matrix): pass
def create_svg_schedule(cls, schedule): pass
def create_svg_sheet(cls, document, titleblock): pass
+2 -2
View File
@@ -36,7 +36,7 @@ import blenderbim.bim.module.drawing.helper as helper
class Drawing(blenderbim.core.tool.Drawing):
@classmethod
def create_annotation_object(cls, object_type):
def create_annotation_object(cls, drawing, object_type):
data_type = {
"ANGLE": "mesh",
"BREAKLINE": "mesh",
@@ -52,7 +52,7 @@ class Drawing(blenderbim.core.tool.Drawing):
"TEXT": "empty",
"TEXT_LEADER": "curve",
}[object_type]
obj = annotation.Annotator.get_annotation_obj(object_type, data_type)
obj = annotation.Annotator.get_annotation_obj(drawing, object_type, data_type)
if object_type == "FILL_AREA":
obj = annotation.Annotator.add_plane_to_annotation(obj)
elif object_type != "TEXT":
+1 -1
View File
@@ -281,7 +281,7 @@ class TestAddAnnotation:
drawing.show_decorations().should_be_called()
drawing.get_drawing_target_view("drawing").should_be_called().will_return("target_view")
drawing.get_annotation_context("target_view").should_be_called().will_return("context")
drawing.create_annotation_object("object_type").should_be_called().will_return("obj")
drawing.create_annotation_object("drawing", "object_type").should_be_called().will_return("obj")
ifc.get_entity("obj").should_be_called().will_return(None)
drawing.get_ifc_representation_class("object_type").should_be_called().will_return("ifc_representation_class")
drawing.run_root_assign_class(