mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
unsuppress zero inches in formatting distance #3011
Added option to suppress zero inches in the dimension annotation text through SuppressZeroInches property of BBIM_Dimension property set. Previously by default suppressing zero inches was enabled. Now by default it is disabled. SupressZeroInches On - https://i.imgur.com/nrhELnA.png SupprezZeroInches Off - https://i.imgur.com/gIuO2GW.png
This commit is contained in:
@@ -27,7 +27,8 @@ DATA;
|
|||||||
#20=IFCSIMPLEPROPERTYTEMPLATE('23tejOrxj859R_eCRp1AFP',$,'MarkersPath','Default markers SVG',.P_SINGLEVALUE.,'IfcURIReference',$,$,$,$,$,.READWRITE.);
|
#20=IFCSIMPLEPROPERTYTEMPLATE('23tejOrxj859R_eCRp1AFP',$,'MarkersPath','Default markers SVG',.P_SINGLEVALUE.,'IfcURIReference',$,$,$,$,$,.READWRITE.);
|
||||||
#21=IFCSIMPLEPROPERTYTEMPLATE('1UDakJ5_f7kBhggNSW4$h5',$,'SymbolsPath','Default symbols SVG',.P_SINGLEVALUE.,'IfcURIReference',$,$,$,$,$,.READWRITE.);
|
#21=IFCSIMPLEPROPERTYTEMPLATE('1UDakJ5_f7kBhggNSW4$h5',$,'SymbolsPath','Default symbols SVG',.P_SINGLEVALUE.,'IfcURIReference',$,$,$,$,$,.READWRITE.);
|
||||||
#22=IFCSIMPLEPROPERTYTEMPLATE('0d53LEtgLDQxnv__NfgH7i',$,'PatternsPath','Default patterns SVG',.P_SINGLEVALUE.,'IfcURIReference',$,$,$,$,$,.READWRITE.);
|
#22=IFCSIMPLEPROPERTYTEMPLATE('0d53LEtgLDQxnv__NfgH7i',$,'PatternsPath','Default patterns SVG',.P_SINGLEVALUE.,'IfcURIReference',$,$,$,$,$,.READWRITE.);
|
||||||
#23=IFCPROPERTYSETTEMPLATE('0I9merLinF5Ap$aZwaclgm',$,'BBIM_Dimension','',.PSET_OCCURRENCEDRIVEN.,'IfcAnnotation,IfcTypeProduct',(#24));
|
#23=IFCPROPERTYSETTEMPLATE('0I9merLinF5Ap$aZwaclgm',$,'BBIM_Dimension','',.PSET_OCCURRENCEDRIVEN.,'IfcAnnotation,IfcTypeProduct',(#24,#25));
|
||||||
#24=IFCSIMPLEPROPERTYTEMPLATE('1rL2AbQsXD8RbpoWH5pYOV',$,'ShowDescriptionOnly','Hide the measurement values and show only annotation description',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
|
#24=IFCSIMPLEPROPERTYTEMPLATE('1rL2AbQsXD8RbpoWH5pYOV',$,'ShowDescriptionOnly','Hide the measurement values and show only annotation description',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
|
||||||
|
#25=IFCSIMPLEPROPERTYTEMPLATE('0SVyOfB0rC2xNfdRYf3XvY',$,'SuppressZeroInches','Suppress 0 inch values in dimension annotation text (for example: 12'' - 0" -> 12'')',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
|
||||||
ENDSEC;
|
ENDSEC;
|
||||||
END-ISO-10303-21;
|
END-ISO-10303-21;
|
||||||
|
|||||||
@@ -276,11 +276,15 @@ class DecoratorData:
|
|||||||
if classes and "oblique" in classes.lower().split():
|
if classes and "oblique" in classes.lower().split():
|
||||||
dimension_style = "oblique"
|
dimension_style = "oblique"
|
||||||
|
|
||||||
show_description_only = (
|
pset_data = ifcopenshell.util.element.get_pset(element, "BBIM_Dimension") or {}
|
||||||
ifcopenshell.util.element.get_pset(element, "BBIM_Dimension", "ShowDescriptionOnly") or False
|
show_description_only = pset_data.get("ShowDescriptionOnly", False)
|
||||||
)
|
suppress_zero_inches = pset_data.get("SuppressZeroInches", False)
|
||||||
|
|
||||||
dimension_data = {"dimension_style": dimension_style, "show_description_only": show_description_only}
|
dimension_data = {
|
||||||
|
"dimension_style": dimension_style,
|
||||||
|
"show_description_only": show_description_only,
|
||||||
|
"suppress_zero_inches": suppress_zero_inches,
|
||||||
|
}
|
||||||
cls.data[obj.name] = dimension_data
|
cls.data[obj.name] = dimension_data
|
||||||
return dimension_data
|
return dimension_data
|
||||||
|
|
||||||
|
|||||||
@@ -570,7 +570,8 @@ class DimensionDecorator(BaseDecorator):
|
|||||||
|
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
description = element.Description
|
description = element.Description
|
||||||
show_description_only = DecoratorData.get_dimension_data(obj)["show_description_only"]
|
dimension_data = DecoratorData.get_dimension_data(obj)
|
||||||
|
show_description_only = dimension_data["show_description_only"]
|
||||||
|
|
||||||
for i0, i1 in indices:
|
for i0, i1 in indices:
|
||||||
v0 = Vector(vertices[i0])
|
v0 = Vector(vertices[i0])
|
||||||
@@ -583,6 +584,8 @@ class DimensionDecorator(BaseDecorator):
|
|||||||
|
|
||||||
if not show_description_only:
|
if not show_description_only:
|
||||||
length = (v1 - v0).length
|
length = (v1 - v0).length
|
||||||
|
# TODO: same distance format function as in svg?
|
||||||
|
# requires storing drawing precision and decimal_places from pset to data.py
|
||||||
text = self.format_value(context, length)
|
text = self.format_value(context, length)
|
||||||
|
|
||||||
self.draw_label(context, text, p0 + text_dir * 0.5, text_dir, box_alignment="bottom-middle")
|
self.draw_label(context, text, p0 + text_dir * 0.5, text_dir, box_alignment="bottom-middle")
|
||||||
|
|||||||
@@ -120,7 +120,9 @@ class BoundingBox:
|
|||||||
|
|
||||||
# This function stolen from https://github.com/kevancress/MeasureIt_ARCH/blob/dcf607ce0896aa2284463c6b4ae9cd023fc54cbe/measureit_arch_baseclass.py
|
# This function stolen from https://github.com/kevancress/MeasureIt_ARCH/blob/dcf607ce0896aa2284463c6b4ae9cd023fc54cbe/measureit_arch_baseclass.py
|
||||||
# MeasureIt-ARCH is GPL-v3
|
# MeasureIt-ARCH is GPL-v3
|
||||||
def format_distance(value, isArea=False, hide_units=True, precision=None, decimal_places=None):
|
def format_distance(
|
||||||
|
value, isArea=False, hide_units=True, precision=None, decimal_places=None, suppress_zero_inches=False
|
||||||
|
):
|
||||||
s_code = "\u00b2" # Superscript two THIS IS LEGACY (but being kept for when Area Measurements are re-implimented)
|
s_code = "\u00b2" # Superscript two THIS IS LEGACY (but being kept for when Area Measurements are re-implimented)
|
||||||
|
|
||||||
# Get Scene Unit Settings
|
# Get Scene Unit Settings
|
||||||
@@ -183,18 +185,19 @@ def format_distance(value, isArea=False, hide_units=True, precision=None, decima
|
|||||||
inches = 0
|
inches = 0
|
||||||
|
|
||||||
if not isArea:
|
if not isArea:
|
||||||
|
add_inches = bool(inches) or not suppress_zero_inches
|
||||||
tx_dist = ""
|
tx_dist = ""
|
||||||
if feet:
|
if feet:
|
||||||
tx_dist += str(feet) + "'"
|
tx_dist += str(feet) + "'"
|
||||||
if feet and inches:
|
if feet and add_inches:
|
||||||
tx_dist += " - "
|
tx_dist += " - "
|
||||||
if inches:
|
if add_inches:
|
||||||
tx_dist += str(inches)
|
tx_dist += str(inches)
|
||||||
if inches and frac:
|
if add_inches and frac:
|
||||||
tx_dist += " "
|
tx_dist += " "
|
||||||
if frac:
|
if frac:
|
||||||
tx_dist += str(frac) + "/" + str(base)
|
tx_dist += str(frac) + "/" + str(base)
|
||||||
if inches or frac:
|
if add_inches or frac:
|
||||||
tx_dist += '"'
|
tx_dist += '"'
|
||||||
else:
|
else:
|
||||||
tx_dist = str("%1.3f" % (value * toInches / inPerFoot)) + " sq. ft."
|
tx_dist = str("%1.3f" % (value * toInches / inPerFoot)) + " sq. ft."
|
||||||
|
|||||||
@@ -1056,7 +1056,8 @@ class SvgWriter:
|
|||||||
matrix_world = obj.matrix_world
|
matrix_world = obj.matrix_world
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
dimension_text = element.Description
|
dimension_text = element.Description
|
||||||
show_description_only = DecoratorData.get_dimension_data(obj)["show_description_only"]
|
dimension_data = DecoratorData.get_dimension_data(obj)
|
||||||
|
|
||||||
for spline in obj.data.splines:
|
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):
|
||||||
@@ -1070,7 +1071,8 @@ class SvgWriter:
|
|||||||
classes,
|
classes,
|
||||||
dimension_text,
|
dimension_text,
|
||||||
text_format=lambda x: "D" + x,
|
text_format=lambda x: "D" + x,
|
||||||
show_description_only=show_description_only,
|
show_description_only=dimension_data["show_description_only"],
|
||||||
|
suppress_zero_inches=dimension_data["suppress_zero_inches"],
|
||||||
)
|
)
|
||||||
|
|
||||||
def draw_dimension_annotations(self, obj):
|
def draw_dimension_annotations(self, obj):
|
||||||
@@ -1078,7 +1080,8 @@ class SvgWriter:
|
|||||||
matrix_world = obj.matrix_world
|
matrix_world = obj.matrix_world
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
dimension_text = element.Description
|
dimension_text = element.Description
|
||||||
show_description_only = DecoratorData.get_dimension_data(obj)["show_description_only"]
|
dimension_data = DecoratorData.get_dimension_data(obj)
|
||||||
|
|
||||||
for spline in obj.data.splines:
|
for spline in obj.data.splines:
|
||||||
points = self.get_spline_points(spline)
|
points = self.get_spline_points(spline)
|
||||||
for i in range(len(points) - 1):
|
for i in range(len(points) - 1):
|
||||||
@@ -1089,7 +1092,8 @@ class SvgWriter:
|
|||||||
v1_global,
|
v1_global,
|
||||||
classes,
|
classes,
|
||||||
dimension_text=dimension_text,
|
dimension_text=dimension_text,
|
||||||
show_description_only=show_description_only,
|
show_description_only=dimension_data["show_description_only"],
|
||||||
|
suppress_zero_inches=dimension_data["suppress_zero_inches"],
|
||||||
)
|
)
|
||||||
|
|
||||||
def draw_measureit_arch_dimension_annotations(self):
|
def draw_measureit_arch_dimension_annotations(self):
|
||||||
@@ -1105,7 +1109,14 @@ class SvgWriter:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def draw_dimension_annotation(
|
def draw_dimension_annotation(
|
||||||
self, v0_global, v1_global, classes, dimension_text=None, text_format=lambda x: x, show_description_only=False
|
self,
|
||||||
|
v0_global,
|
||||||
|
v1_global,
|
||||||
|
classes,
|
||||||
|
dimension_text=None,
|
||||||
|
text_format=lambda x: x,
|
||||||
|
show_description_only=False,
|
||||||
|
suppress_zero_inches=False,
|
||||||
):
|
):
|
||||||
offset = Vector([self.raw_width, self.raw_height]) / 2
|
offset = Vector([self.raw_width, self.raw_height]) / 2
|
||||||
v0 = self.project_point_onto_camera(v0_global)
|
v0 = self.project_point_onto_camera(v0_global)
|
||||||
@@ -1116,7 +1127,12 @@ class SvgWriter:
|
|||||||
vector = end - start
|
vector = end - start
|
||||||
perpendicular = Vector((vector.y, -vector.x)).normalized()
|
perpendicular = Vector((vector.y, -vector.x)).normalized()
|
||||||
dimension = (v1_global - v0_global).length
|
dimension = (v1_global - v0_global).length
|
||||||
dimension = helper.format_distance(dimension, precision=self.precision, decimal_places=self.decimal_places)
|
dimension = helper.format_distance(
|
||||||
|
dimension,
|
||||||
|
precision=self.precision,
|
||||||
|
decimal_places=self.decimal_places,
|
||||||
|
suppress_zero_inches=suppress_zero_inches,
|
||||||
|
)
|
||||||
sheet_dimension = (end - start).length
|
sheet_dimension = (end - start).length
|
||||||
|
|
||||||
# if annotation can't fit offset text to the right of marker
|
# if annotation can't fit offset text to the right of marker
|
||||||
|
|||||||
Reference in New Issue
Block a user