mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 07:42:44 +00:00
Add support for breakline annotations
This commit is contained in:
@@ -861,6 +861,9 @@ class SvgWriter():
|
|||||||
if self.ifc_cutter.dimension_obj:
|
if self.ifc_cutter.dimension_obj:
|
||||||
self.draw_dimension_annotations(self.ifc_cutter.dimension_obj)
|
self.draw_dimension_annotations(self.ifc_cutter.dimension_obj)
|
||||||
|
|
||||||
|
if self.ifc_cutter.break_obj:
|
||||||
|
self.draw_break_annotations(self.ifc_cutter.break_obj)
|
||||||
|
|
||||||
for grid_obj in self.ifc_cutter.grid_objs:
|
for grid_obj in self.ifc_cutter.grid_objs:
|
||||||
matrix_world = grid_obj.matrix_world
|
matrix_world = grid_obj.matrix_world
|
||||||
for edge in grid_obj.data.edges:
|
for edge in grid_obj.data.edges:
|
||||||
@@ -1056,6 +1059,30 @@ class SvgWriter():
|
|||||||
}
|
}
|
||||||
))
|
))
|
||||||
|
|
||||||
|
def draw_break_annotations(self, break_obj):
|
||||||
|
x_offset = self.raw_width / 2
|
||||||
|
y_offset = self.raw_height / 2
|
||||||
|
|
||||||
|
matrix_world = break_obj.matrix_world
|
||||||
|
for polygon in break_obj.data.polygons:
|
||||||
|
points = [break_obj.data.vertices[v] for v in polygon.vertices]
|
||||||
|
projected_points = [self.project_point_onto_camera(matrix_world @ p.co.xyz) for p in points]
|
||||||
|
d = ' '.join(['L {} {}'.format(
|
||||||
|
(x_offset + p.x) * self.scale, (y_offset - p.y) * self.scale)
|
||||||
|
for p in projected_points])
|
||||||
|
d = 'M{}'.format(d[1:])
|
||||||
|
path = self.svg.add(self.svg.path(d=d, class_=' '.join(['break'])))
|
||||||
|
|
||||||
|
break_points = [
|
||||||
|
projected_points[0],
|
||||||
|
((projected_points[1]-projected_points[0])/2)+projected_points[0],
|
||||||
|
projected_points[1]]
|
||||||
|
d = ' '.join(['L {} {}'.format(
|
||||||
|
(x_offset + p.x) * self.scale, (y_offset - p.y) * self.scale)
|
||||||
|
for p in break_points])
|
||||||
|
d = 'M{}'.format(d[1:])
|
||||||
|
path = self.svg.add(self.svg.path(d=d, class_=' '.join(['breakline'])))
|
||||||
|
|
||||||
def draw_dimension_annotations(self, dimension_obj, text_override=None):
|
def draw_dimension_annotations(self, dimension_obj, text_override=None):
|
||||||
x_offset = self.raw_width / 2
|
x_offset = self.raw_width / 2
|
||||||
y_offset = self.raw_height / 2
|
y_offset = self.raw_height / 2
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
.hidden { stroke-dasharray: 3, 2; }
|
.hidden { stroke-dasharray: 3, 2; }
|
||||||
.leader { marker-end: url(#leader-marker); }
|
.leader { marker-end: url(#leader-marker); }
|
||||||
.stair { marker-start: url(#stair-marker-start); marker-end: url(#stair-marker-end); }
|
.stair { marker-start: url(#stair-marker-start); marker-end: url(#stair-marker-end); }
|
||||||
|
.break { fill: white; }
|
||||||
|
.breakline { fill: none; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; marker-mid: url(#breakline-marker); }
|
||||||
.solid {}
|
.solid {}
|
||||||
.material-diagonal1 { fill: url(#diagonal1); }
|
.material-diagonal1 { fill: url(#diagonal1); }
|
||||||
.material-diagonal2 { fill: url(#diagonal2); }
|
.material-diagonal2 { fill: url(#diagonal2); }
|
||||||
|
|||||||
@@ -53,4 +53,10 @@
|
|||||||
<path d="M 0 1 L 90 1" class="annotation" style="stroke-width:1;" />
|
<path d="M 0 1 L 90 1" class="annotation" style="stroke-width:1;" />
|
||||||
</g>
|
</g>
|
||||||
</marker>
|
</marker>
|
||||||
|
<marker id="breakline-marker" markerHeight="20" markerWidth="15" refX="7.5" refY="10">
|
||||||
|
<g>
|
||||||
|
<path d="M 0 10 L 5 20 L 7.5 10" class="annotation" style="stroke-width:1; fill: white;" />
|
||||||
|
<path d="M 7.5 10 L 10 0 L 15 10" class="annotation" style="stroke-width:1; fill: white;" />
|
||||||
|
</g>
|
||||||
|
</marker>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.6 KiB |
@@ -1579,6 +1579,7 @@ class CutSection(bpy.types.Operator):
|
|||||||
ifc_cutter.leader_obj = None
|
ifc_cutter.leader_obj = None
|
||||||
ifc_cutter.stair_obj = None
|
ifc_cutter.stair_obj = None
|
||||||
ifc_cutter.dimension_obj = None
|
ifc_cutter.dimension_obj = None
|
||||||
|
ifc_cutter.break_obj = None
|
||||||
ifc_cutter.equal_obj = None
|
ifc_cutter.equal_obj = None
|
||||||
ifc_cutter.hidden_objs = []
|
ifc_cutter.hidden_objs = []
|
||||||
ifc_cutter.solid_objs = []
|
ifc_cutter.solid_objs = []
|
||||||
@@ -1595,6 +1596,8 @@ class CutSection(bpy.types.Operator):
|
|||||||
ifc_cutter.equal_obj = obj
|
ifc_cutter.equal_obj = obj
|
||||||
elif 'Dimension' in obj.name:
|
elif 'Dimension' in obj.name:
|
||||||
ifc_cutter.dimension_obj = obj
|
ifc_cutter.dimension_obj = obj
|
||||||
|
elif 'Break' in obj.name:
|
||||||
|
ifc_cutter.break_obj = obj
|
||||||
elif 'Hidden' in obj.name:
|
elif 'Hidden' in obj.name:
|
||||||
ifc_cutter.hidden_objs.append((obj, obj.data))
|
ifc_cutter.hidden_objs.append((obj, obj.data))
|
||||||
elif 'Solid' in obj.name:
|
elif 'Solid' in obj.name:
|
||||||
|
|||||||
Reference in New Issue
Block a user