mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
#1153 Dimensions can now have custom text
This commit is contained in:
@@ -172,7 +172,6 @@ class BaseDecorator:
|
|||||||
results = []
|
results = []
|
||||||
decoration_presets = (
|
decoration_presets = (
|
||||||
"DIMENSION",
|
"DIMENSION",
|
||||||
"EQUAL_DIMENSION",
|
|
||||||
"TEXT_LEADER",
|
"TEXT_LEADER",
|
||||||
"STAIR_ARROW",
|
"STAIR_ARROW",
|
||||||
"HIDDEN_LINE",
|
"HIDDEN_LINE",
|
||||||
@@ -481,29 +480,6 @@ class DimensionDecorator(BaseDecorator):
|
|||||||
self.draw_label(context, text, p0 + (dir) * 0.5, dir)
|
self.draw_label(context, text, p0 + (dir) * 0.5, dir)
|
||||||
|
|
||||||
|
|
||||||
class EqualityDecorator(DimensionDecorator):
|
|
||||||
"""Decorator for equality objects
|
|
||||||
- outlines each segment
|
|
||||||
- augments with arrows on both sides
|
|
||||||
- puts 'EQ' label
|
|
||||||
"""
|
|
||||||
|
|
||||||
objecttype = "EQUAL_DIMENSION"
|
|
||||||
|
|
||||||
def draw_labels(self, context, obj, vertices, indices):
|
|
||||||
region = context.region
|
|
||||||
region3d = context.region_data
|
|
||||||
for i0, i1 in indices:
|
|
||||||
v0 = Vector(vertices[i0])
|
|
||||||
v1 = Vector(vertices[i1])
|
|
||||||
p0 = location_3d_to_region_2d(region, region3d, v0)
|
|
||||||
p1 = location_3d_to_region_2d(region, region3d, v1)
|
|
||||||
dir = p1 - p0
|
|
||||||
if dir.length < 1:
|
|
||||||
continue
|
|
||||||
self.draw_label(context, "EQ", p0 + (dir) * 0.5, dir)
|
|
||||||
|
|
||||||
|
|
||||||
class LeaderDecorator(BaseDecorator):
|
class LeaderDecorator(BaseDecorator):
|
||||||
"""Decorating text with arrows
|
"""Decorating text with arrows
|
||||||
- head point with arrow
|
- head point with arrow
|
||||||
@@ -1605,7 +1581,6 @@ class TextDecorator(BaseDecorator):
|
|||||||
class DecorationsHandler:
|
class DecorationsHandler:
|
||||||
decorators_classes = [
|
decorators_classes = [
|
||||||
DimensionDecorator,
|
DimensionDecorator,
|
||||||
EqualityDecorator,
|
|
||||||
GridDecorator,
|
GridDecorator,
|
||||||
HiddenDecorator,
|
HiddenDecorator,
|
||||||
LeaderDecorator,
|
LeaderDecorator,
|
||||||
|
|||||||
@@ -151,8 +151,6 @@ class SvgWriter:
|
|||||||
self.draw_leader_annotation(obj)
|
self.draw_leader_annotation(obj)
|
||||||
elif element.ObjectType == "STAIR_ARROW":
|
elif element.ObjectType == "STAIR_ARROW":
|
||||||
self.draw_stair_annotation(obj)
|
self.draw_stair_annotation(obj)
|
||||||
elif element.ObjectType == "EQUAL_DIMENSION":
|
|
||||||
self.draw_dimension_annotations(obj, text_override="EQ")
|
|
||||||
elif element.ObjectType == "DIMENSION":
|
elif element.ObjectType == "DIMENSION":
|
||||||
self.draw_dimension_annotations(obj)
|
self.draw_dimension_annotations(obj)
|
||||||
elif element.ObjectType == "RADIUS":
|
elif element.ObjectType == "RADIUS":
|
||||||
@@ -663,10 +661,12 @@ class SvgWriter:
|
|||||||
|
|
||||||
self.svg.add(self.svg.text(tag, insert=tuple(text_position), **text_style))
|
self.svg.add(self.svg.text(tag, insert=tuple(text_position), **text_style))
|
||||||
|
|
||||||
def draw_dimension_annotations(self, dimension_obj, text_override=None):
|
def draw_dimension_annotations(self, obj):
|
||||||
classes = self.get_attribute_classes(dimension_obj)
|
classes = self.get_attribute_classes(obj)
|
||||||
matrix_world = dimension_obj.matrix_world
|
matrix_world = obj.matrix_world
|
||||||
for spline in dimension_obj.data.splines:
|
element = tool.Ifc.get_entity(obj)
|
||||||
|
text_override = element.Description
|
||||||
|
for spline in obj.data.splines:
|
||||||
points = self.get_spline_points(spline)
|
points = self.get_spline_points(spline)
|
||||||
for i, p in enumerate(points):
|
for i, p in enumerate(points):
|
||||||
if i + 1 >= len(points):
|
if i + 1 >= len(points):
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
def create_annotation_object(cls, object_type):
|
def create_annotation_object(cls, object_type):
|
||||||
data_type = {
|
data_type = {
|
||||||
"DIMENSION": "curve",
|
"DIMENSION": "curve",
|
||||||
"EQUAL_DIMENSION": "curve",
|
|
||||||
"RADIUS": "curve",
|
"RADIUS": "curve",
|
||||||
"TEXT": "empty",
|
"TEXT": "empty",
|
||||||
"TEXT_LEADER": "curve",
|
"TEXT_LEADER": "curve",
|
||||||
|
|||||||
Reference in New Issue
Block a user