mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
fix #4665 - View layerset thicknesses in feet and inches format
This commit is contained in:
@@ -121,7 +121,13 @@ class BoundingBox:
|
||||
# This function stolen from https://github.com/kevancress/MeasureIt_ARCH/blob/dcf607ce0896aa2284463c6b4ae9cd023fc54cbe/measureit_arch_baseclass.py
|
||||
# MeasureIt-ARCH is GPL-v3
|
||||
def format_distance(
|
||||
value, isArea=False, hide_units=True, precision=None, decimal_places=None, suppress_zero_inches=False
|
||||
value,
|
||||
isArea=False,
|
||||
hide_units=True,
|
||||
precision=None,
|
||||
decimal_places=None,
|
||||
suppress_zero_inches=False,
|
||||
in_unit_length = False
|
||||
):
|
||||
s_code = "\u00b2" # Superscript two THIS IS LEGACY (but being kept for when Area Measurements are re-implimented)
|
||||
|
||||
@@ -130,17 +136,22 @@ def format_distance(
|
||||
unit_system = bpy.context.scene.unit_settings.system
|
||||
unit_length = bpy.context.scene.unit_settings.length_unit
|
||||
|
||||
toInches = 39.3700787401574887
|
||||
inPerFoot = 11.9999
|
||||
|
||||
if isArea:
|
||||
toInches = 1550
|
||||
inPerFoot = 143.999
|
||||
|
||||
value *= scaleFactor
|
||||
|
||||
# Imperial Formatting
|
||||
if unit_system == "IMPERIAL":
|
||||
if in_unit_length:
|
||||
if unit_length == 'INCHES':
|
||||
toInches = 1
|
||||
if unit_length == 'FEET':
|
||||
toInches = 11.9999
|
||||
else:
|
||||
toInches = 39.3700787401574887
|
||||
inPerFoot = 11.9999
|
||||
|
||||
if isArea:
|
||||
toInches = 1550
|
||||
inPerFoot = 143.999
|
||||
if not precision:
|
||||
precision = 256
|
||||
elif precision == "1":
|
||||
@@ -210,6 +221,12 @@ def format_distance(
|
||||
|
||||
# METRIC FORMATTING
|
||||
elif unit_system == "METRIC":
|
||||
if in_unit_length:
|
||||
if unit_length == 'CENTIMETERS':
|
||||
value = value/100
|
||||
if unit_length == 'MILLIMETERS':
|
||||
value = value/1000
|
||||
|
||||
if precision:
|
||||
value = precision * round(float(value) / precision)
|
||||
|
||||
|
||||
@@ -371,6 +371,7 @@ class DocProperties(PropertyGroup):
|
||||
shadingstyle_default: StringProperty(default="Blender Default", name="Default Shading Style")
|
||||
drawing_font: StringProperty(default="OpenGost Type B TT.ttf", name="Drawing Font")
|
||||
magic_font_scale: bpy.props.FloatProperty(default=0.004118616, name="Font Scale Factor")
|
||||
imperial_precision: StringProperty(default="1/32", name="Imperial Precision")
|
||||
|
||||
|
||||
class BIMCameraProperties(PropertyGroup):
|
||||
|
||||
@@ -23,6 +23,7 @@ import ifcopenshell.util.element
|
||||
import ifcopenshell.util.doc
|
||||
import ifcopenshell.util.schema
|
||||
import blenderbim.tool as tool
|
||||
from blenderbim.bim.module.drawing.helper import format_distance
|
||||
|
||||
|
||||
def refresh():
|
||||
@@ -251,7 +252,14 @@ class ObjectMaterialData:
|
||||
else:
|
||||
data["name"] = "No Profile"
|
||||
if item.is_a("IfcMaterialLayer"):
|
||||
data["name"] += f" ({item.LayerThickness})"
|
||||
total_thickness = item.LayerThickness
|
||||
unit_system = bpy.context.scene.unit_settings.system
|
||||
if unit_system == "IMPERIAL":
|
||||
precision = bpy.context.scene.DocProperties.imperial_precision
|
||||
else:
|
||||
precision = None
|
||||
formatted_thickness = format_distance(total_thickness, precision=precision, suppress_zero_inches=True, in_unit_length = True)
|
||||
data["name"] = f"{formatted_thickness} - {data['name']}"
|
||||
if item.is_a("IfcMaterial"):
|
||||
data["material"] = item.Name or "Unnamed"
|
||||
else:
|
||||
|
||||
@@ -18,11 +18,13 @@
|
||||
|
||||
import blenderbim.bim.helper
|
||||
import blenderbim.tool as tool
|
||||
import bpy
|
||||
from bpy.types import Panel, UIList
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from blenderbim.bim.helper import draw_attributes
|
||||
from blenderbim.bim.helper import prop_with_search
|
||||
from blenderbim.bim.module.material.data import MaterialsData, ObjectMaterialData
|
||||
from blenderbim.bim.module.drawing.helper import format_distance
|
||||
|
||||
|
||||
class BIM_PT_materials(Panel):
|
||||
@@ -327,8 +329,16 @@ class BIM_PT_object_material(Panel):
|
||||
row.label(text=set_item["material"], icon="MATERIAL")
|
||||
|
||||
if ObjectMaterialData.data["total_thickness"]:
|
||||
total_thickness = ObjectMaterialData.data["total_thickness"]
|
||||
unit_system = bpy.context.scene.unit_settings.system
|
||||
|
||||
if unit_system == "IMPERIAL":
|
||||
precision = bpy.context.scene.DocProperties.imperial_precision
|
||||
else:
|
||||
precision = None
|
||||
formatted_thickness = format_distance(total_thickness, precision=precision, suppress_zero_inches=True, in_unit_length = True)
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text=f"Total Thickness: {ObjectMaterialData.data['total_thickness']:.3f}")
|
||||
row.label(text=f"Total Thickness: {formatted_thickness}")
|
||||
|
||||
|
||||
class BIM_UL_materials(UIList):
|
||||
|
||||
@@ -349,6 +349,9 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
||||
row = self.layout.row()
|
||||
row.prop(context.scene.DocProperties, "drawing_font")
|
||||
row.prop(context.scene.DocProperties, "magic_font_scale")
|
||||
row = self.layout.row()
|
||||
row.prop(context.scene.DocProperties, "imperial_precision")
|
||||
|
||||
|
||||
|
||||
# Scene panel groups
|
||||
|
||||
Reference in New Issue
Block a user