mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
You can now purge unused representations from the purge data panel
This commit is contained in:
@@ -37,6 +37,7 @@ classes = (
|
||||
operator.OverrideOriginSet,
|
||||
operator.OverrideOutlinerDelete,
|
||||
operator.OverridePasteBuffer,
|
||||
operator.PurgeUnusedRepresentations,
|
||||
operator.RefreshAggregate,
|
||||
operator.RemoveConnection,
|
||||
operator.RemoveRepresentation,
|
||||
|
||||
@@ -210,6 +210,15 @@ class RemoveRepresentation(bpy.types.Operator, Operator):
|
||||
)
|
||||
|
||||
|
||||
class PurgeUnusedRepresentations(bpy.types.Operator, Operator):
|
||||
bl_idname = "bim.purge_unused_representations"
|
||||
bl_label = "Purge Unused Representations"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def _execute(self, context):
|
||||
core.purge_unused_representations(tool.Ifc, tool.Geometry)
|
||||
|
||||
|
||||
class UpdateRepresentation(bpy.types.Operator, Operator):
|
||||
bl_idname = "bim.update_representation"
|
||||
bl_label = "Update Representation"
|
||||
|
||||
@@ -395,3 +395,4 @@ class BIM_PT_purge(Panel):
|
||||
layout = self.layout
|
||||
layout.operator("bim.purge_unused_profiles")
|
||||
layout.operator("bim.purge_unused_types")
|
||||
layout.operator("bim.purge_unused_representations")
|
||||
|
||||
@@ -157,6 +157,12 @@ def remove_representation(ifc, geometry, obj=None, representation=None):
|
||||
geometry.delete_data(data)
|
||||
|
||||
|
||||
def purge_unused_representations(ifc, geometry):
|
||||
for representation in geometry.get_model_representations():
|
||||
if ifc.get().get_total_inverses(representation) == 0:
|
||||
ifc.run("geometry.remove_representation", representation=representation)
|
||||
|
||||
|
||||
def select_connection(geometry, connection=None):
|
||||
geometry.select_connection(connection)
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ class Geometry(blenderbim.core.tool.Geometry):
|
||||
direction = Vector((0, 1, 0))
|
||||
depsgraph = bpy.context.evaluated_depsgraph_get()
|
||||
visible_faces = []
|
||||
face_offset = obj.matrix_world.to_quaternion() @ Vector((0,0,distance))
|
||||
face_offset = obj.matrix_world.to_quaternion() @ Vector((0, 0, distance))
|
||||
global_direction = obj.matrix_world.to_quaternion() @ direction
|
||||
for face in bm.faces:
|
||||
if direction.dot(face.normal) > 0:
|
||||
@@ -215,7 +215,9 @@ class Geometry(blenderbim.core.tool.Geometry):
|
||||
centroid = face.calc_center_median()
|
||||
face_centroid_at_max = Vector((centroid.x, min_y, centroid.z))
|
||||
face_centroid_at_max = obj.matrix_world @ face_centroid_at_max
|
||||
hit, loc, norm, idx, o, mw = bpy.context.scene.ray_cast(depsgraph, face_centroid_at_max, global_direction, distance=distance)
|
||||
hit, loc, norm, idx, o, mw = bpy.context.scene.ray_cast(
|
||||
depsgraph, face_centroid_at_max, global_direction, distance=distance
|
||||
)
|
||||
if o != obj or idx == face.index:
|
||||
visible_faces.append(face)
|
||||
return visible_faces
|
||||
@@ -617,3 +619,7 @@ class Geometry(blenderbim.core.tool.Geometry):
|
||||
@classmethod
|
||||
def should_use_presentation_style_assignment(cls):
|
||||
return bpy.context.scene.BIMGeometryProperties.should_use_presentation_style_assignment
|
||||
|
||||
@classmethod
|
||||
def get_model_representations(cls):
|
||||
return tool.Ifc.get().by_type("IfcShapeRepresentation")
|
||||
|
||||
Reference in New Issue
Block a user