Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/bonsai/bonsai/bim/data/pset/Psets_BBIM_Annotation.ifc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DATA;
#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.);
#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,#35,#27,#28,#30,#34));
#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.);
#27=IFCSIMPLEPROPERTYTEMPLATE('2bUmj458PBqPAtUoI3MXsb',$,'TextPrefix','Text to add before annotation measurement value',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
Expand All @@ -37,6 +37,8 @@ DATA;
#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')),$);
#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.);
#35=IFCSIMPLEPROPERTYTEMPLATE('3Nf6Qs1mT0pWxBuCvDyEzA',$,'SuppressZeroFeet','Suppress 0 feet in dimension annotation text (for example: 0'' - 3 1/2" -> 3 1/2")',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
#33=IFCSIMPLEPROPERTYTEMPLATE('22TrcxF8jFNB4buSmzjGEF',$,'List_Separator','',.P_SINGLEVALUE.,'IfcText',$,$,$,$,$,.READWRITE.);
ENDSEC;
END-ISO-10303-21;
9 changes: 6 additions & 3 deletions src/bonsai/bonsai/bim/module/drawing/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,19 +799,22 @@ def get_dimension_data(cls, obj: bpy.types.Object) -> dict[str, Any]:
pset_data = ifcopenshell.util.element.get_pset(element, "BBIM_Dimension") or {}
show_description_only = pset_data.get("ShowDescriptionOnly", False)
suppress_zero_inches = pset_data.get("SuppressZeroInches", False)
suppress_zero_feet = pset_data.get("SuppressZeroFeet", False)
text_prefix = pset_data.get("TextPrefix", None) or ""
text_suffix = pset_data.get("TextSuffix", None) or ""
custom_unit_list = pset_data.get("CustomUnit", None) or ""
custom_unit = custom_unit_list[0] if custom_unit_list else ""
custom_units = list(pset_data.get("CustomUnit", None) or [])
separator = pset_data.get("Separator", None) or " / "

return {
"dimension_style": dimension_style,
"show_description_only": show_description_only,
"suppress_zero_inches": suppress_zero_inches,
"suppress_zero_feet": suppress_zero_feet,
"text_prefix": text_prefix,
"text_suffix": text_suffix,
"fill_bg": fill_bg,
"custom_unit": custom_unit,
"custom_units": custom_units,
"separator": separator,
}

@classmethod
Expand Down
25 changes: 17 additions & 8 deletions src/bonsai/bonsai/bim/module/drawing/decoration.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@
self.draw_label(context, text=text, line_no=line_number_start, multiline=True, **draw_label_kwargs)

@cache
def format_value(self, context, value, suppress_zero_inches=False, custom_unit=None, in_unit_length=False):
def format_value(self, context, value, suppress_zero_inches=False, suppress_zero_feet=False, custom_unit=None, in_unit_length=False):

Check failure on line 493 in src/bonsai/bonsai/bim/module/drawing/decoration.py

View workflow job for this annotation

GitHub Actions / lint-formatting

Black Format Issue

Black formatting issue in /home/runner/work/IfcOpenShell/IfcOpenShell/src/bonsai/bonsai/bim/module/drawing/decoration.py

Check failure on line 493 in src/bonsai/bonsai/bim/module/drawing/decoration.py

View workflow job for this annotation

GitHub Actions / lint-formatting

Black Format Issue

Black formatting issue in /home/runner/work/IfcOpenShell/IfcOpenShell/src/bonsai/bonsai/bim/module/drawing/decoration.py
drawing_pset_data = DrawingsData.data["active_drawing_pset_data"]
precision = drawing_pset_data.get("MetricPrecision", None)
if not precision:
Expand All @@ -502,6 +502,7 @@
precision=precision,
decimal_places=decimal_places,
suppress_zero_inches=suppress_zero_inches,
suppress_zero_feet=suppress_zero_feet,
custom_unit=custom_unit,
in_unit_length=in_unit_length,
)
Expand Down Expand Up @@ -745,12 +746,18 @@

if not show_description_only:
length = (v1 - v0).length
text = self.format_value(
context,
length,
suppress_zero_inches=dimension_data["suppress_zero_inches"],
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,
suppress_zero_inches=dimension_data["suppress_zero_inches"],
suppress_zero_feet=dimension_data["suppress_zero_feet"],
custom_unit=unit,
)
for unit in units_to_format
]
text = dimension_data["separator"].join(str(p) for p in parts)
if isinstance(self, DiameterDecorator):
text = "D" + text
text = text_prefix + text + text_suffix
Expand Down Expand Up @@ -965,7 +972,9 @@

def get_text():
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, suppress_zero_feet=dimension_data["suppress_zero_feet"], custom_unit=unit) for unit in units_to_format]

