Fix #2352. Text styling is now possible with custom classes.

This commit is contained in:
Dion Moult
2023-02-12 15:01:47 +11:00
parent c9bd7adf8a
commit 82b201a14e
8 changed files with 135 additions and 51 deletions
@@ -5,9 +5,9 @@ FILE_NAME('EPset_Annotation.ifc','2020-01-01T00:00:00',(),(),'EPset_Annotation',
FILE_SCHEMA(('IFC4'));
ENDSEC;
DATA;
#1=IFCPROPERTYSETTEMPLATE('3VuPUwdCD2Qx3XDDRs0R1N',$,'EPset_Annotation','',.PSET_OCCURRENCEDRIVEN.,'IfcAnnotation',(#2,#3));
#1=IFCPROPERTYSETTEMPLATE('3VuPUwdCD2Qx3XDDRs0R1N',$,'EPset_Annotation','',.PSET_OCCURRENCEDRIVEN.,'IfcAnnotation',(#2,#3,#4));
#2=IFCSIMPLEPROPERTYTEMPLATE('2P7JN79n96Q9pElZ83LKe4',$,'ZIndex','',.P_SINGLEVALUE.,'IfcInteger',$,$,$,$,$,.READWRITE.);
#3=IFCSIMPLEPROPERTYTEMPLATE('1Wpx_r2xj1_9w5JpI0QRJy',$,'Symbol','',.P_ENUMERATEDVALUE.,'IfcLabel',$,#4,$,$,$,.READWRITE.);
#4=IFCPROPERTYENUMERATION('Symbol',(IFCLABEL('rectangle-tag'), IFCLABEL('door-tag')),$);
#3=IFCSIMPLEPROPERTYTEMPLATE('1Wpx_r2xj1_9w5JpI0QRJy',$,'Symbol','',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#4=IFCSIMPLEPROPERTYTEMPLATE('3q0oxMUKP47vZ4jnyG$dDb',$,'Classes','',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
ENDSEC;
END-ISO-10303-21;
@@ -19,7 +19,7 @@
*/
* { stroke-linecap: round; stroke-linejoin: round; }
text { fill: black; stroke: none; }
text { /* 2.5mm */ fill: black; stroke: none; font-family: 'OpenGost Type B TT'; font-size: 4.13px; dominant-baseline: baseline; text-anchor: start; }
.cut { fill: black; stroke: black; stroke-linecap: 'round'; stroke-width: 0.35; fill-rule: evenodd; }
.projection { fill: white; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; }
.annotation { fill: none; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; }
@@ -44,6 +44,11 @@ text { fill: black; stroke: none; }
.PredefinedType-TEXT { fill: black; stroke: none; }
path.PredefinedType-TEXTLEADER { marker-end: url(#leader-marker); }
text.PredefinedType-TEXTLEADER { fill: black; stroke: none; }
text.title { /* 7mm */ fill: black; stroke: none; font-family: 'OpenGost Type B TT'; font-size: 11.55px; }
text.header { /* 5mm */ fill: black; stroke: none; font-family: 'OpenGost Type B TT'; font-size: 8.25px; }
text.large { /* 3.5mm */ fill: black; stroke: none; font-family: 'OpenGost Type B TT'; font-size: 5.78px; }
text.regular { /* 2.5mm */ fill: black; stroke: none; font-family: 'OpenGost Type B TT'; font-size: 4.13px; }
text.small { /* 1.8mm */ fill: black; stroke: none; font-family: 'OpenGost Type B TT'; font-size: 2.97px; }
.material-blank { fill: white; }
.material-diagonal1 { fill: url(#diagonal1); }
.material-diagonal2 { fill: url(#diagonal2); }
@@ -23,17 +23,6 @@ from mathutils import Vector
class Annotator:
@staticmethod
def get_svg_text_size(size):
sizes = {
"1.8": "2.97",
"2.5": "4.13",
"3.5": "5.78",
"5.0": "8.25",
"7.0": "11.55",
}
return float(sizes[str(size)])
@staticmethod
def add_text(related_element=None):
curve = bpy.data.curves.new(type="FONT", name="Text")
@@ -202,8 +202,6 @@ class SvgWriter:
rl *= unit_scale
rl = "{:.3f}m".format(rl)
text_style = {
"font-size": annotation.Annotator.get_svg_text_size(2.5),
"font-family": "OpenGost Type B TT",
"text-anchor": "start",
"alignment-baseline": "baseline",
"dominant-baseline": "baseline",
@@ -236,8 +234,6 @@ class SvgWriter:
"UP",
insert=tuple(text_position),
**{
"font-size": annotation.Annotator.get_svg_text_size(2.5),
"font-family": "OpenGost Type B TT",
"text-anchor": "middle",
"alignment-baseline": "middle",
"dominant-baseline": "middle",
@@ -270,8 +266,6 @@ class SvgWriter:
axis_tag,
insert=tuple(start * self.svg_scale),
**{
"font-size": annotation.Annotator.get_svg_text_size(5.0),
"font-family": "OpenGost Type B TT",
"text-anchor": "middle",
"alignment-baseline": "middle",
"dominant-baseline": "middle",
@@ -283,8 +277,6 @@ class SvgWriter:
axis_tag,
insert=tuple(end * self.svg_scale),
**{
"font-size": annotation.Annotator.get_svg_text_size(5.0),
"font-family": "OpenGost Type B TT",
"text-anchor": "middle",
"alignment-baseline": "middle",
"dominant-baseline": "middle",
@@ -325,6 +317,9 @@ class SvgWriter:
str(ifcopenshell.util.element.get_predefined_type(element))
)
classes = [global_id, element.is_a(), predefined_type]
custom_classes = ifcopenshell.util.element.get_pset(element, "EPset_Annotation", "Classes")
if custom_classes:
classes.extend(custom_classes.split())
for key in self.metadata:
value = ifcopenshell.util.selector.Selector.get_element_value(element, key)
if value:
@@ -413,8 +408,6 @@ class SvgWriter:
reference_id, sheet_id = self.get_reference_and_sheet_id_from_annotation(tool.Ifc.get_entity(obj))
text_position = list(symbol_position * self.svg_scale)
text_style = {
"font-size": annotation.Annotator.get_svg_text_size(2.5),
"font-family": "OpenGost Type B TT",
"text-anchor": "middle",
"alignment-baseline": "middle",
"dominant-baseline": "middle",
@@ -446,8 +439,6 @@ class SvgWriter:
reference_id, sheet_id = self.get_reference_and_sheet_id_from_annotation(tool.Ifc.get_entity(obj))
text_position = list(symbol_position * self.svg_scale)
text_style = {
"font-size": annotation.Annotator.get_svg_text_size(2.5),
"font-family": "OpenGost Type B TT",
"text-anchor": "middle",
"alignment-baseline": "middle",
"dominant-baseline": "middle",
@@ -544,8 +535,6 @@ class SvgWriter:
insert=tuple((text_position * self.svg_scale) + Vector((0, 3.5 * line_number))),
class_=" ".join(self.get_attribute_classes(text_obj)),
**{
"font-size": annotation.Annotator.get_svg_text_size(text_obj.BIMTextProperties.font_size),
"font-family": "OpenGost Type B TT",
"text-anchor": text_anchor,
"alignment-baseline": alignment_baseline,
"dominant-baseline": alignment_baseline,
@@ -618,8 +607,6 @@ class SvgWriter:
"RL +{}".format(rl),
insert=tuple(text_position),
**{
"font-size": annotation.Annotator.get_svg_text_size(2.5),
"font-family": "OpenGost Type B TT",
"text-anchor": text_anchor,
"alignment-baseline": "baseline",
"dominant-baseline": "baseline",
@@ -740,8 +727,6 @@ class SvgWriter:
text_position += text_offset
text_style = {
"font-size": annotation.Annotator.get_svg_text_size(2.5),
"font-family": "OpenGost Type B TT",
"text-anchor": "middle",
"alignment-baseline": "middle",
"dominant-baseline": "middle",
@@ -808,8 +793,6 @@ class SvgWriter:
text_position += text_offset
text_style = {
"font-size": annotation.Annotator.get_svg_text_size(2.5),
"font-family": "OpenGost Type B TT",
"text-anchor": "middle",
"alignment-baseline": "middle",
"dominant-baseline": "middle",
@@ -898,8 +881,6 @@ class SvgWriter:
insert=tuple(text_position),
**{
"transform": "rotate({} {} {})".format(rotation, text_position.x, text_position.y),
"font-size": annotation.Annotator.get_svg_text_size(2.5),
"font-family": "OpenGost Type B TT",
"text-anchor": "middle",
},
)
@@ -355,11 +355,6 @@ class BIM_PT_text(Panel):
row.label(text=attribute["name"])
row.label(text=attribute["value"])
row = self.layout.row()
row.prop(props, "font_size")
row = self.layout.row()
row.prop(props, "symbol")
class BIM_PT_annotation_utilities(Panel):
bl_idname = "BIM_PT_annotation_utilities"
@@ -160,6 +160,8 @@ class OpenUpstream(bpy.types.Operator):
webbrowser.open("https://wiki.osarch.org/index.php?title=Category:BlenderBIM_Add-on")
elif self.page == "community":
webbrowser.open("https://community.osarch.org/")
elif self.page == "fund":
webbrowser.open("https://opencollective.com/opensourcebim")
return {"FINISHED"}
+2 -2
View File
@@ -962,11 +962,11 @@ class Drawing(blenderbim.core.tool.Drawing):
@classmethod
def get_annotation_z_index(cls, drawing):
return ifcopenshell.util.element.get_psets(drawing).get("EPset_Annotation", {}).get("ZIndex", 0)
return ifcopenshell.util.element.get_pset(drawing, "EPset_Annotation", "ZIndex") or 0
@classmethod
def get_annotation_symbol(cls, drawing):
return ifcopenshell.util.element.get_psets(drawing).get("EPset_Annotation", {}).get("Symbol", None)
return ifcopenshell.util.element.get_pset(drawing, "EPset_Annotation", "Symbol")
@classmethod
def has_linework(cls, drawing):