mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 02:31:09 +00:00
Refactor qto utils and migrate to bmesh volume calculation. See #1222.
This commit is contained in:
@@ -1838,73 +1838,6 @@ class SelectIfcPatchOutput(bpy.types.Operator):
|
||||
return {"RUNNING_MODAL"}
|
||||
|
||||
|
||||
class CalculateEdgeLengths(bpy.types.Operator):
|
||||
bl_idname = "bim.calculate_edge_lengths"
|
||||
bl_label = "Calculate Edge Lengths"
|
||||
|
||||
def execute(self, context):
|
||||
result = 0
|
||||
for obj in bpy.context.selected_objects:
|
||||
if not obj.data or not obj.data.edges:
|
||||
continue
|
||||
for edge in obj.data.edges:
|
||||
if edge.select:
|
||||
result += (obj.data.vertices[edge.vertices[1]].co - obj.data.vertices[edge.vertices[0]].co).length
|
||||
bpy.context.scene.BIMProperties.qto_result = str(round(result, 3))
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class CalculateFaceAreas(bpy.types.Operator):
|
||||
bl_idname = "bim.calculate_face_areas"
|
||||
bl_label = "Calculate Face Areas"
|
||||
|
||||
def execute(self, context):
|
||||
result = 0
|
||||
for obj in bpy.context.selected_objects:
|
||||
if not obj.data or not obj.data.polygons:
|
||||
continue
|
||||
for polygon in obj.data.polygons:
|
||||
if polygon.select:
|
||||
result += polygon.area
|
||||
bpy.context.scene.BIMProperties.qto_result = str(round(result, 3))
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class CalculateObjectVolumes(bpy.types.Operator):
|
||||
bl_idname = "bim.calculate_object_volumes"
|
||||
bl_label = "Calculate Object Volumes"
|
||||
|
||||
def execute(self, context):
|
||||
# TODO: reimplement
|
||||
qto_calculator = qto.QtoCalculator()
|
||||
result = 0
|
||||
for obj in bpy.context.selected_objects:
|
||||
if not obj.data:
|
||||
continue
|
||||
result += qto_calculator.get_volume(obj)
|
||||
bpy.context.scene.BIMProperties.qto_result = str(round(result, 3))
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AddOpening(bpy.types.Operator):
|
||||
bl_idname = "bim.add_opening"
|
||||
bl_label = "Add Opening"
|
||||
|
||||
def execute(self, context):
|
||||
if context.active_object.children and "IfcOpeningElement/" in context.active_object.children[0].name:
|
||||
opening = context.active_object.children[0]
|
||||
else:
|
||||
opening = context.active_object
|
||||
if context.selected_objects[0] != context.active_object:
|
||||
obj = context.selected_objects[0]
|
||||
else:
|
||||
obj = context.selected_objects[1]
|
||||
modifier = obj.modifiers.new("IfcOpeningElement", "BOOLEAN")
|
||||
modifier.operation = "DIFFERENCE"
|
||||
modifier.object = opening
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class SetOverrideColour(bpy.types.Operator):
|
||||
bl_idname = "bim.set_override_colour"
|
||||
bl_label = "Set Override Colour"
|
||||
|
||||
Reference in New Issue
Block a user