mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 14:02:27 +00:00
Fix rotated dimensions, add engineering style dimensions
This commit is contained in:
@@ -737,17 +737,13 @@ class SvgWriter():
|
|||||||
end = Vector(((x_offset + v1.x), (y_offset - v1.y)))
|
end = Vector(((x_offset + v1.x), (y_offset - v1.y)))
|
||||||
mid = ((end - start) / 2) + start
|
mid = ((end - start) / 2) + start
|
||||||
vector = end - start
|
vector = end - start
|
||||||
if (end.y - start.y) * self.scale > 1:
|
|
||||||
perpendicular = Vector((-vector.y, vector.x)).normalized()
|
|
||||||
else:
|
|
||||||
perpendicular = Vector((vector.y, -vector.x)).normalized()
|
|
||||||
perpendicular = Vector((vector.y, -vector.x)).normalized()
|
perpendicular = Vector((vector.y, -vector.x)).normalized()
|
||||||
text_position = (mid * self.scale) + perpendicular
|
text_position = (mid * self.scale) + perpendicular
|
||||||
rotation = degrees(vector.angle(Vector((1, 0))))
|
rotation = degrees(vector.angle_signed(Vector((1, 0))))
|
||||||
line = self.svg.add(self.svg.line(start=tuple(start * self.scale),
|
line = self.svg.add(self.svg.line(start=tuple(start * self.scale),
|
||||||
end=tuple(end * self.scale), class_=' '.join(classes)))
|
end=tuple(end * self.scale), class_=' '.join(classes)))
|
||||||
line['marker-start'] = 'url(#dimension-marker)'
|
line['marker-start'] = 'url(#dimension-marker-start)'
|
||||||
line['marker-end'] = 'url(#dimension-marker)'
|
line['marker-end'] = 'url(#dimension-marker-end)'
|
||||||
# Standard font sizes 1.8, 2.5, 3.5, 5, 7
|
# Standard font sizes 1.8, 2.5, 3.5, 5, 7
|
||||||
# Equivalent for OpenGost Type B: 2.97, 4.13, 5.78, 8.25, 11.55
|
# Equivalent for OpenGost Type B: 2.97, 4.13, 5.78, 8.25, 11.55
|
||||||
self.svg.add(self.svg.text('EQ', insert=tuple(text_position), **{
|
self.svg.add(self.svg.text('EQ', insert=tuple(text_position), **{
|
||||||
@@ -774,18 +770,20 @@ class SvgWriter():
|
|||||||
mid = ((end - start) / 2) + start
|
mid = ((end - start) / 2) + start
|
||||||
# TODO: hardcoded meters to mm conversion, until I properly do units
|
# TODO: hardcoded meters to mm conversion, until I properly do units
|
||||||
vector = end - start
|
vector = end - start
|
||||||
if (end.y - start.y) * self.scale > 1:
|
|
||||||
perpendicular = Vector((-vector.y, vector.x)).normalized()
|
|
||||||
else:
|
|
||||||
perpendicular = Vector((vector.y, -vector.x)).normalized()
|
|
||||||
perpendicular = Vector((vector.y, -vector.x)).normalized()
|
perpendicular = Vector((vector.y, -vector.x)).normalized()
|
||||||
text_position = (mid * self.scale) + perpendicular
|
|
||||||
dimension = vector.length * 1000
|
dimension = vector.length * 1000
|
||||||
rotation = degrees(vector.angle(Vector((1, 0))))
|
sheet_dimension = ((end*self.scale) - (start*self.scale)).length
|
||||||
|
if sheet_dimension < 5: # annotation can't fit
|
||||||
|
# offset text to right of marker
|
||||||
|
text_position = (end * self.scale) + perpendicular + (3 * vector.normalized())
|
||||||
|
else:
|
||||||
|
text_position = (mid * self.scale) + perpendicular
|
||||||
|
print(sheet_dimension)
|
||||||
|
rotation = degrees(vector.angle_signed(Vector((1, 0))))
|
||||||
line = self.svg.add(self.svg.line(start=tuple(start * self.scale),
|
line = self.svg.add(self.svg.line(start=tuple(start * self.scale),
|
||||||
end=tuple(end * self.scale), class_=' '.join(classes)))
|
end=tuple(end * self.scale), class_=' '.join(classes)))
|
||||||
line['marker-start'] = 'url(#dimension-marker)'
|
line['marker-start'] = 'url(#dimension-marker-start)'
|
||||||
line['marker-end'] = 'url(#dimension-marker)'
|
line['marker-end'] = 'url(#dimension-marker-end)'
|
||||||
# Standard font sizes 1.8, 2.5, 3.5, 5, 7
|
# Standard font sizes 1.8, 2.5, 3.5, 5, 7
|
||||||
# Equivalent for OpenGost Type B: 2.97, 4.13, 5.78, 8.25, 11.55
|
# Equivalent for OpenGost Type B: 2.97, 4.13, 5.78, 8.25, 11.55
|
||||||
self.svg.add(self.svg.text(str(round(dimension)), insert=tuple(text_position), **{
|
self.svg.add(self.svg.text(str(round(dimension)), insert=tuple(text_position), **{
|
||||||
@@ -853,20 +851,24 @@ class SvgWriter():
|
|||||||
d = ' '.join(['L {} {}'.format((x_offset + p.co.x) * self.scale, (y_offset - p.co.y) * self.scale) for p in spline.points])
|
d = ' '.join(['L {} {}'.format((x_offset + p.co.x) * self.scale, (y_offset - p.co.y) * self.scale) for p in spline.points])
|
||||||
d = 'M{}'.format(d[1:])
|
d = 'M{}'.format(d[1:])
|
||||||
path = self.svg.add(self.svg.path(d=d, class_=' '.join(classes)))
|
path = self.svg.add(self.svg.path(d=d, class_=' '.join(classes)))
|
||||||
path['marker-start'] = 'url(#plan-level-marker)'
|
path['marker-end'] = 'url(#plan-level-marker)'
|
||||||
text_position = Vector((
|
text_position = Vector((
|
||||||
(x_offset + spline.points[0].co.x) * self.scale,
|
(x_offset + spline.points[0].co.x) * self.scale,
|
||||||
((y_offset - spline.points[0].co.y) * self.scale) - 5
|
((y_offset - spline.points[0].co.y) * self.scale) - 2.5
|
||||||
))
|
))
|
||||||
# TODO: unhardcode mm unit
|
# TODO: unhardcode m unit
|
||||||
rl = round(((self.ifc_cutter.plan_level_obj.matrix_world @
|
rl = ((self.ifc_cutter.plan_level_obj.matrix_world @
|
||||||
spline.points[0].co).xyz + self.ifc_cutter.plan_level_obj.location).z * 1000)
|
spline.points[0].co).xyz + self.ifc_cutter.plan_level_obj.location).z
|
||||||
self.svg.add(self.svg.text('RL +{}'.format(rl), insert=tuple(text_position), **{
|
if spline.points[0].co.x > spline.points[-1].co.x:
|
||||||
|
text_anchor = 'end'
|
||||||
|
else:
|
||||||
|
text_anchor = 'start'
|
||||||
|
self.svg.add(self.svg.text('RL +{:.3f}m'.format(rl), insert=tuple(text_position), **{
|
||||||
'font-size': '4.13', # 2.5
|
'font-size': '4.13', # 2.5
|
||||||
'font-family': 'OpenGost Type B TT',
|
'font-family': 'OpenGost Type B TT',
|
||||||
'text-anchor': 'middle',
|
'text-anchor': text_anchor,
|
||||||
'alignment-baseline': 'middle',
|
'alignment-baseline': 'baseline',
|
||||||
'dominant-baseline': 'middle'
|
'dominant-baseline': 'baseline'
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if self.ifc_cutter.section_level_obj:
|
if self.ifc_cutter.section_level_obj:
|
||||||
|
|||||||
@@ -1,6 +1,25 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<svg baseProfile="full" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
|
<svg baseProfile="full" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
<marker id="dimension-marker" markerHeight="30" markerWidth="20" refX="10" refY="15" orient="auto">
|
<marker id="eng-dimension-marker-start" markerHeight="14" markerWidth="11" orient="auto" refX="1" refY="7">
|
||||||
|
<g>
|
||||||
|
<path d="M 11 3.5 L 11 10.5 L 1 7" class="annotation" style="fill:black;" />
|
||||||
|
<path d="M 1 0 L 1 14" class="annotation" style="stroke-width:1;" />
|
||||||
|
</g>
|
||||||
|
</marker>
|
||||||
|
<marker id="eng-dimension-marker-end" markerHeight="14" markerWidth="11" orient="auto" refX="10" refY="7">
|
||||||
|
<g>
|
||||||
|
<path d="M 0 3.5 L 0 10.5 L 10 7" class="annotation" style="fill:black;" />
|
||||||
|
<path d="M 10 0 L 10 14" class="annotation" style="stroke-width:1;" />
|
||||||
|
</g>
|
||||||
|
</marker>
|
||||||
|
<marker id="dimension-marker-start" markerHeight="30" markerWidth="20" refX="10" refY="15" orient="auto">
|
||||||
|
<g>
|
||||||
|
<path d="M 0 15 L 20 15" class="annotation" style="stroke-width:1;" />
|
||||||
|
<path d="M 10 0 L 10 30" class="annotation" style="stroke-width:1;" />
|
||||||
|
<path d="M 5 20 L 15 10" class="annotation" style="stroke-width:3;" />
|
||||||
|
</g>
|
||||||
|
</marker>
|
||||||
|
<marker id="dimension-marker-end" markerHeight="30" markerWidth="20" refX="10" refY="15" orient="auto">
|
||||||
<g>
|
<g>
|
||||||
<path d="M 0 15 L 20 15" class="annotation" style="stroke-width:1;" />
|
<path d="M 0 15 L 20 15" class="annotation" style="stroke-width:1;" />
|
||||||
<path d="M 10 0 L 10 30" class="annotation" style="stroke-width:1;" />
|
<path d="M 10 0 L 10 30" class="annotation" style="stroke-width:1;" />
|
||||||
@@ -28,7 +47,9 @@
|
|||||||
<path d="M 15 15 L 22.5 15 A 7.5 7.5 0 0 1 15 22.5 Z" fill="black"/>
|
<path d="M 15 15 L 22.5 15 A 7.5 7.5 0 0 1 15 22.5 Z" fill="black"/>
|
||||||
</g>
|
</g>
|
||||||
</marker>
|
</marker>
|
||||||
<marker id="section-level-marker" markerHeight="15" markerWidth="30" refX="15" refY="15">
|
<marker id="section-level-marker" markerHeight="10" markerWidth="20" refX="10" refY="10">
|
||||||
<path d="M 0 0 L 30 0 L 15 15 Z" fill="black" />
|
<g>
|
||||||
|
<path d="M 0 0 L 20 0 L 10 10 Z" fill="black" />
|
||||||
|
<g>
|
||||||
</marker>
|
</marker>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 3.2 KiB |
@@ -797,7 +797,7 @@ class CutSection(bpy.types.Operator):
|
|||||||
ifc_cutter.section_level_obj = None
|
ifc_cutter.section_level_obj = None
|
||||||
ifc_cutter.grid_objs = []
|
ifc_cutter.grid_objs = []
|
||||||
ifc_cutter.text_objs = []
|
ifc_cutter.text_objs = []
|
||||||
for obj in bpy.context.selected_objects:
|
for obj in camera.users_collection[0].objects:
|
||||||
if 'Leader' in obj.name:
|
if 'Leader' in obj.name:
|
||||||
ifc_cutter.leader_obj = obj
|
ifc_cutter.leader_obj = obj
|
||||||
elif 'Stair' in obj.name:
|
elif 'Stair' in obj.name:
|
||||||
|
|||||||
Reference in New Issue
Block a user