Skip to content

Commit ea6df7f

Browse files
committed
Use latest syntax for setting geometry settings #5299
Also fixed: - old include_curves use - missing use of 'include_curves' in ifcopenshell.draw
1 parent fcf41bf commit ea6df7f

6 files changed

Lines changed: 15 additions & 12 deletions

File tree

src/ifcdiff/ifcdiff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ def summarise_shapes(
231231
def get_settings(self, ifc: ifcopenshell.file) -> ifcopenshell.geom.settings:
232232
settings = ifcopenshell.geom.settings()
233233
# Are you feeling lucky?
234-
settings.set(settings.DISABLE_BOOLEAN_RESULT, True)
234+
settings.set("disable-boolean-result", True)
235235
# Are you feeling very lucky?
236-
settings.set(settings.DISABLE_OPENING_SUBTRACTIONS, True)
236+
settings.set("disable-opening-subtractions", True)
237237
# Facetation is to accommodate broken Revit files
238238
# See https://forums.buildingsmart.org/t/suggestions-on-how-to-improve-clarity-of-representation-context-usage-in-documentation/3663/6?u=moult
239239
body_contexts = [

src/ifcopenshell-python/docs/ifcopenshell/geometry_settings.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Here's an example of changing settings in Python:
2525
.. code-block:: python
2626
2727
settings = ifcopenshell.geom.settings()
28-
settings.set(settings.APPLY_DEFAULT_MATERIALS, True)
28+
settings.set("apply-default-materials", True)
2929
settings.set_deflection_tolerance(1e-3)
3030
3131
angular_tolerance
@@ -53,7 +53,7 @@ Here is an example in Python:
5353
.. code-block:: python
5454
5555
settings = ifcopenshell.geom.settings()
56-
settings.set_angular_tolerance(0.5)
56+
settings.set("mesher-angular-deflection", 0.5)
5757
5858
APPLY_DEFAULT_MATERIALS
5959
-----------------------
@@ -178,7 +178,7 @@ Here is an example in Python:
178178
179179
settings = ifcopenshell.geom.settings()
180180
contexts = [c.id() for c in ifc_file.by_type("IfcGeometricRepresentationContext") if c.ContextIdentifier == "Body"]
181-
settings.set_context_ids(contexts)
181+
settings.set("context-ids", contexts)
182182
183183
184184
CONVERT_BACK_UNITS
@@ -228,7 +228,7 @@ Here is an example in Python:
228228
.. code-block:: python
229229
230230
settings = ifcopenshell.geom.settings()
231-
settings.set_deflection_tolerance(1e-3)
231+
settings.set("mesher-linear-deflection", 1e-3)
232232
233233
DISABLE_BOOLEAN_RESULT
234234
----------------------
@@ -273,7 +273,7 @@ For example, if you want to set this setting in a python script you can use the
273273
.. code-block:: python
274274
275275
settings = ifcopenshell.geom.settings()
276-
settings.set(settings.DISABLE_OPENING_SUBTRACTIONS, True)
276+
settings.set("disable-opening-subtractions", True)
277277
278278
279279
DISABLE_TRIANGULATION

src/ifcopenshell-python/ifcopenshell/draw.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ def main(
8888
)
8989

9090
# this is required for serialization
91-
geom_settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
91+
dimensionality = W.CURVES_SURFACES_AND_SOLIDS if settings.include_curves else W.SURFACES_AND_SOLIDS
92+
geom_settings.set("dimensionality", dimensionality)
9293
geom_settings.set("iterator-output", ifcopenshell.ifcopenshell_wrapper.NATIVE)
9394
geom_settings.set("apply-default-materials", True)
9495

src/ifcopenshell-python/ifcopenshell/geom/app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import operator
2323
import functools
2424
import multiprocessing
25+
import ifcopenshell.ifcopenshell_wrapper as W
2526

2627
try:
2728
from OCC.Core import AIS
@@ -522,8 +523,8 @@ def load_file(self, f, setting=None):
522523

523524
if setting is None:
524525
setting = settings()
525-
setting.set(setting.INCLUDE_CURVES, True)
526-
setting.set(setting.USE_PYTHON_OPENCASCADE, True)
526+
setting.set("dimensionality", W.CURVES_SURFACES_AND_SOLIDS)
527+
setting.set("use-python-opencascade", True)
527528

528529
self.signals = geometry_creation_signals()
529530
thread = self.thread = geometry_creation_thread(self.signals, setting, f)

src/ifcopenshell-python/ifcopenshell/geom/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def create_shape(
365365
"""
366366
Return a geometric representation from STEP-based IFCREPRESENTATIONSHAPE
367367
or
368-
Return an OpenCASCADE BRep if settings.USE_PYTHON_OPENCASCADE == True
368+
Return an OpenCASCADE BRep if 'use-python-opencascade' is True
369369
370370
Note that in Python, you must store a reference to the element returned by this function to prevent garbage
371371
collection when you access its children. See #1124.
@@ -391,7 +391,7 @@ def create_shape(
391391
.. code:: python
392392
393393
settings = ifcopenshell.geom.settings()
394-
settings.set(settings.USE_PYTHON_OPENCASCADE, True)
394+
settings.set("use-python-opencascade", True)
395395
396396
ifc_file = ifcopenshell.open(file_path)
397397
products = ifc_file.by_type("IfcProduct")

src/ifcopenshell-python/test/test_create_shape.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def test_settings(self):
1919
assert settings.get("use-python-opencascade") is False
2020
assert "USE_PYTHON_OPENCASCADE = False" in repr(settings)
2121

22+
# Testing both new and old ways of setting geometry settings.
2223
if ifcopenshell.geom.has_occ:
2324
settings.set("use-python-opencascade", True)
2425
settings.set(settings.USE_PYTHON_OPENCASCADE, True)

0 commit comments

Comments
 (0)