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 = [
+1 -1
View File
@@ -148,7 +148,7 @@ class IfcOpenShell:
formula_functions = {}
gross_settings = ifcopenshell.geom.settings()
gross_settings.set(gross_settings.DISABLE_OPENING_SUBTRACTIONS, True)
gross_settings.set("disable-opening-subtractions", True)
net_settings = ifcopenshell.geom.settings()
gross_qtos = {}
@@ -86,7 +86,7 @@ def import_ifc(filename, use_names, process_relations, blender_booleans):
print(f"Reading {bpy.path.basename(filename)}...")
settings = ifcopenshell_geom.settings()
settings.set(settings.DISABLE_OPENING_SUBTRACTIONS, blender_booleans)
settings.set("disable-opening-subtractions", blender_booleans)
assert os.path.exists(filename), filename
ifc_file = ifcopenshell.open(filename)
iterator = ifcopenshell_geom.iterator(settings, ifc_file)
@@ -140,7 +140,7 @@ class Usecase:
return (self.settings["profile"].FlangeWidth * 2) - self.settings["profile"].WebThickness
else:
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, self.settings["profile"])
x = [shape.verts[i] for i in range(0, len(shape.verts), 3)]
return self.convert_si_to_unit(max(x) - min(x))
@@ -169,7 +169,7 @@ class Usecase:
return self.settings["profile"].Depth
else:
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, self.settings["profile"])
y = [shape.verts[i + 1] for i in range(0, len(shape.verts), 3)]
return self.convert_si_to_unit(max(y) - min(y))
@@ -144,7 +144,7 @@ class Usecase:
}
)
self.settings_2d = ifcopenshell.geom.settings()
self.settings_2d.set(self.settings_2d.INCLUDE_CURVES, True)
self.settings_2d.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
shape = ifcopenshell.geom.create_shape(self.settings_2d, dummy_solid)
if self.cardinal_point == 1:
@@ -75,7 +75,7 @@ def get_axis2placement(placement: ifcopenshell.entity_instance) -> MatrixType:
import ifcopenshell.geom
settings = ifcopenshell.geom.settings()
settings.set('convert-back-units', True)
settings.set("convert-back-units", True)
shape = ifcopenshell.geom.create_shape(settings, placement)
return np.array(shape.matrix).reshape((4, 4), order="F")
elif ifc_class == "IfcAxis2Placement2D":
@@ -186,7 +186,7 @@ class Patcher:
# This fixes symptom C.
settings = ifcopenshell.geom.settings()
settings.set(settings.INCLUDE_CURVES, True)
settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(self.file)
for curve in self.file.by_type("IfcIndexedPolyCurve"):
if True in [s.is_a("IfcArcIndex") for s in curve.Segments]:
+1 -1
View File
@@ -194,7 +194,7 @@ class Patcher:
if c.ContextType == "Model"
]
)
self.settings.set_context_ids(self.body_contexts)
self.settings.set("context-ids", self.body_contexts)
products = self.elements
iterator = ifcopenshell.geom.iterator(self.settings, self.file, multiprocessing.cpu_count(), include=products)
@@ -71,7 +71,7 @@ class Patcher:
return
settings = ifcopenshell.geom.settings()
settings.set_context_ids([context.id()])
settings.set("context-ids", [context.id()])
iterator = ifcopenshell.geom.iterator(settings, self.file, multiprocessing.cpu_count(), include=elements)
replacements = {}
if iterator.initialize():