mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
Minor fix
This commit is contained in:
@@ -160,6 +160,7 @@ if bpy is not None:
|
|||||||
operator.PropagateTextData,
|
operator.PropagateTextData,
|
||||||
operator.PushRepresentation,
|
operator.PushRepresentation,
|
||||||
operator.ConvertLocalToGlobal,
|
operator.ConvertLocalToGlobal,
|
||||||
|
operator.GetObjectLinearLength,
|
||||||
operator.GetObjectLength,
|
operator.GetObjectLength,
|
||||||
operator.GetObjectWidth,
|
operator.GetObjectWidth,
|
||||||
operator.GetObjectHeight,
|
operator.GetObjectHeight,
|
||||||
|
|||||||
@@ -3196,6 +3196,18 @@ class GetObjectArea(bpy.types.Operator):
|
|||||||
return {'FINISHED'}
|
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):
|
class GetObjectLength(bpy.types.Operator):
|
||||||
bl_idname = 'bim.get_object_length'
|
bl_idname = 'bim.get_object_length'
|
||||||
bl_label = 'Get Object Length'
|
bl_label = 'Get Object Length'
|
||||||
|
|||||||
@@ -4,11 +4,17 @@ class QtoCalculator():
|
|||||||
def get_units(self, o, vg_index):
|
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]])
|
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):
|
def get_length(self, o, vg_index=None):
|
||||||
if vg_index is None:
|
if vg_index is None:
|
||||||
x = (Vector(o.bound_box[4]) - Vector(o.bound_box[0])).length
|
x = (Vector(o.bound_box[4]) - Vector(o.bound_box[0])).length
|
||||||
y = (Vector(o.bound_box[3]) - 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
|
length = 0
|
||||||
edges = [e for e in o.data.edges if (
|
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
|
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):
|
def get_width(self, o):
|
||||||
x = (Vector(o.bound_box[4]) - Vector(o.bound_box[0])).length
|
x = (Vector(o.bound_box[4]) - Vector(o.bound_box[0])).length
|
||||||
y = (Vector(o.bound_box[3]) - 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):
|
def get_height(self, o):
|
||||||
return (Vector(o.bound_box[1]) - Vector(o.bound_box[0])).length
|
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
|
x = (Vector(o.bound_box[4]) - Vector(o.bound_box[0])).length
|
||||||
y = (Vector(o.bound_box[3]) - 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
|
z = (Vector(o.bound_box[1]) - Vector(o.bound_box[0])).length
|
||||||
a1 = x * z
|
return max(x * z, y * z)
|
||||||
a2 = y * z
|
|
||||||
return a1 if a1 > a2 else a2
|
|
||||||
|
|
||||||
def get_area(self, o, vg_index=None):
|
def get_area(self, o, vg_index=None):
|
||||||
if vg_index is None:
|
if vg_index is None:
|
||||||
|
|||||||
@@ -103,7 +103,13 @@ class BIM_PT_object(Panel):
|
|||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(prop, 'name', text='')
|
row.prop(prop, 'name', text='')
|
||||||
row.prop(prop, 'string_value', 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 = row.operator('bim.get_object_length', icon='IPO_EASE_IN_OUT', text='')
|
||||||
op.qto_index = index
|
op.qto_index = index
|
||||||
op.prop_index = index2
|
op.prop_index = index2
|
||||||
@@ -121,7 +127,7 @@ class BIM_PT_object(Panel):
|
|||||||
op.qto_index = index
|
op.qto_index = index
|
||||||
op.prop_index = index2
|
op.prop_index = index2
|
||||||
elif 'area' in prop.name.lower() \
|
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 = row.operator('bim.get_object_footprint_area', icon='MESH_CIRCLE', text='')
|
||||||
op.qto_index = index
|
op.qto_index = index
|
||||||
op.prop_index = index2
|
op.prop_index = index2
|
||||||
|
|||||||
Reference in New Issue
Block a user