mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
switch_representation to automatically switch to unresolved mapped representation
The cool thing about it now that it will automatically create a new mesh for "unresolved" representation if element has openings, otherwise it'll stick to the same mesh representation as the type object. This fixed a few bugs: - similar tob9a9abdbut during extrusion profile edit - applying void to the occurence used to remove the type and other occurences. Apparently it occured after744c08e- previously we seems to rely on `ifcopenshell.geom.create_shape(settings, element)` to unresolve the representations. Though before744c08ethere still was an issue - it would apply the same opening to the all occurences and the type meshes but wasn't removing them. Probably fixed a few other similar issues.
This commit is contained in:
@@ -106,10 +106,13 @@ def switch_representation(
|
|||||||
entity = ifc.get_entity(obj)
|
entity = ifc.get_entity(obj)
|
||||||
current_obj_data = obj.data
|
current_obj_data = obj.data
|
||||||
|
|
||||||
# doesn't resolve mapped representations in case if it's going to have openings
|
|
||||||
# otherwise we would also add openings to the type and other occurences mesh data
|
|
||||||
has_openings = apply_openings and getattr(entity, "HasOpenings", None)
|
has_openings = apply_openings and getattr(entity, "HasOpenings", None)
|
||||||
if not has_openings:
|
if has_openings:
|
||||||
|
# if it has openings make sure to switch to element's mapped representation
|
||||||
|
representation = geometry.unresolve_type_representation(representation, entity)
|
||||||
|
else:
|
||||||
|
# doesn't resolve mapped representations in case if it's going to have openings
|
||||||
|
# otherwise we would also add openings to the type and other occurences mesh data
|
||||||
representation = geometry.resolve_mapped_representation(representation)
|
representation = geometry.resolve_mapped_representation(representation)
|
||||||
|
|
||||||
old_repr_data = geometry.get_representation_data(representation)
|
old_repr_data = geometry.get_representation_data(representation)
|
||||||
|
|||||||
@@ -631,6 +631,18 @@ class Geometry(blenderbim.core.tool.Geometry):
|
|||||||
return cls.resolve_mapped_representation(representation.Items[0].MappingSource.MappedRepresentation)
|
return cls.resolve_mapped_representation(representation.Items[0].MappingSource.MappedRepresentation)
|
||||||
return representation
|
return representation
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def unresolve_type_representation(cls, representation, occurence):
|
||||||
|
if not ifcopenshell.util.element.get_type(occurence):
|
||||||
|
return representation
|
||||||
|
|
||||||
|
if representation.RepresentationType == "MappedRepresentation":
|
||||||
|
return representation
|
||||||
|
|
||||||
|
for mapped_representation in occurence.Representation.Representations:
|
||||||
|
if cls.resolve_mapped_representation(mapped_representation) == representation:
|
||||||
|
return mapped_representation
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_geometry_update_representation(cls, obj=None):
|
def run_geometry_update_representation(cls, obj=None):
|
||||||
bpy.ops.bim.update_representation(obj=obj.name, ifc_representation_class="")
|
bpy.ops.bim.update_representation(obj=obj.name, ifc_representation_class="")
|
||||||
|
|||||||
Reference in New Issue
Block a user