mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
#1153 New annotation objects have their placement Z in the drawing direction to allow for 2D geometry.
This commit is contained in:
@@ -35,7 +35,7 @@ text { fill: black; stroke: none; }
|
|||||||
.PredefinedType-RADIUS { marker-end: url(#radius-marker-end); }
|
.PredefinedType-RADIUS { marker-end: url(#radius-marker-end); }
|
||||||
.PredefinedType-DIAMETER { marker-start: url(#diameter-marker-start); marker-end: url(#diameter-marker-end); }
|
.PredefinedType-DIAMETER { marker-start: url(#diameter-marker-start); marker-end: url(#diameter-marker-end); }
|
||||||
.PredefinedType-HIDDENLINE { stroke-dasharray: 3, 2; }
|
.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-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-BATTING { marker-start: url(#batting); stroke: none; }
|
||||||
.PredefinedType-SEALANT { fill: url(#crosshatch1); stroke-width: 0.25; }
|
.PredefinedType-SEALANT { fill: url(#crosshatch1); stroke-width: 0.25; }
|
||||||
|
|||||||
@@ -151,10 +151,17 @@ class Annotator:
|
|||||||
return obj
|
return obj
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_annotation_obj(object_type, data_type):
|
def get_annotation_obj(drawing, object_type, data_type):
|
||||||
collection = bpy.context.scene.camera.users_collection[0]
|
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":
|
if object_type == "TEXT":
|
||||||
obj = bpy.data.objects.new(object_type, None)
|
obj = bpy.data.objects.new(object_type, None)
|
||||||
|
obj.matrix_world = matrix_world
|
||||||
collection.objects.link(obj)
|
collection.objects.link(obj)
|
||||||
return obj
|
return obj
|
||||||
elif object_type in ("TEXT_LEADER", "SECTION_LEVEL"):
|
elif object_type in ("TEXT_LEADER", "SECTION_LEVEL"):
|
||||||
@@ -162,6 +169,7 @@ class Annotator:
|
|||||||
data.dimensions = "3D"
|
data.dimensions = "3D"
|
||||||
data.resolution_u = 2
|
data.resolution_u = 2
|
||||||
obj = bpy.data.objects.new(object_type, data)
|
obj = bpy.data.objects.new(object_type, data)
|
||||||
|
obj.matrix_world = matrix_world
|
||||||
collection.objects.link(obj)
|
collection.objects.link(obj)
|
||||||
return obj
|
return obj
|
||||||
if object_type != "ANGLE":
|
if object_type != "ANGLE":
|
||||||
@@ -176,12 +184,14 @@ class Annotator:
|
|||||||
data.dimensions = "3D"
|
data.dimensions = "3D"
|
||||||
data.resolution_u = 2
|
data.resolution_u = 2
|
||||||
obj = bpy.data.objects.new(object_type, data)
|
obj = bpy.data.objects.new(object_type, data)
|
||||||
|
obj.matrix_world = matrix_world
|
||||||
collection.objects.link(obj)
|
collection.objects.link(obj)
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_placeholder_coords():
|
def get_placeholder_coords(camera=None):
|
||||||
camera = bpy.context.scene.camera
|
if not camera:
|
||||||
|
camera = bpy.context.scene.camera
|
||||||
z_offset = camera.matrix_world.to_quaternion() @ Vector((0, 0, -1))
|
z_offset = camera.matrix_world.to_quaternion() @ Vector((0, 0, -1))
|
||||||
if bpy.context.scene.render.resolution_x > bpy.context.scene.render.resolution_y:
|
if bpy.context.scene.render.resolution_x > bpy.context.scene.render.resolution_y:
|
||||||
y = (
|
y = (
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class ObjectMaterialData:
|
|||||||
def type_material(cls):
|
def type_material(cls):
|
||||||
element = tool.Ifc.get_entity(bpy.context.active_object)
|
element = tool.Ifc.get_entity(bpy.context.active_object)
|
||||||
element_type = ifcopenshell.util.element.get_type(element)
|
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)
|
material = ifcopenshell.util.element.get_material(element_type)
|
||||||
if not material:
|
if not material:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ def add_annotation(ifc, collector, drawing_tool, drawing=None, object_type=None)
|
|||||||
if not context:
|
if not context:
|
||||||
return
|
return
|
||||||
drawing_tool.show_decorations()
|
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)
|
element = ifc.get_entity(obj)
|
||||||
if not element:
|
if not element:
|
||||||
element = drawing_tool.run_root_assign_class(
|
element = drawing_tool.run_root_assign_class(
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ class Document:
|
|||||||
|
|
||||||
@interface
|
@interface
|
||||||
class Drawing:
|
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_camera(cls, name, matrix): pass
|
||||||
def create_svg_schedule(cls, schedule): pass
|
def create_svg_schedule(cls, schedule): pass
|
||||||
def create_svg_sheet(cls, document, titleblock): pass
|
def create_svg_sheet(cls, document, titleblock): pass
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import blenderbim.bim.module.drawing.helper as helper
|
|||||||
|
|
||||||
class Drawing(blenderbim.core.tool.Drawing):
|
class Drawing(blenderbim.core.tool.Drawing):
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_annotation_object(cls, object_type):
|
def create_annotation_object(cls, drawing, object_type):
|
||||||
data_type = {
|
data_type = {
|
||||||
"ANGLE": "mesh",
|
"ANGLE": "mesh",
|
||||||
"BREAKLINE": "mesh",
|
"BREAKLINE": "mesh",
|
||||||
@@ -52,7 +52,7 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
"TEXT": "empty",
|
"TEXT": "empty",
|
||||||
"TEXT_LEADER": "curve",
|
"TEXT_LEADER": "curve",
|
||||||
}[object_type]
|
}[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":
|
if object_type == "FILL_AREA":
|
||||||
obj = annotation.Annotator.add_plane_to_annotation(obj)
|
obj = annotation.Annotator.add_plane_to_annotation(obj)
|
||||||
elif object_type != "TEXT":
|
elif object_type != "TEXT":
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ class TestAddAnnotation:
|
|||||||
drawing.show_decorations().should_be_called()
|
drawing.show_decorations().should_be_called()
|
||||||
drawing.get_drawing_target_view("drawing").should_be_called().will_return("target_view")
|
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.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)
|
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.get_ifc_representation_class("object_type").should_be_called().will_return("ifc_representation_class")
|
||||||
drawing.run_root_assign_class(
|
drawing.run_root_assign_class(
|
||||||
|
|||||||
Reference in New Issue
Block a user