mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Propagate deflection settings on reload (#8484)
reimport_element_representations() built a fresh ifcopenshell.geom.settings() without copying deflection_tolerance / angular_tolerance from the IfcImportSettings it had just constructed, and never passed geometry_library to either the iterator() or create_shape() calls it makes. As a result, exiting Item/edit mode (which reaches this function via switch_representation) silently fell back to IfcOpenShell's hard-coded mesher defaults (0.001 linear deflection, ~50x finer than the project's default of 0.05) and the default geometry kernel, instead of the project's configured tolerance and Geometry Library. This made geometry visibly change quality after a no-op Tab into and back out of edit mode, since the reload path was unintentionally far more precise (and used a different kernel) than the initial import. Both settings, and geometry_library, are now taken from the IfcImportSettings instance already built at the top of the function, so a reload matches the original import. Refs #5685. Generated with the assistance of an AI coding tool. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1151,6 +1151,9 @@ class Geometry(bonsai.core.tool.Geometry):
|
||||
settings.set("layerset-first", True)
|
||||
settings.set("keep-bounding-boxes", True)
|
||||
settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
|
||||
settings.set("mesher-linear-deflection", ifc_import_settings.deflection_tolerance)
|
||||
settings.set("mesher-angular-deflection", ifc_import_settings.angular_tolerance)
|
||||
geometry_library = ifc_import_settings.geometry_library
|
||||
|
||||
ifc_importer = bonsai.bim.import_ifc.IfcImporter(ifc_import_settings)
|
||||
ifc_importer.file = tool.Ifc.get()
|
||||
@@ -1162,7 +1165,11 @@ class Geometry(bonsai.core.tool.Geometry):
|
||||
shape = None
|
||||
if elements:
|
||||
iterator = ifcopenshell.geom.iterator(
|
||||
settings, tool.Ifc.get(), multiprocessing.cpu_count(), include=elements
|
||||
settings,
|
||||
tool.Ifc.get(),
|
||||
multiprocessing.cpu_count(),
|
||||
include=elements,
|
||||
geometry_library=geometry_library,
|
||||
)
|
||||
else:
|
||||
iterator = None # For example, when switching representation of a type with no occurrences
|
||||
@@ -1217,7 +1224,9 @@ class Geometry(bonsai.core.tool.Geometry):
|
||||
for element in element_types:
|
||||
if obj := tool.Ifc.get_object(element):
|
||||
if representation := ifcopenshell.util.representation.get_representation(element, context):
|
||||
geometry = ifcopenshell.geom.create_shape(settings, representation)
|
||||
geometry = ifcopenshell.geom.create_shape(
|
||||
settings, representation, geometry_library=geometry_library
|
||||
)
|
||||
mesh_name = tool.Loader.get_mesh_name_from_shape(geometry)
|
||||
mesh = meshes.get(mesh_name)
|
||||
if mesh is None:
|
||||
|
||||
Reference in New Issue
Block a user