mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Preserve custom opening geometry via a type-level Reference template
Custom IfcOpeningElement voids (e.g. an IfcPolygonalFaceSet / tessellation) were lost - reset to a default extrusion - on bim.duplicate_type, project append, and type switching, because the void lived only on occurrences and nothing carried it to a new type. Anchor the shared opening body on the filling type as a 'Reference' representation map (per IfcShapeRepresentation, 'Reference' is geometry "not part of the Body representation", used for opening geometries excluded from an implicit Boolean operation). bim.duplicate_type and append copy a type's RepresentationMaps, so the template survives; generate_opening_from_filling consults it before falling back to a generated extrusion. - map_type_representations: skip 'Reference' maps so occurrences don't receive the opening shape as their own Body geometry. - opening.py: get_/set_type_opening_representation, promote_opening_to_type, update_type_template_from_opening; pre/post type.assign_type listeners (anchor the old type's void before a switch; regenerate to the assigned type's void afterwards, replacing the previous "preserve custom" guard). - DuplicateType promotes the void before copy; AppendLibraryElement harvests the template cross-file from a library instance. - Write-back on void edit, hooked at both commit paths (UpdateRepresentation and OverrideModeSetObject). - reimport_element_representations renders the requested representation, so switching a type to its Reference row shows the void rather than the body. - Representations panel shows RepresentationIdentifier plus column headers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -94,6 +94,13 @@ def map_type_representations(
|
||||
ifcopenshell.api.geometry.remove_representation(file, representation=representation)
|
||||
for representation_map in relating_type.RepresentationMaps:
|
||||
representation = representation_map.MappedRepresentation
|
||||
# 'Reference' representations are, per IfcShapeRepresentation, "not part of
|
||||
# the Body representation" (used e.g. for opening geometries excluded from an
|
||||
# implicit Boolean operation). They may be carried on a type purely as a
|
||||
# template (e.g. a shared opening body) and must not be mapped onto
|
||||
# occurrences as their own geometry.
|
||||
if representation.RepresentationIdentifier == "Reference":
|
||||
continue
|
||||
mapped_representation = ifcopenshell.api.geometry.map_representation(file, representation=representation)
|
||||
ifcopenshell.api.geometry.assign_representation(
|
||||
file,
|
||||
|
||||
Reference in New Issue
Block a user