Update all geom settings to new v0.8 syntax

This commit is contained in:
Dion Moult
2024-06-09 16:15:55 +10:00
parent 52f9db4522
commit cdce612566
17 changed files with 37 additions and 40 deletions
+9 -9
View File
@@ -398,18 +398,18 @@ class IfcImporter:
for context in self.contexts:
settings = ifcopenshell.geom.settings()
settings.set('mesher-linear-deflection', self.ifc_import_settings.deflection_tolerance)
settings.set('mesher-angular-deflection', self.ifc_import_settings.angular_tolerance)
settings.set('dimensionality', ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
settings.set('context-ids', [context.id()])
settings.set("mesher-linear-deflection", self.ifc_import_settings.deflection_tolerance)
settings.set("mesher-angular-deflection", self.ifc_import_settings.angular_tolerance)
settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
settings.set("context-ids", [context.id()])
self.context_settings.append(settings)
settings = ifcopenshell.geom.settings()
settings.set('mesher-linear-deflection', self.ifc_import_settings.deflection_tolerance)
settings.set('mesher-angular-deflection', self.ifc_import_settings.angular_tolerance)
settings.set('dimensionality', ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
settings.set('disable-opening-subtractions', True)
settings.set('context-ids', [context.id()])
settings.set("mesher-linear-deflection", self.ifc_import_settings.deflection_tolerance)
settings.set("mesher-angular-deflection", self.ifc_import_settings.angular_tolerance)
settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
settings.set("disable-opening-subtractions", True)
settings.set("context-ids", [context.id()])
self.gross_context_settings.append(settings)
def process_element_filter(self) -> None:
@@ -133,14 +133,11 @@ class Loader:
return mesh
def load_settings(self):
settings = ifcopenshell.geom.settings()
settings.set(settings.EXCLUDE_SOLIDS_AND_SURFACES, False)
settings.set(settings.USE_BREP_DATA, False)
return settings
return ifcopenshell.geom.settings()
def load_fallback_settings(self):
settings = ifcopenshell.geom.settings()
settings.set(settings.INCLUDE_CURVES, True)
settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
return settings
def load_importer(self):
@@ -692,7 +689,7 @@ class AddBoundary(bpy.types.Operator, tool.Ifc.Operator):
tree = ifcopenshell.geom.tree()
shapes = {}
settings = ifcopenshell.geom.settings()
settings.set(settings.DISABLE_OPENING_SUBTRACTIONS, True)
settings.set("disable-opening-subtractions", True)
iterator = ifcopenshell.geom.iterator(settings, tool.Ifc.get(), multiprocessing.cpu_count(), include=include)
if iterator.initialize():
while True:
@@ -1030,7 +1027,7 @@ class AddBoundary(bpy.types.Operator, tool.Ifc.Operator):
settings = ifcopenshell.geom.settings()
if not element.is_a("IfcOpeningElement"):
settings.set(settings.DISABLE_OPENING_SUBTRACTIONS, True)
settings.set("disable-opening-subtractions", True)
# geometry = ifcopenshell.geom.create_shape(settings, body)
shape = ifcopenshell.geom.create_shape(settings, element)
m = shape.transformation.matrix
@@ -172,7 +172,7 @@ class CreateAllShapes(bpy.types.Operator):
total = len(elements)
settings = ifcopenshell.geom.settings()
settings_2d = ifcopenshell.geom.settings()
settings_2d.set(settings_2d.INCLUDE_CURVES, True)
settings_2d.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
failures = []
excludes = () # For the developer to debug with
for i, element in enumerate(elements, 1):
@@ -225,7 +225,7 @@ class CreateShapeFromStepId(bpy.types.Operator):
element = self.file.by_id(self.step_id or int(context.scene.BIMDebugProperties.step_id))
settings = ifcopenshell.geom.settings()
if self.should_include_curves:
settings.set(settings.INCLUDE_CURVES, True)
settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
shape = ifcopenshell.geom.create_shape(settings, element)
if shape:
ifc_importer = import_ifc.IfcImporter(self.ifc_import_settings)
@@ -291,7 +291,7 @@ class FilledOpeningGenerator:
return tool.Ifc.get().createIfcIndexedPolyCurve(Points=ifc_points, Segments=ifc_segments)
settings = ifcopenshell.geom.settings()
settings.set(settings.INCLUDE_CURVES, True)
settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
geometry = ifcopenshell.geom.create_shape(settings, profile)
verts = ifcopenshell.util.shape.get_vertices(geometry)
# [0, 2] represents X and Z ordinates
@@ -1162,7 +1162,7 @@ def create_shapely_polygon(obj: bpy.types.Object, polygon: bpy.types.MeshPolygon
def get_gross_element_mesh(element: ifcopenshell.entity_instance) -> bpy.types.Mesh:
settings = ifcopenshell.geom.settings()
settings.set(settings.DISABLE_OPENING_SUBTRACTIONS, True)
settings.set("disable-opening-subtractions", True)
return create_mesh_from_shape(element, settings)
+6 -6
View File
@@ -514,7 +514,7 @@ class Geometry(blenderbim.core.tool.Geometry):
ifc_import_settings = blenderbim.bim.import_ifc.IfcImportSettings.factory(bpy.context, None, logger)
element = tool.Ifc.get_entity(obj)
settings = ifcopenshell.geom.settings()
settings.set(settings.WELD_VERTICES, True)
settings.set("weld-vertices", True)
context = representation.ContextOfItems
if element.is_a("IfcTypeProduct"):
@@ -522,20 +522,20 @@ class Geometry(blenderbim.core.tool.Geometry):
try:
shape = ifcopenshell.geom.create_shape(settings, representation)
except:
settings.set(settings.INCLUDE_CURVES, True)
settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
shape = ifcopenshell.geom.create_shape(settings, representation)
else:
if not apply_openings:
settings.set(settings.DISABLE_OPENING_SUBTRACTIONS, True)
settings.set("disable-opening-subtractions", True)
if context.ContextIdentifier == "Body" and context.TargetView == "MODEL_VIEW":
try:
shape = ifcopenshell.geom.create_shape(settings, element, representation)
except:
settings.set(settings.INCLUDE_CURVES, True)
settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
shape = ifcopenshell.geom.create_shape(settings, element, representation)
else:
settings.set(settings.INCLUDE_CURVES, True)
settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
shape = ifcopenshell.geom.create_shape(settings, element, representation)
ifc_importer = blenderbim.bim.import_ifc.IfcImporter(ifc_import_settings)
@@ -779,7 +779,7 @@ class Geometry(blenderbim.core.tool.Geometry):
# Filter out unique meshes to avoid
# reloading the same representation multiple times.
meshes_to_objects: dict[bpy.types.Mesh, bpy.types.Object]
meshes_to_objects = {(obj:=tool.Ifc.get_object(element)).data: obj for element in elements}
meshes_to_objects = {(obj := tool.Ifc.get_object(element)).data: obj for element in elements}
for obj in meshes_to_objects.values():
representation = tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
+1 -1
View File
@@ -36,7 +36,7 @@ class Profile(blenderbim.core.tool.Profile):
) -> None:
"""generates image based on `profile` using `PIL.ImageDraw`"""
settings = ifcopenshell.geom.settings()
settings.set(settings.INCLUDE_CURVES, True)
settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
shape = ifcopenshell.geom.create_shape(settings, profile)
verts = shape.verts
edges = shape.edges
+1 -1
View File
@@ -419,7 +419,7 @@ class Spatial(blenderbim.core.tool.Spatial):
@classmethod
def get_gross_mesh_from_element(cls, visible_element):
gross_settings = ifcopenshell.geom.settings()
gross_settings.set(gross_settings.DISABLE_OPENING_SUBTRACTIONS, True)
gross_settings.set("disable-opening-subtractions", True)
new_mesh = cls.create_mesh_from_shape(ifcopenshell.geom.create_shape(gross_settings, visible_element))
return new_mesh
@@ -16,8 +16,8 @@ class BlenderImporter:
self.created_guids = set()
self.settings = ifcopenshell.geom.settings()
self.settings.set_deflection_tolerance(self.deflection_tolerance)
self.settings.set_angular_tolerance(self.angular_tolerance)
self.settings.set("mesher-linear-deflection", self.deflection_tolerance)
self.settings.set("mesher-angular-deflection", self.angular_tolerance)
self.settings_2d = ifcopenshell.geom.settings()
self.settings_2d.set(self.settings_2d.INCLUDE_CURVES, True)
@@ -47,7 +47,7 @@ class BlenderImporter:
]
)
if self.body_contexts:
self.settings.set_context_ids(self.body_contexts)
self.settings.set("context-ids", self.body_contexts)
# Annotation is to accommodate broken Revit files
# See https://github.com/Autodesk/revit-ifc/issues/187
self.plan_contexts = [