diff --git a/src/ifcblenderexport/blenderbim/bim/helper.py b/src/ifcblenderexport/blenderbim/bim/helper.py index 3de489d048..3e7f142195 100644 --- a/src/ifcblenderexport/blenderbim/bim/helper.py +++ b/src/ifcblenderexport/blenderbim/bim/helper.py @@ -128,14 +128,6 @@ def format_distance(value, isArea=False, hide_units=True): scaleFactor = bpy.context.scene.unit_settings.scale_length unit_system = bpy.context.scene.unit_settings.system unit_length = bpy.context.scene.unit_settings.length_unit - imperial_precision = 32 - # (('1', "1\"", "1 Inch"), - # ('2', "1/2\"", "1/2 Inch"), - # ('4', "1/4\"", "1/4 Inch"), - # ('8', "1/8\"", "1/8th Inch"), - # ('16', "1/16\"", "1/16th Inch"), - # ('32', "1/32\"", "1/32th Inch"), - # ('64', "1/64\"", "1/64th Inch")), toInches = 39.3700787401574887 inPerFoot = 11.999 @@ -148,7 +140,15 @@ def format_distance(value, isArea=False, hide_units=True): # Imperial Formating if unit_system == "IMPERIAL": - base = int(imperial_precision) + precision = bpy.context.scene.BIMProperties.imperial_precision + if precision == 'NONE': + precision = 256 + elif precision == '1': + precision = 1 + elif '/' in precision: + precision = int(precision.split('/')[1]) + + base = int(precision) decInches = value * toInches # Seperate ft and inches @@ -207,6 +207,9 @@ def format_distance(value, isArea=False, hide_units=True): # METRIC FORMATING elif unit_system == "METRIC": + precision = bpy.context.scene.BIMProperties.metric_precision + if precision != 0: + value = precision * round(float(value)/precision) # Meters if unit_length == 'METERS': diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index 58ba99c851..6c40c9a447 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -1288,6 +1288,19 @@ class BIMProperties(PropertyGroup): qto_result: StringProperty(default='', name='Qto Result') area_unit: StringProperty(default='', name='IFC Area Unit') volume_unit: StringProperty(default='', name='IFC Volume Unit') + metric_precision: FloatProperty(default=0, name='Drawing Metric Precision') + imperial_precision: EnumProperty(items=[ + ('NONE', 'No rounding', ''), + ('1', 'Nearest 1"', ''), + ('1/2', 'Nearest 1/2"', ''), + ('1/4', 'Nearest 1/4"', ''), + ('1/8', 'Nearest 1/8"', ''), + ('1/16', 'Nearest 1/16"', ''), + ('1/32', 'Nearest 1/32"', ''), + ('1/64', 'Nearest 1/64"', ''), + ('1/128', 'Nearest 1/128"', ''), + ('1/256', 'Nearest 1/256"', ''), + ], name='Drawing Imperial Precision') override_colour: FloatVectorProperty(name='Override Colour', subtype='COLOR', default=(1, 0, 0, 1), min=0.0, max=1.0, size=4) diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index 7236dc25da..10da7149ee 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -2108,3 +2108,8 @@ def ifc_units(self, context): row.prop(props, 'area_unit') row = layout.row() row.prop(props, 'volume_unit') + row = layout.row() + if bpy.context.scene.unit_settings.system == 'IMPERIAL': + row.prop(props, 'imperial_precision') + else: + row.prop(props, 'metric_precision')