mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 11:24:19 +00:00
#1153. Section markers are now supported in SVG.
This commit is contained in:
@@ -14,4 +14,11 @@
|
||||
<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 id="section-arrow">
|
||||
<path style="fill: black;" d="M -7.07106 0 0 -7.07106 7.07106 0" />
|
||||
</g>
|
||||
<g id="section-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>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 893 B After Width: | Height: | Size: 1.2 KiB |
@@ -459,6 +459,8 @@ class CreateDrawing(bpy.types.Operator):
|
||||
svg_writer.annotations.setdefault("dimension_objs", []).append(obj)
|
||||
elif element.ObjectType == "ELEVATION":
|
||||
svg_writer.annotations.setdefault("elevation_objs", []).append(obj)
|
||||
elif element.ObjectType == "SECTION":
|
||||
svg_writer.annotations.setdefault("section_objs", []).append(obj)
|
||||
elif element.ObjectType == "BREAKLINE":
|
||||
svg_writer.annotations["break_obj"] = obj
|
||||
elif element.ObjectType == "HIDDEN_LINE":
|
||||
|
||||
@@ -290,6 +290,9 @@ class SvgWriter:
|
||||
for obj in self.annotations.get("elevation_objs", []):
|
||||
self.draw_elevation_annotation(obj)
|
||||
|
||||
for obj in self.annotations.get("section_objs", []):
|
||||
self.draw_section_annotation(obj)
|
||||
|
||||
for text_obj in self.annotations.get("text_objs", []):
|
||||
self.draw_text_annotation(text_obj, text_obj.location)
|
||||
|
||||
@@ -430,6 +433,29 @@ class SvgWriter:
|
||||
position = Vector((0, 0, 0))
|
||||
self.draw_text_annotation(obj, position)
|
||||
|
||||
def draw_section_annotation(self, obj):
|
||||
x_offset = self.raw_width / 2
|
||||
y_offset = self.raw_height / 2
|
||||
|
||||
self.draw_line_annotation((obj, obj.data), ["solid"])
|
||||
|
||||
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))))
|
||||
|
||||
for vert in obj.data.vertices:
|
||||
point = obj.matrix_world @ vert.co
|
||||
symbol_position = self.project_point_onto_camera(point)
|
||||
symbol_position = Vector(((x_offset + symbol_position.x), (y_offset - symbol_position.y)))
|
||||
transform = "rotate({}, {}, {})".format(
|
||||
angle,
|
||||
(symbol_position * self.scale)[0],
|
||||
(symbol_position * self.scale)[1],
|
||||
)
|
||||
|
||||
self.svg.add(self.svg.use("#section-arrow", insert=tuple(symbol_position * self.scale), transform=transform))
|
||||
self.svg.add(self.svg.use("#section-tag", insert=tuple(symbol_position * self.scale)))
|
||||
|
||||
def draw_elevation_annotation(self, obj):
|
||||
x_offset = self.raw_width / 2
|
||||
y_offset = self.raw_height / 2
|
||||
|
||||
Reference in New Issue
Block a user