closes #8060: add multiple customunits to the dimensions string.

This commit is contained in:
Ryan Schultz
2026-05-15 07:48:03 -05:00
parent 6f3acc84ee
commit 22c8aa1960
4 changed files with 49 additions and 30 deletions
@@ -28,7 +28,7 @@ DATA;
#21=IFCSIMPLEPROPERTYTEMPLATE('1UDakJ5_f7kBhggNSW4$h5',$,'SymbolsPath','Default symbols SVG',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.); #21=IFCSIMPLEPROPERTYTEMPLATE('1UDakJ5_f7kBhggNSW4$h5',$,'SymbolsPath','Default symbols SVG',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#22=IFCSIMPLEPROPERTYTEMPLATE('0d53LEtgLDQxnv__NfgH7i',$,'PatternsPath','Default patterns SVG',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.); #22=IFCSIMPLEPROPERTYTEMPLATE('0d53LEtgLDQxnv__NfgH7i',$,'PatternsPath','Default patterns SVG',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#23=IFCSIMPLEPROPERTYTEMPLATE('26qFNMv7nCHgU6Jd7Anga5',$,'ShadingStylesPath','Default shading styles',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.); #23=IFCSIMPLEPROPERTYTEMPLATE('26qFNMv7nCHgU6Jd7Anga5',$,'ShadingStylesPath','Default shading styles',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#24=IFCPROPERTYSETTEMPLATE('0I9merLinF5Ap$aZwaclgm',$,'BBIM_Dimension','',.PSET_TYPEDRIVENOVERRIDE.,'IfcAnnotation/DIMENSION,IfcAnnotation/RADIUS,IfcAnnotation/DIAMETER,IfcTypeProduct',(#25,#26,#27,#28,#30)); #24=IFCPROPERTYSETTEMPLATE('0I9merLinF5Ap$aZwaclgm',$,'BBIM_Dimension','',.PSET_TYPEDRIVENOVERRIDE.,'IfcAnnotation/DIMENSION,IfcAnnotation/RADIUS,IfcAnnotation/DIAMETER,IfcTypeProduct',(#25,#26,#27,#28,#30,#34));
#25=IFCSIMPLEPROPERTYTEMPLATE('1rL2AbQsXD8RbpoWH5pYOV',$,'ShowDescriptionOnly','Hide the measurement values and show only annotation description',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.); #25=IFCSIMPLEPROPERTYTEMPLATE('1rL2AbQsXD8RbpoWH5pYOV',$,'ShowDescriptionOnly','Hide the measurement values and show only annotation description',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
#26=IFCSIMPLEPROPERTYTEMPLATE('0SVyOfB0rC2xNfdRYf3XvY',$,'SuppressZeroInches','Suppress 0 inch values in dimension annotation text (for example: 12'' - 0" -> 12'')',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.); #26=IFCSIMPLEPROPERTYTEMPLATE('0SVyOfB0rC2xNfdRYf3XvY',$,'SuppressZeroInches','Suppress 0 inch values in dimension annotation text (for example: 12'' - 0" -> 12'')',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
#27=IFCSIMPLEPROPERTYTEMPLATE('2bUmj458PBqPAtUoI3MXsb',$,'TextPrefix','Text to add before annotation measurement value',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.); #27=IFCSIMPLEPROPERTYTEMPLATE('2bUmj458PBqPAtUoI3MXsb',$,'TextPrefix','Text to add before annotation measurement value',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
@@ -37,6 +37,7 @@ DATA;
#30=IFCSIMPLEPROPERTYTEMPLATE('2TJn72t_v2cvBUG916Dpev',$,'CustomUnit','Dimension''s custom unit',.P_ENUMERATEDVALUE.,'IfcText',$,#31,$,$,$,.READWRITE.); #30=IFCSIMPLEPROPERTYTEMPLATE('2TJn72t_v2cvBUG916Dpev',$,'CustomUnit','Dimension''s custom unit',.P_ENUMERATEDVALUE.,'IfcText',$,#31,$,$,$,.READWRITE.);
#31=IFCPROPERTYENUMERATION('CustomUnit',(IFCTEXT('Feet and Inches - Fractional'),IFCTEXT('Feet - Decimal'),IFCTEXT('Inches - Fractional'),IFCTEXT('Inches - Decimal'),IFCTEXT('Meters'),IFCTEXT('Decimeters'),IFCTEXT('Centimeters'),IFCTEXT('Millimeters')),$); #31=IFCPROPERTYENUMERATION('CustomUnit',(IFCTEXT('Feet and Inches - Fractional'),IFCTEXT('Feet - Decimal'),IFCTEXT('Inches - Fractional'),IFCTEXT('Inches - Decimal'),IFCTEXT('Meters'),IFCTEXT('Decimeters'),IFCTEXT('Centimeters'),IFCTEXT('Millimeters')),$);
#32=IFCSIMPLEPROPERTYTEMPLATE('0gjJzDYBX8P85qn1xcAOOo',$,'Reverse_List','',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.); #32=IFCSIMPLEPROPERTYTEMPLATE('0gjJzDYBX8P85qn1xcAOOo',$,'Reverse_List','',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
#34=IFCSIMPLEPROPERTYTEMPLATE('1Kx4Pm9nR8vBwZqTs2uYeL',$,'Separator','Characters placed between multiple dimension values when CustomUnit has more than one unit selected (default: '' / '')',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#33=IFCSIMPLEPROPERTYTEMPLATE('22TrcxF8jFNB4buSmzjGEF',$,'List_Separator','',.P_SINGLEVALUE.,'IfcText',$,$,$,$,$,.READWRITE.); #33=IFCSIMPLEPROPERTYTEMPLATE('22TrcxF8jFNB4buSmzjGEF',$,'List_Separator','',.P_SINGLEVALUE.,'IfcText',$,$,$,$,$,.READWRITE.);
ENDSEC; ENDSEC;
END-ISO-10303-21; END-ISO-10303-21;
+4 -3
View File
@@ -801,8 +801,8 @@ class DecoratorData:
suppress_zero_inches = pset_data.get("SuppressZeroInches", False) suppress_zero_inches = pset_data.get("SuppressZeroInches", False)
text_prefix = pset_data.get("TextPrefix", None) or "" text_prefix = pset_data.get("TextPrefix", None) or ""
text_suffix = pset_data.get("TextSuffix", None) or "" text_suffix = pset_data.get("TextSuffix", None) or ""
custom_unit_list = pset_data.get("CustomUnit", None) or "" custom_units = list(pset_data.get("CustomUnit", None) or [])
custom_unit = custom_unit_list[0] if custom_unit_list else "" separator = pset_data.get("Separator", None) or " / "
return { return {
"dimension_style": dimension_style, "dimension_style": dimension_style,
@@ -811,7 +811,8 @@ class DecoratorData:
"text_prefix": text_prefix, "text_prefix": text_prefix,
"text_suffix": text_suffix, "text_suffix": text_suffix,
"fill_bg": fill_bg, "fill_bg": fill_bg,
"custom_unit": custom_unit, "custom_units": custom_units,
"separator": separator,
} }
@classmethod @classmethod
@@ -749,12 +749,17 @@ class DimensionDecorator(BaseDecorator):
if not show_description_only: if not show_description_only:
length = (v1 - v0).length length = (v1 - v0).length
text = self.format_value( units_to_format = dimension_data["custom_units"] if dimension_data["custom_units"] else [None]
context, parts = [
length, self.format_value(
suppress_zero_inches=dimension_data["suppress_zero_inches"], context,
custom_unit=dimension_data["custom_unit"], length,
) suppress_zero_inches=dimension_data["suppress_zero_inches"],
custom_unit=unit,
)
for unit in units_to_format
]
text = dimension_data["separator"].join(str(p) for p in parts)
if isinstance(self, DiameterDecorator): if isinstance(self, DiameterDecorator):
text = "D" + text text = "D" + text
text = text_prefix + text + text_suffix text = text_prefix + text + text_suffix
@@ -969,7 +974,9 @@ class RadiusDecorator(BaseDecorator):
def get_text(): def get_text():
length = (spline_points[-1] - spline_points[-2]).length length = (spline_points[-1] - spline_points[-2]).length
return "R" + self.format_value(context, length, custom_unit=dimension_data["custom_unit"]) units_to_format = dimension_data["custom_units"] if dimension_data["custom_units"] else [None]
parts = [self.format_value(context, length, custom_unit=unit) for unit in units_to_format]
return "R" + dimension_data["separator"].join(str(p) for p in parts)
self.draw_dimension_text( self.draw_dimension_text(
context, get_text, description, dimension_data, pos=pos, text_dir=Vector((1, 0)), box_alignment="center" context, get_text, description, dimension_data, pos=pos, text_dir=Vector((1, 0)), box_alignment="center"
@@ -1367,14 +1367,17 @@ class SvgWriter:
def get_text(): def get_text():
radius = (points[-1].co - points[-2].co).length radius = (points[-1].co - points[-2].co).length
radius = helper.format_distance( units_to_format = dimension_data["custom_units"] if dimension_data["custom_units"] else [None]
radius, parts = [
precision=self.precision, helper.format_distance(
decimal_places=self.decimal_places, radius,
custom_unit=dimension_data["custom_unit"], precision=self.precision,
) decimal_places=self.decimal_places,
text = f"R{radius}" custom_unit=unit,
return text )
for unit in units_to_format
]
return "R" + dimension_data["separator"].join(str(p) for p in parts)
self.draw_dimension_text( self.draw_dimension_text(
get_text, tag, dimension_data, text_position=text_position, class_str="RADIUS", box_alignment="center" get_text, tag, dimension_data, text_position=text_position, class_str="RADIUS", box_alignment="center"
@@ -1504,7 +1507,8 @@ class SvgWriter:
text_prefix=dimension_data["text_prefix"], text_prefix=dimension_data["text_prefix"],
text_suffix=dimension_data["text_suffix"], text_suffix=dimension_data["text_suffix"],
fill_bg=dimension_data["fill_bg"], fill_bg=dimension_data["fill_bg"],
custom_unit=dimension_data["custom_unit"], custom_units=dimension_data["custom_units"],
separator=dimension_data["separator"],
) )
def draw_dimension_annotations(self, obj: bpy.types.Object) -> None: def draw_dimension_annotations(self, obj: bpy.types.Object) -> None:
@@ -1530,7 +1534,8 @@ class SvgWriter:
text_prefix=dimension_data["text_prefix"], text_prefix=dimension_data["text_prefix"],
text_suffix=dimension_data["text_suffix"], text_suffix=dimension_data["text_suffix"],
fill_bg=dimension_data["fill_bg"], fill_bg=dimension_data["fill_bg"],
custom_unit=dimension_data["custom_unit"], custom_units=dimension_data["custom_units"],
separator=dimension_data["separator"],
) )
def draw_measureit_arch_dimension_annotations(self) -> None: def draw_measureit_arch_dimension_annotations(self) -> None:
@@ -1557,7 +1562,8 @@ class SvgWriter:
text_prefix="", text_prefix="",
text_suffix="", text_suffix="",
fill_bg=False, fill_bg=False,
custom_unit=None, custom_units=None,
separator=" / ",
) -> None: ) -> None:
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)
@@ -1586,14 +1592,18 @@ class SvgWriter:
if not show_description_only: if not show_description_only:
dimension = (v1_global - v0_global).length dimension = (v1_global - v0_global).length
dimension = helper.format_distance( units_to_format = custom_units if custom_units else [None]
dimension, parts = [
precision=self.precision, helper.format_distance(
decimal_places=self.decimal_places, dimension,
suppress_zero_inches=suppress_zero_inches, precision=self.precision,
custom_unit=custom_unit, decimal_places=self.decimal_places,
) suppress_zero_inches=suppress_zero_inches,
text = text_prefix + str(dimension) + text_suffix custom_unit=unit,
)
for unit in units_to_format
]
text = text_prefix + separator.join(str(p) for p in parts) + text_suffix
else: else:
if not dimension_text: if not dimension_text:
return return