mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
Add support for rounding metric and imperial units in drawings
This commit is contained in:
@@ -128,14 +128,6 @@ def format_distance(value, isArea=False, hide_units=True):
|
|||||||
scaleFactor = bpy.context.scene.unit_settings.scale_length
|
scaleFactor = bpy.context.scene.unit_settings.scale_length
|
||||||
unit_system = bpy.context.scene.unit_settings.system
|
unit_system = bpy.context.scene.unit_settings.system
|
||||||
unit_length = bpy.context.scene.unit_settings.length_unit
|
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
|
toInches = 39.3700787401574887
|
||||||
inPerFoot = 11.999
|
inPerFoot = 11.999
|
||||||
@@ -148,7 +140,15 @@ def format_distance(value, isArea=False, hide_units=True):
|
|||||||
|
|
||||||
# Imperial Formating
|
# Imperial Formating
|
||||||
if unit_system == "IMPERIAL":
|
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
|
decInches = value * toInches
|
||||||
|
|
||||||
# Seperate ft and inches
|
# Seperate ft and inches
|
||||||
@@ -207,6 +207,9 @@ def format_distance(value, isArea=False, hide_units=True):
|
|||||||
|
|
||||||
# METRIC FORMATING
|
# METRIC FORMATING
|
||||||
elif unit_system == "METRIC":
|
elif unit_system == "METRIC":
|
||||||
|
precision = bpy.context.scene.BIMProperties.metric_precision
|
||||||
|
if precision != 0:
|
||||||
|
value = precision * round(float(value)/precision)
|
||||||
|
|
||||||
# Meters
|
# Meters
|
||||||
if unit_length == 'METERS':
|
if unit_length == 'METERS':
|
||||||
|
|||||||
@@ -1288,6 +1288,19 @@ class BIMProperties(PropertyGroup):
|
|||||||
qto_result: StringProperty(default='', name='Qto Result')
|
qto_result: StringProperty(default='', name='Qto Result')
|
||||||
area_unit: StringProperty(default='', name='IFC Area Unit')
|
area_unit: StringProperty(default='', name='IFC Area Unit')
|
||||||
volume_unit: StringProperty(default='', name='IFC Volume 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)
|
override_colour: FloatVectorProperty(name='Override Colour', subtype='COLOR', default=(1, 0, 0, 1), min=0.0, max=1.0, size=4)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2108,3 +2108,8 @@ def ifc_units(self, context):
|
|||||||
row.prop(props, 'area_unit')
|
row.prop(props, 'area_unit')
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(props, 'volume_unit')
|
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')
|
||||||
|
|||||||
Reference in New Issue
Block a user