mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 17:57:02 +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.OverrideOriginSet,
|
||||||
operator.OverrideOutlinerDelete,
|
operator.OverrideOutlinerDelete,
|
||||||
operator.OverridePasteBuffer,
|
operator.OverridePasteBuffer,
|
||||||
|
operator.PurgeUnusedRepresentations,
|
||||||
operator.RefreshAggregate,
|
operator.RefreshAggregate,
|
||||||
operator.RemoveConnection,
|
operator.RemoveConnection,
|
||||||
operator.RemoveRepresentation,
|
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):
|
class UpdateRepresentation(bpy.types.Operator, Operator):
|
||||||
bl_idname = "bim.update_representation"
|
bl_idname = "bim.update_representation"
|
||||||
bl_label = "Update Representation"
|
bl_label = "Update Representation"
|
||||||
|
|||||||
@@ -395,3 +395,4 @@ class BIM_PT_purge(Panel):
|
|||||||
layout = self.layout
|
layout = self.layout
|
||||||
layout.operator("bim.purge_unused_profiles")
|
layout.operator("bim.purge_unused_profiles")
|
||||||
layout.operator("bim.purge_unused_types")
|
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)
|
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):
|
def select_connection(geometry, connection=None):
|
||||||
geometry.select_connection(connection)
|
geometry.select_connection(connection)
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ class Geometry(blenderbim.core.tool.Geometry):
|
|||||||
direction = Vector((0, 1, 0))
|
direction = Vector((0, 1, 0))
|
||||||
depsgraph = bpy.context.evaluated_depsgraph_get()
|
depsgraph = bpy.context.evaluated_depsgraph_get()
|
||||||
visible_faces = []
|
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
|
global_direction = obj.matrix_world.to_quaternion() @ direction
|
||||||
for face in bm.faces:
|
for face in bm.faces:
|
||||||
if direction.dot(face.normal) > 0:
|
if direction.dot(face.normal) > 0:
|
||||||
@@ -215,7 +215,9 @@ class Geometry(blenderbim.core.tool.Geometry):
|
|||||||
centroid = face.calc_center_median()
|
centroid = face.calc_center_median()
|
||||||
face_centroid_at_max = Vector((centroid.x, min_y, centroid.z))
|
face_centroid_at_max = Vector((centroid.x, min_y, centroid.z))
|
||||||
face_centroid_at_max = obj.matrix_world @ face_centroid_at_max
|
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:
|
if o != obj or idx == face.index:
|
||||||
visible_faces.append(face)
|
visible_faces.append(face)
|
||||||
return visible_faces
|
return visible_faces
|
||||||
@@ -617,3 +619,7 @@ class Geometry(blenderbim.core.tool.Geometry):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def should_use_presentation_style_assignment(cls):
|
def should_use_presentation_style_assignment(cls):
|
||||||
return bpy.context.scene.BIMGeometryProperties.should_use_presentation_style_assignment
|
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