Minor fix

This commit is contained in:
Dion Moult
2020-07-16 17:35:57 +10:00
parent 418e4133b7
commit 1ec78e57ce
4 changed files with 30 additions and 7 deletions
@@ -160,6 +160,7 @@ if bpy is not None:
operator.PropagateTextData,
operator.PushRepresentation,
operator.ConvertLocalToGlobal,
operator.GetObjectLinearLength,
operator.GetObjectLength,
operator.GetObjectWidth,
operator.GetObjectHeight,
@@ -3196,6 +3196,18 @@ class GetObjectArea(bpy.types.Operator):
return {'FINISHED'}
class GetObjectLinearLength(bpy.types.Operator):
bl_idname = 'bim.get_object_linear_length'
bl_label = 'Get Object Linear Length'
qto_index: bpy.props.IntProperty()
prop_index: bpy.props.IntProperty()
def execute(self, context):
qto_calculator = qto.QtoCalculator()
bpy.context.active_object.BIMObjectProperties.qtos[self.qto_index].properties[self.prop_index].string_value = str(round(qto_calculator.get_linear_length(bpy.context.active_object), 3))
return {'FINISHED'}
class GetObjectLength(bpy.types.Operator):
bl_idname = 'bim.get_object_length'
bl_label = 'Get Object Length'
+9 -5
View File
@@ -4,11 +4,17 @@ class QtoCalculator():
def get_units(self, o, vg_index):
return len([v for v in o.data.vertices if vg_index in [g.group for g in v.groups]])
def get_linear_length(self, o):
x = (Vector(o.bound_box[4]) - Vector(o.bound_box[0])).length
y = (Vector(o.bound_box[3]) - Vector(o.bound_box[0])).length
z = (Vector(o.bound_box[1]) - Vector(o.bound_box[0])).length
return max(x, y, z)
def get_length(self, o, vg_index=None):
if vg_index is None:
x = (Vector(o.bound_box[4]) - Vector(o.bound_box[0])).length
y = (Vector(o.bound_box[3]) - Vector(o.bound_box[0])).length
return x if x > y else y
return max(x, y)
length = 0
edges = [e for e in o.data.edges if (
vg_index in [g.group for g in o.data.vertices[e.vertices[0]].groups] and
@@ -21,7 +27,7 @@ class QtoCalculator():
def get_width(self, o):
x = (Vector(o.bound_box[4]) - Vector(o.bound_box[0])).length
y = (Vector(o.bound_box[3]) - Vector(o.bound_box[0])).length
return x if x < y else y
return min(x, y)
def get_height(self, o):
return (Vector(o.bound_box[1]) - Vector(o.bound_box[0])).length
@@ -43,9 +49,7 @@ class QtoCalculator():
x = (Vector(o.bound_box[4]) - Vector(o.bound_box[0])).length
y = (Vector(o.bound_box[3]) - Vector(o.bound_box[0])).length
z = (Vector(o.bound_box[1]) - Vector(o.bound_box[0])).length
a1 = x * z
a2 = y * z
return a1 if a1 > a2 else a2
return max(x * z, y * z)
def get_area(self, o, vg_index=None):
if vg_index is None:
+8 -2
View File
@@ -103,7 +103,13 @@ class BIM_PT_object(Panel):
row = layout.row(align=True)
row.prop(prop, 'name', text='')
row.prop(prop, 'string_value', text='')
if 'length' in prop.name.lower():
if 'length' in prop.name.lower() \
and 'width' not in [p.name.lower() for p in qto.properties] \
and 'height' not in [p.name.lower() for p in qto.properties]:
op = row.operator('bim.get_object_linear_length', icon='IPO_EASE_IN_OUT', text='')
op.qto_index = index
op.prop_index = index2
elif 'length' in prop.name.lower():
op = row.operator('bim.get_object_length', icon='IPO_EASE_IN_OUT', text='')
op.qto_index = index
op.prop_index = index2
@@ -121,7 +127,7 @@ class BIM_PT_object(Panel):
op.qto_index = index
op.prop_index = index2
elif 'area' in prop.name.lower() \
and 'footprint' in prop.name.lower():
and ('footprint' in prop.name.lower() or 'section' in prop.name.lower()):
op = row.operator('bim.get_object_footprint_area', icon='MESH_CIRCLE', text='')
op.qto_index = index
op.prop_index = index2