mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
#1153. Add support for elevation symbols in generated SVGs.
This commit is contained in:
@@ -5,6 +5,13 @@
|
|||||||
</g>
|
</g>
|
||||||
<g id="door-tag">
|
<g id="door-tag">
|
||||||
<circle cy="1.75" r="5" fill="white" stroke="black" style="stroke-width: 0.25;" />
|
<circle cy="1.75" r="5" fill="white" stroke="black" style="stroke-width: 0.25;" />
|
||||||
<line x1="-5" y1="1.75" x2="5" y2="1.75" style="stroke:black; stroke-width: 0.25;" />
|
<line x1="-5" y1="1.75" x2="5" y2="1.75" style="stroke: black; stroke-width: 0.25;" />
|
||||||
|
</g>
|
||||||
|
<g id="elevation-arrow">
|
||||||
|
<path style="fill: black;" d="M -7.07106 0 0 -7.07106 7.07106 0" />
|
||||||
|
</g>
|
||||||
|
<g id="elevation-tag">
|
||||||
|
<circle r="5" fill="white" stroke="black" style="stroke-width: 0.25;" />
|
||||||
|
<line x1="-5" y1="0" x2="5" y2="0" style="stroke: black; stroke-width: 0.25;" />
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 572 B After Width: | Height: | Size: 893 B |
@@ -457,6 +457,8 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
svg_writer.annotations.setdefault("equal_objs", []).append(obj)
|
svg_writer.annotations.setdefault("equal_objs", []).append(obj)
|
||||||
elif element.ObjectType == "DIMENSION":
|
elif element.ObjectType == "DIMENSION":
|
||||||
svg_writer.annotations.setdefault("dimension_objs", []).append(obj)
|
svg_writer.annotations.setdefault("dimension_objs", []).append(obj)
|
||||||
|
elif element.ObjectType == "ELEVATION":
|
||||||
|
svg_writer.annotations.setdefault("elevation_objs", []).append(obj)
|
||||||
elif element.ObjectType == "BREAKLINE":
|
elif element.ObjectType == "BREAKLINE":
|
||||||
svg_writer.annotations["break_obj"] = obj
|
svg_writer.annotations["break_obj"] = obj
|
||||||
elif element.ObjectType == "HIDDEN_LINE":
|
elif element.ObjectType == "HIDDEN_LINE":
|
||||||
@@ -681,6 +683,7 @@ class ActivateView(bpy.types.Operator):
|
|||||||
|
|
||||||
project_collection.children["Views"].children[camera.users_collection[0].name].hide_viewport = False
|
project_collection.children["Views"].children[camera.users_collection[0].name].hide_viewport = False
|
||||||
bpy.data.collections.get(camera.users_collection[0].name).hide_render = False
|
bpy.data.collections.get(camera.users_collection[0].name).hide_render = False
|
||||||
|
bpy.context.scene.DocProperties.active_drawing_id = self.drawing
|
||||||
bpy.ops.bim.activate_drawing_style()
|
bpy.ops.bim.activate_drawing_style()
|
||||||
core.sync_references(tool.Ifc, tool.Collector, tool.Drawing, drawing=tool.Ifc.get().by_id(self.drawing))
|
core.sync_references(tool.Ifc, tool.Collector, tool.Drawing, drawing=tool.Ifc.get().by_id(self.drawing))
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|||||||
@@ -286,7 +286,12 @@ class SvgWriter:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.draw_text_annotations()
|
|
||||||
|
for obj in self.annotations.get("elevation_objs", []):
|
||||||
|
self.draw_elevation_annotation(obj)
|
||||||
|
|
||||||
|
for text_obj in self.annotations.get("text_objs", []):
|
||||||
|
self.draw_text_annotation(text_obj, text_obj.location)
|
||||||
|
|
||||||
def draw_ifc_annotation(self):
|
def draw_ifc_annotation(self):
|
||||||
x_offset = self.raw_width / 2
|
x_offset = self.raw_width / 2
|
||||||
@@ -425,9 +430,25 @@ class SvgWriter:
|
|||||||
position = Vector((0, 0, 0))
|
position = Vector((0, 0, 0))
|
||||||
self.draw_text_annotation(obj, position)
|
self.draw_text_annotation(obj, position)
|
||||||
|
|
||||||
def draw_text_annotations(self):
|
def draw_elevation_annotation(self, obj):
|
||||||
for text_obj in self.annotations.get("text_objs", []):
|
x_offset = self.raw_width / 2
|
||||||
self.draw_text_annotation(text_obj, text_obj.location)
|
y_offset = self.raw_height / 2
|
||||||
|
symbol_position = self.project_point_onto_camera(obj.location)
|
||||||
|
symbol_position = Vector(((x_offset + symbol_position.x), (y_offset - symbol_position.y)))
|
||||||
|
|
||||||
|
v1 = self.project_point_onto_camera(obj.matrix_world @ Vector((0, 0, 0)))
|
||||||
|
v2 = self.project_point_onto_camera(obj.matrix_world @ Vector((0, 0, -1)))
|
||||||
|
angle = -math.degrees((v2 - v1).xy.angle_signed(Vector((0, 1))))
|
||||||
|
|
||||||
|
transform = "rotate({}, {}, {})".format(
|
||||||
|
angle,
|
||||||
|
(symbol_position * self.scale)[0],
|
||||||
|
(symbol_position * self.scale)[1],
|
||||||
|
)
|
||||||
|
|
||||||
|
self.svg.add(self.svg.use("#elevation-arrow", insert=tuple(symbol_position * self.scale), transform=transform))
|
||||||
|
self.svg.add(self.svg.use("#elevation-tag", insert=tuple(symbol_position * self.scale)))
|
||||||
|
|
||||||
|
|
||||||
def draw_text_annotation(self, text_obj, position):
|
def draw_text_annotation(self, text_obj, position):
|
||||||
x_offset = self.raw_width / 2
|
x_offset = self.raw_width / 2
|
||||||
@@ -646,6 +667,7 @@ class SvgWriter:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def project_point_onto_camera(self, point):
|
def project_point_onto_camera(self, point):
|
||||||
|
# TODO is this needlessly complex?
|
||||||
return self.camera.matrix_world.inverted() @ geometry.intersect_line_plane(
|
return self.camera.matrix_world.inverted() @ geometry.intersect_line_plane(
|
||||||
point.xyz,
|
point.xyz,
|
||||||
point.xyz - Vector(self.camera_projection),
|
point.xyz - Vector(self.camera_projection),
|
||||||
|
|||||||
Reference in New Issue
Block a user