mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 06:18:09 +00:00
Use latest syntax for setting geometry settings #5299
Also fixed: - old include_curves use - missing use of 'include_curves' in ifcopenshell.draw
This commit is contained in:
@@ -231,9 +231,9 @@ class IfcDiff:
|
|||||||
def get_settings(self, ifc: ifcopenshell.file) -> ifcopenshell.geom.settings:
|
def get_settings(self, ifc: ifcopenshell.file) -> ifcopenshell.geom.settings:
|
||||||
settings = ifcopenshell.geom.settings()
|
settings = ifcopenshell.geom.settings()
|
||||||
# Are you feeling lucky?
|
# Are you feeling lucky?
|
||||||
settings.set(settings.DISABLE_BOOLEAN_RESULT, True)
|
settings.set("disable-boolean-result", True)
|
||||||
# Are you feeling very lucky?
|
# Are you feeling very lucky?
|
||||||
settings.set(settings.DISABLE_OPENING_SUBTRACTIONS, True)
|
settings.set("disable-opening-subtractions", True)
|
||||||
# Facetation is to accommodate broken Revit files
|
# Facetation is to accommodate broken Revit files
|
||||||
# See https://forums.buildingsmart.org/t/suggestions-on-how-to-improve-clarity-of-representation-context-usage-in-documentation/3663/6?u=moult
|
# See https://forums.buildingsmart.org/t/suggestions-on-how-to-improve-clarity-of-representation-context-usage-in-documentation/3663/6?u=moult
|
||||||
body_contexts = [
|
body_contexts = [
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ Here's an example of changing settings in Python:
|
|||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
settings = ifcopenshell.geom.settings()
|
settings = ifcopenshell.geom.settings()
|
||||||
settings.set(settings.APPLY_DEFAULT_MATERIALS, True)
|
settings.set("apply-default-materials", True)
|
||||||
settings.set_deflection_tolerance(1e-3)
|
settings.set_deflection_tolerance(1e-3)
|
||||||
|
|
||||||
angular_tolerance
|
angular_tolerance
|
||||||
@@ -53,7 +53,7 @@ Here is an example in Python:
|
|||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
settings = ifcopenshell.geom.settings()
|
settings = ifcopenshell.geom.settings()
|
||||||
settings.set_angular_tolerance(0.5)
|
settings.set("mesher-angular-deflection", 0.5)
|
||||||
|
|
||||||
APPLY_DEFAULT_MATERIALS
|
APPLY_DEFAULT_MATERIALS
|
||||||
-----------------------
|
-----------------------
|
||||||
@@ -178,7 +178,7 @@ Here is an example in Python:
|
|||||||
|
|
||||||
settings = ifcopenshell.geom.settings()
|
settings = ifcopenshell.geom.settings()
|
||||||
contexts = [c.id() for c in ifc_file.by_type("IfcGeometricRepresentationContext") if c.ContextIdentifier == "Body"]
|
contexts = [c.id() for c in ifc_file.by_type("IfcGeometricRepresentationContext") if c.ContextIdentifier == "Body"]
|
||||||
settings.set_context_ids(contexts)
|
settings.set("context-ids", contexts)
|
||||||
|
|
||||||
|
|
||||||
CONVERT_BACK_UNITS
|
CONVERT_BACK_UNITS
|
||||||
@@ -228,7 +228,7 @@ Here is an example in Python:
|
|||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
settings = ifcopenshell.geom.settings()
|
settings = ifcopenshell.geom.settings()
|
||||||
settings.set_deflection_tolerance(1e-3)
|
settings.set("mesher-linear-deflection", 1e-3)
|
||||||
|
|
||||||
DISABLE_BOOLEAN_RESULT
|
DISABLE_BOOLEAN_RESULT
|
||||||
----------------------
|
----------------------
|
||||||
@@ -273,7 +273,7 @@ For example, if you want to set this setting in a python script you can use the
|
|||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
settings = ifcopenshell.geom.settings()
|
settings = ifcopenshell.geom.settings()
|
||||||
settings.set(settings.DISABLE_OPENING_SUBTRACTIONS, True)
|
settings.set("disable-opening-subtractions", True)
|
||||||
|
|
||||||
|
|
||||||
DISABLE_TRIANGULATION
|
DISABLE_TRIANGULATION
|
||||||
|
|||||||
@@ -88,7 +88,8 @@ def main(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# this is required for serialization
|
# this is required for serialization
|
||||||
geom_settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
|
dimensionality = W.CURVES_SURFACES_AND_SOLIDS if settings.include_curves else W.SURFACES_AND_SOLIDS
|
||||||
|
geom_settings.set("dimensionality", dimensionality)
|
||||||
geom_settings.set("iterator-output", ifcopenshell.ifcopenshell_wrapper.NATIVE)
|
geom_settings.set("iterator-output", ifcopenshell.ifcopenshell_wrapper.NATIVE)
|
||||||
geom_settings.set("apply-default-materials", True)
|
geom_settings.set("apply-default-materials", True)
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import time
|
|||||||
import operator
|
import operator
|
||||||
import functools
|
import functools
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
import ifcopenshell.ifcopenshell_wrapper as W
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from OCC.Core import AIS
|
from OCC.Core import AIS
|
||||||
@@ -522,8 +523,8 @@ class application(QtWidgets.QApplication):
|
|||||||
|
|
||||||
if setting is None:
|
if setting is None:
|
||||||
setting = settings()
|
setting = settings()
|
||||||
setting.set(setting.INCLUDE_CURVES, True)
|
setting.set("dimensionality", W.CURVES_SURFACES_AND_SOLIDS)
|
||||||
setting.set(setting.USE_PYTHON_OPENCASCADE, True)
|
setting.set("use-python-opencascade", True)
|
||||||
|
|
||||||
self.signals = geometry_creation_signals()
|
self.signals = geometry_creation_signals()
|
||||||
thread = self.thread = geometry_creation_thread(self.signals, setting, f)
|
thread = self.thread = geometry_creation_thread(self.signals, setting, f)
|
||||||
|
|||||||
@@ -365,7 +365,7 @@ def create_shape(
|
|||||||
"""
|
"""
|
||||||
Return a geometric representation from STEP-based IFCREPRESENTATIONSHAPE
|
Return a geometric representation from STEP-based IFCREPRESENTATIONSHAPE
|
||||||
or
|
or
|
||||||
Return an OpenCASCADE BRep if settings.USE_PYTHON_OPENCASCADE == True
|
Return an OpenCASCADE BRep if 'use-python-opencascade' is True
|
||||||
|
|
||||||
Note that in Python, you must store a reference to the element returned by this function to prevent garbage
|
Note that in Python, you must store a reference to the element returned by this function to prevent garbage
|
||||||
collection when you access its children. See #1124.
|
collection when you access its children. See #1124.
|
||||||
@@ -391,7 +391,7 @@ def create_shape(
|
|||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
settings = ifcopenshell.geom.settings()
|
settings = ifcopenshell.geom.settings()
|
||||||
settings.set(settings.USE_PYTHON_OPENCASCADE, True)
|
settings.set("use-python-opencascade", True)
|
||||||
|
|
||||||
ifc_file = ifcopenshell.open(file_path)
|
ifc_file = ifcopenshell.open(file_path)
|
||||||
products = ifc_file.by_type("IfcProduct")
|
products = ifc_file.by_type("IfcProduct")
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class TestGeomSettings:
|
|||||||
assert settings.get("use-python-opencascade") is False
|
assert settings.get("use-python-opencascade") is False
|
||||||
assert "USE_PYTHON_OPENCASCADE = False" in repr(settings)
|
assert "USE_PYTHON_OPENCASCADE = False" in repr(settings)
|
||||||
|
|
||||||
|
# Testing both new and old ways of setting geometry settings.
|
||||||
if ifcopenshell.geom.has_occ:
|
if ifcopenshell.geom.has_occ:
|
||||||
settings.set("use-python-opencascade", True)
|
settings.set("use-python-opencascade", True)
|
||||||
settings.set(settings.USE_PYTHON_OPENCASCADE, True)
|
settings.set(settings.USE_PYTHON_OPENCASCADE, True)
|
||||||
|
|||||||
Reference in New Issue
Block a user