mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +00:00
snapshot
This commit is contained in:
@@ -28,11 +28,13 @@ 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,IfcTypeProduct',(#25,#26,#27,#28));
|
#24=IFCPROPERTYSETTEMPLATE('0I9merLinF5Ap$aZwaclgm',$,'BBIM_Dimension','',.PSET_TYPEDRIVENOVERRIDE.,'IfcAnnotation/DIMENSION,IfcTypeProduct',(#25,#26,#27,#28,#30));
|
||||||
#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.);
|
||||||
#28=IFCSIMPLEPROPERTYTEMPLATE('0bnzttUb9BPuN597uNTXOE',$,'TextSuffix','Text to add after annotation measurement value',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
|
#28=IFCSIMPLEPROPERTYTEMPLATE('0bnzttUb9BPuN597uNTXOE',$,'TextSuffix','Text to add after annotation measurement value',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
|
||||||
#29=IFCSIMPLEPROPERTYTEMPLATE('2pJmUDpB50VBdCOib1zcJJ',$,'Newline_At','',.P_SINGLEVALUE.,'IfcInteger',$,$,$,$,$,.READWRITE.);
|
#29=IFCSIMPLEPROPERTYTEMPLATE('2pJmUDpB50VBdCOib1zcJJ',$,'Newline_At','',.P_SINGLEVALUE.,'IfcInteger',$,$,$,$,$,.READWRITE.);
|
||||||
|
#30=IFCSIMPLEPROPERTYTEMPLATE('2TJn72t_v2cvBUG916Dpev',$,'Unit_Primary','Dimension''s primary unit',.P_ENUMERATEDVALUE.,'IfcText',$,#31,$,$,$,.READWRITE.);
|
||||||
|
#31=IFCPROPERTYENUMERATION('Unit_Primary',(IFCTEXT('Feet and Inches - Fractional'),IFCTEXT('Feet - Decimal'),IFCTEXT('Inches - Fractional'),IFCTEXT('Inches - Decimal'),IFCTEXT('Meters'),IFCTEXT('Decimeters'),IFCTEXT('Centimeters'),IFCTEXT('Millimeters')),$);
|
||||||
ENDSEC;
|
ENDSEC;
|
||||||
END-ISO-10303-21;
|
END-ISO-10303-21;
|
||||||
|
|||||||
@@ -376,6 +376,11 @@ class DecoratorData:
|
|||||||
fill_bg = True
|
fill_bg = True
|
||||||
|
|
||||||
pset_data = ifcopenshell.util.element.get_pset(element, "BBIM_Dimension") or {}
|
pset_data = ifcopenshell.util.element.get_pset(element, "BBIM_Dimension") or {}
|
||||||
|
unit_primary = pset_data.get("Unit_Primary", "")
|
||||||
|
if not unit_primary:
|
||||||
|
unit_primary = ''
|
||||||
|
else:
|
||||||
|
unit_primary = pset_data.get("Unit_Primary", "")[0]
|
||||||
show_description_only = pset_data.get("ShowDescriptionOnly", False)
|
show_description_only = pset_data.get("ShowDescriptionOnly", False)
|
||||||
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 ""
|
||||||
@@ -383,6 +388,7 @@ class DecoratorData:
|
|||||||
|
|
||||||
dimension_data = {
|
dimension_data = {
|
||||||
"dimension_style": dimension_style,
|
"dimension_style": dimension_style,
|
||||||
|
"unit_primary": unit_primary,
|
||||||
"show_description_only": show_description_only,
|
"show_description_only": show_description_only,
|
||||||
"suppress_zero_inches": suppress_zero_inches,
|
"suppress_zero_inches": suppress_zero_inches,
|
||||||
"text_prefix": text_prefix,
|
"text_prefix": text_prefix,
|
||||||
|
|||||||
@@ -475,6 +475,7 @@ class BaseDecorator:
|
|||||||
blf.disable(font_id, blf.SHADOW)
|
blf.disable(font_id, blf.SHADOW)
|
||||||
|
|
||||||
def draw_dimension_text(self, context, get_text, description, dimension_data, **draw_label_kwargs):
|
def draw_dimension_text(self, context, get_text, description, dimension_data, **draw_label_kwargs):
|
||||||
|
unit_primary = dimension_data["unit_primary"]
|
||||||
prefix = dimension_data["text_prefix"]
|
prefix = dimension_data["text_prefix"]
|
||||||
suffix = dimension_data["text_suffix"]
|
suffix = dimension_data["text_suffix"]
|
||||||
show_description_only = dimension_data["show_description_only"]
|
show_description_only = dimension_data["show_description_only"]
|
||||||
@@ -493,14 +494,37 @@ class BaseDecorator:
|
|||||||
self.draw_label(context, text=text, line_no=line_number_start, multiline=True, **draw_label_kwargs)
|
self.draw_label(context, text=text, line_no=line_number_start, multiline=True, **draw_label_kwargs)
|
||||||
|
|
||||||
@lru_cache(maxsize=None)
|
@lru_cache(maxsize=None)
|
||||||
def format_value(self, context, value):
|
def format_value(self, context, value, unit_primary):
|
||||||
drawing_pset_data = DrawingsData.data["active_drawing_pset_data"]
|
drawing_pset_data = DrawingsData.data["active_drawing_pset_data"]
|
||||||
precision = drawing_pset_data.get("MetricPrecision", None)
|
unit_system = bpy.context.scene.unit_settings.system
|
||||||
if not precision:
|
|
||||||
|
imperial_units = {
|
||||||
|
"Inches - Decimal",
|
||||||
|
"Feet - Decimal",
|
||||||
|
"Feet and Inches - Fractional",
|
||||||
|
"Inches - Fractional",
|
||||||
|
}
|
||||||
|
|
||||||
|
metric_units = {
|
||||||
|
"Meters",
|
||||||
|
"Decimeters",
|
||||||
|
"Centimeters",
|
||||||
|
"Millimeters"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
unit_system == "IMPERIAL"
|
||||||
|
and unit_primary in imperial_units
|
||||||
|
and unit_primary not in metric_units
|
||||||
|
):
|
||||||
|
|
||||||
precision = drawing_pset_data.get("ImperialPrecision", None)
|
precision = drawing_pset_data.get("ImperialPrecision", None)
|
||||||
|
else:
|
||||||
|
precision = drawing_pset_data.get("MetricPrecision", None)
|
||||||
|
|
||||||
|
|
||||||
decimal_places = drawing_pset_data.get("DecimalPlaces", None)
|
decimal_places = drawing_pset_data.get("DecimalPlaces", None)
|
||||||
return format_distance(value, precision=precision, decimal_places=decimal_places)
|
return format_distance(value, precision=precision, decimal_places=decimal_places, unit_primary=unit_primary)
|
||||||
|
|
||||||
def draw_asterisk(self, context: bpy.types.Context, pos: Vector, rotation: float = 0.0, scale: float = 1.0) -> None:
|
def draw_asterisk(self, context: bpy.types.Context, pos: Vector, rotation: float = 0.0, scale: float = 1.0) -> None:
|
||||||
"""`pos` is a world space position\n
|
"""`pos` is a world space position\n
|
||||||
@@ -709,6 +733,7 @@ class DimensionDecorator(BaseDecorator):
|
|||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
description = element.Description
|
description = element.Description
|
||||||
dimension_data = DecoratorData.get_dimension_data(obj)
|
dimension_data = DecoratorData.get_dimension_data(obj)
|
||||||
|
unit_primary = dimension_data["unit_primary"]
|
||||||
show_description_only = dimension_data["show_description_only"]
|
show_description_only = dimension_data["show_description_only"]
|
||||||
text_prefix = dimension_data["text_prefix"]
|
text_prefix = dimension_data["text_prefix"]
|
||||||
text_suffix = dimension_data["text_suffix"]
|
text_suffix = dimension_data["text_suffix"]
|
||||||
@@ -735,7 +760,7 @@ 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(context, length)
|
text = self.format_value(context, length, unit_primary)
|
||||||
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
|
||||||
@@ -937,6 +962,7 @@ class RadiusDecorator(BaseDecorator):
|
|||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
description = element.Description
|
description = element.Description
|
||||||
dimension_data = DecoratorData.get_dimension_data(obj)
|
dimension_data = DecoratorData.get_dimension_data(obj)
|
||||||
|
unit_primary = dimension_data["unit_primary"]
|
||||||
viewportDrawingScale = self.get_viewport_drawing_scale(context)
|
viewportDrawingScale = self.get_viewport_drawing_scale(context)
|
||||||
text_offset = 20 * viewportDrawingScale
|
text_offset = 20 * viewportDrawingScale
|
||||||
|
|
||||||
@@ -944,7 +970,7 @@ 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)
|
return "R" + self.format_value(context, length, unit_primary)
|
||||||
|
|
||||||
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"
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ def format_distance(
|
|||||||
value,
|
value,
|
||||||
isArea=False,
|
isArea=False,
|
||||||
hide_units=True,
|
hide_units=True,
|
||||||
|
unit_primary = None,
|
||||||
precision=None,
|
precision=None,
|
||||||
decimal_places=None,
|
decimal_places=None,
|
||||||
suppress_zero_inches=False,
|
suppress_zero_inches=False,
|
||||||
@@ -139,7 +140,24 @@ def format_distance(
|
|||||||
value *= scaleFactor
|
value *= scaleFactor
|
||||||
|
|
||||||
# Imperial Formatting
|
# Imperial Formatting
|
||||||
if unit_system == "IMPERIAL":
|
imperial_units = {
|
||||||
|
"Inches - Decimal",
|
||||||
|
"Feet - Decimal",
|
||||||
|
"Feet and Inches - Fractional",
|
||||||
|
"Inches - Fractional",
|
||||||
|
}
|
||||||
|
|
||||||
|
metric_units = {
|
||||||
|
"Meters",
|
||||||
|
"Decimeters",
|
||||||
|
"Centimeters",
|
||||||
|
"Millimeters"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
(unit_system == "IMPERIAL" or unit_primary in imperial_units)
|
||||||
|
and unit_primary not in metric_units
|
||||||
|
):
|
||||||
if in_unit_length:
|
if in_unit_length:
|
||||||
if unit_length == "INCHES":
|
if unit_length == "INCHES":
|
||||||
toInches = 1
|
toInches = 1
|
||||||
@@ -164,12 +182,19 @@ def format_distance(
|
|||||||
|
|
||||||
# Separate ft and inches
|
# Separate ft and inches
|
||||||
# Unless Inches are the specified Length Unit
|
# Unless Inches are the specified Length Unit
|
||||||
if unit_length != "INCHES":
|
if (
|
||||||
|
unit_length != "INCHES"
|
||||||
|
and unit_primary != "Feet - Decimal"
|
||||||
|
and unit_system != "METRIC"
|
||||||
|
or unit_primary == "Feet and Inches - Fractional"
|
||||||
|
):
|
||||||
feet = int(decInches / inPerFoot) # remove decimal
|
feet = int(decInches / inPerFoot) # remove decimal
|
||||||
decInches -= feet * inPerFoot
|
decInches -= feet * inPerFoot
|
||||||
else:
|
else:
|
||||||
feet = 0
|
feet = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Separate Fractional Inches
|
# Separate Fractional Inches
|
||||||
decInches = abs(decInches) # ignore the sign for inches
|
decInches = abs(decInches) # ignore the sign for inches
|
||||||
inches = math.floor(decInches) # remove decimal
|
inches = math.floor(decInches) # remove decimal
|
||||||
@@ -224,12 +249,33 @@ def format_distance(
|
|||||||
tx_dist += str(frac) + "/" + str(base)
|
tx_dist += str(frac) + "/" + str(base)
|
||||||
if add_inches or frac:
|
if add_inches or frac:
|
||||||
tx_dist += '"'
|
tx_dist += '"'
|
||||||
|
if unit_primary == "Inches - Decimal":
|
||||||
|
value = decInches
|
||||||
|
if decimal_places:
|
||||||
|
value = round(value, decimal_places)
|
||||||
|
tx_dist = f"{str(value)}\""
|
||||||
|
if unit_primary == "Feet - Decimal":
|
||||||
|
value = decInches/12
|
||||||
|
if decimal_places:
|
||||||
|
value = round(value, decimal_places)
|
||||||
|
tx_dist = f"{str(value)}\'"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
tx_dist = str("%1.3f" % (value * toInches / inPerFoot)) + " sq. ft."
|
tx_dist = str("%1.3f" % (value * toInches / inPerFoot)) + " sq. ft."
|
||||||
|
|
||||||
# METRIC FORMATTING
|
# METRIC FORMATTING
|
||||||
elif unit_system == "METRIC":
|
elif (
|
||||||
if in_unit_length:
|
unit_system == "METRIC"
|
||||||
|
or unit_primary == "Meters"
|
||||||
|
or unit_primary == "Decimeters"
|
||||||
|
or unit_primary == "Centimeters"
|
||||||
|
or unit_primary == "Millimeters"
|
||||||
|
):
|
||||||
|
if(
|
||||||
|
in_unit_length
|
||||||
|
):
|
||||||
if unit_length == "CENTIMETERS":
|
if unit_length == "CENTIMETERS":
|
||||||
value = value / 100
|
value = value / 100
|
||||||
if unit_length == "MILLIMETERS":
|
if unit_length == "MILLIMETERS":
|
||||||
@@ -242,14 +288,27 @@ def format_distance(
|
|||||||
fmt = "%1." + str(decimal_places) + "f"
|
fmt = "%1." + str(decimal_places) + "f"
|
||||||
|
|
||||||
# Meters
|
# Meters
|
||||||
if unit_length == "METERS":
|
if (
|
||||||
|
(unit_length == "METERS" or unit_primary == "Meters")
|
||||||
|
and unit_primary != "Decimeters"
|
||||||
|
and unit_primary != "Centimeters"
|
||||||
|
and unit_primary != "Millimeters"
|
||||||
|
):
|
||||||
if decimal_places is None:
|
if decimal_places is None:
|
||||||
fmt = "%1.3f"
|
fmt = "%1.3f"
|
||||||
if hide_units is False:
|
if hide_units is False:
|
||||||
fmt += " m"
|
fmt += " m"
|
||||||
tx_dist = fmt % value
|
tx_dist = fmt % value
|
||||||
# Centimeters
|
# Decimeters
|
||||||
elif unit_length == "CENTIMETERS":
|
elif unit_length == "DECIMETERS" or unit_primary == "Decimeters":
|
||||||
|
if decimal_places is None:
|
||||||
|
fmt = "%1.1f"
|
||||||
|
if hide_units is False:
|
||||||
|
fmt += " cm"
|
||||||
|
d_cm = value * (10)
|
||||||
|
tx_dist = fmt % d_cm
|
||||||
|
# Centimeters
|
||||||
|
elif unit_length == "CENTIMETERS" or unit_primary == "Centimeters":
|
||||||
if decimal_places is None:
|
if decimal_places is None:
|
||||||
fmt = "%1.1f"
|
fmt = "%1.1f"
|
||||||
if hide_units is False:
|
if hide_units is False:
|
||||||
@@ -257,7 +316,7 @@ def format_distance(
|
|||||||
d_cm = value * (100)
|
d_cm = value * (100)
|
||||||
tx_dist = fmt % d_cm
|
tx_dist = fmt % d_cm
|
||||||
# Millimeters
|
# Millimeters
|
||||||
elif unit_length == "MILLIMETERS":
|
elif unit_length == "MILLIMETERS" or unit_primary == "Millimeters":
|
||||||
if decimal_places is None:
|
if decimal_places is None:
|
||||||
fmt = "%1.0f"
|
fmt = "%1.0f"
|
||||||
if hide_units is False:
|
if hide_units is False:
|
||||||
@@ -291,6 +350,8 @@ def format_distance(
|
|||||||
else:
|
else:
|
||||||
tx_dist = fmt % value
|
tx_dist = fmt % value
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return tx_dist
|
return tx_dist
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1273,6 +1273,7 @@ class SvgWriter:
|
|||||||
v1_global,
|
v1_global,
|
||||||
classes,
|
classes,
|
||||||
dimension_text=dimension_text,
|
dimension_text=dimension_text,
|
||||||
|
unit_primary = dimension_data["unit_primary"],
|
||||||
show_description_only=dimension_data["show_description_only"],
|
show_description_only=dimension_data["show_description_only"],
|
||||||
suppress_zero_inches=dimension_data["suppress_zero_inches"],
|
suppress_zero_inches=dimension_data["suppress_zero_inches"],
|
||||||
text_prefix=dimension_data["text_prefix"],
|
text_prefix=dimension_data["text_prefix"],
|
||||||
@@ -1299,6 +1300,7 @@ class SvgWriter:
|
|||||||
classes,
|
classes,
|
||||||
dimension_text=None,
|
dimension_text=None,
|
||||||
text_format=lambda x: x,
|
text_format=lambda x: x,
|
||||||
|
unit_primary = None,
|
||||||
show_description_only=False,
|
show_description_only=False,
|
||||||
suppress_zero_inches=False,
|
suppress_zero_inches=False,
|
||||||
text_prefix="",
|
text_prefix="",
|
||||||
@@ -1334,6 +1336,7 @@ class SvgWriter:
|
|||||||
dimension = (v1_global - v0_global).length
|
dimension = (v1_global - v0_global).length
|
||||||
dimension = helper.format_distance(
|
dimension = helper.format_distance(
|
||||||
dimension,
|
dimension,
|
||||||
|
unit_primary = unit_primary,
|
||||||
precision=self.precision,
|
precision=self.precision,
|
||||||
decimal_places=self.decimal_places,
|
decimal_places=self.decimal_places,
|
||||||
suppress_zero_inches=suppress_zero_inches,
|
suppress_zero_inches=suppress_zero_inches,
|
||||||
|
|||||||
Reference in New Issue
Block a user