Check failure on line 976 in src/bonsai/bonsai/bim/module/drawing/decoration.py

View workflow job for this annotation

GitHub Actions / lint-formatting

Black Format Issue

Black formatting issue in /home/runner/work/IfcOpenShell/IfcOpenShell/src/bonsai/bonsai/bim/module/drawing/decoration.py

Check failure on line 976 in src/bonsai/bonsai/bim/module/drawing/decoration.py

View workflow job for this annotation

GitHub Actions / lint-formatting

Black Format Issue

Black formatting issue in /home/runner/work/IfcOpenShell/IfcOpenShell/src/bonsai/bonsai/bim/module/drawing/decoration.py
return "R" + dimension_data["separator"].join(str(p) for p in parts)

self.draw_dimension_text(
context, get_text, description, dimension_data, pos=pos, text_dir=Vector((1, 0)), box_alignment="center"
Expand Down
5 changes: 3 additions & 2 deletions src/bonsai/bonsai/bim/module/drawing/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def format_distance(
precision=None,
decimal_places=None,
suppress_zero_inches=False,
suppress_zero_feet=False,
in_unit_length=False,
custom_unit=None,
):
Expand Down Expand Up @@ -310,10 +311,10 @@ def format_distance(
tx_dist = ""
if feet:
tx_dist += str(feet) + "'"
if not feet and not add_inches:
if not feet and not add_inches and not suppress_zero_feet:
tx_dist += str(feet) + "'"

if not feet and add_inches and unit_length != "INCHES":
if not feet and add_inches and unit_length != "INCHES" and not suppress_zero_feet:
if value < 0:
tx_dist += "-0' - "
else:
Expand Down
53 changes: 34 additions & 19 deletions src/bonsai/bonsai/bim/module/drawing/svgwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,14 +1371,18 @@ def draw_radius_annotations(self, obj: bpy.types.Object) -> None:

def get_text():
radius = (points[-1].co - points[-2].co).length
radius = helper.format_distance(
radius,
precision=self.precision,
decimal_places=self.decimal_places,
custom_unit=dimension_data["custom_unit"],
)
text = f"R{radius}"
return text
units_to_format = dimension_data["custom_units"] if dimension_data["custom_units"] else [None]
parts = [
helper.format_distance(
radius,
precision=self.precision,
decimal_places=self.decimal_places,
suppress_zero_feet=dimension_data["suppress_zero_feet"],
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(
get_text, tag, dimension_data, text_position=text_position, class_str="RADIUS", box_alignment="center"
Expand Down Expand Up @@ -1503,10 +1507,12 @@ def draw_diameter_annotations(self, obj: bpy.types.Object) -> None:
text_format=lambda x: "D" + x,
show_description_only=dimension_data["show_description_only"],
suppress_zero_inches=dimension_data["suppress_zero_inches"],
suppress_zero_feet=dimension_data["suppress_zero_feet"],
text_prefix=dimension_data["text_prefix"],
text_suffix=dimension_data["text_suffix"],
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:
Expand All @@ -1529,10 +1535,12 @@ def draw_dimension_annotations(self, obj: bpy.types.Object) -> None:
dimension_text=dimension_text,
show_description_only=dimension_data["show_description_only"],
suppress_zero_inches=dimension_data["suppress_zero_inches"],
suppress_zero_feet=dimension_data["suppress_zero_feet"],
text_prefix=dimension_data["text_prefix"],
text_suffix=dimension_data["text_suffix"],
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:
Expand All @@ -1556,10 +1564,12 @@ def draw_dimension_annotation(
text_format=lambda x: x,
show_description_only=False,
suppress_zero_inches=False,
suppress_zero_feet=False,
text_prefix="",
text_suffix="",
fill_bg=False,
custom_unit=None,
custom_units=None,
separator=" / ",
) -> None:
offset = Vector([self.raw_width, self.raw_height]) / 2
v0 = self.project_point_onto_camera(v0_global)
Expand Down Expand Up @@ -1588,14 +1598,19 @@ def draw_dimension_annotation(

if not show_description_only:
dimension = (v1_global - v0_global).length
dimension = helper.format_distance(
dimension,
precision=self.precision,
decimal_places=self.decimal_places,
suppress_zero_inches=suppress_zero_inches,
custom_unit=custom_unit,
)
text = text_prefix + str(dimension) + text_suffix
units_to_format = custom_units if custom_units else [None]
parts = [
helper.format_distance(
dimension,
precision=self.precision,
decimal_places=self.decimal_places,
suppress_zero_inches=suppress_zero_inches,
suppress_zero_feet=suppress_zero_feet,
custom_unit=unit,
)
for unit in units_to_format
]
text = text_prefix + separator.join(str(p) for p in parts) + text_suffix
else:
if not dimension_text:
return
Expand Down
Loading