ifcopenshell.geom.main

Module Contents

class ifcopenshell.geom.main.iterator(settings: iterator.__init__.settings, file_or_filename: ifcopenshell.file.file | str, num_threads: int = 1, include: list[ifcopenshell.entity_instance.entity_instance] | list[str] | None = None, exclude: list[ifcopenshell.entity_instance.entity_instance] | list[str] | None = None, geometry_library: GEOMETRY_LIBRARY = 'opencascade')

Bases: ifcopenshell.ifcopenshell_wrapper.Iterator

get()
settings
class ifcopenshell.geom.main.missing_setting
class ifcopenshell.geom.main.serializer_settings(**kwargs)

Bases: settings_mixin, ifcopenshell.ifcopenshell_wrapper.SerializerSettings

Pythonic interface mixin to the settings modules and to provide an additional setting to enable pythonOCC when available

class ifcopenshell.geom.main.serializers
static obj(out_filename: str | serializers, mtl_filename: str | serializers, geometry_settings: serializers.obj.settings, settings: serializer_settings) ifcopenshell.ifcopenshell_wrapper.WaveFrontOBJSerializer
static svg(out_filename: str | serializers, geometry_settings: serializers.svg.settings, settings: serializer_settings) ifcopenshell.ifcopenshell_wrapper.SvgSerializer
buffer
gltf
hdf5
xml
class ifcopenshell.geom.main.settings(**kwargs)

Bases: settings_mixin, ifcopenshell.ifcopenshell_wrapper.Settings

Pythonic interface mixin to the settings modules and to provide an additional setting to enable pythonOCC when available

use_python_opencascade = False
class ifcopenshell.geom.main.settings_mixin(**kwargs)

Pythonic interface mixin to the settings modules and to provide an additional setting to enable pythonOCC when available

get(k: SETTING) Any
get(k: SERIALIZER_SETTING) Any

Return value of the setting named k.

Raises:

RuntimeError – If there is no setting with name k.

static name(k: str) SETTING | SERIALIZER_SETTING
static rname(k: SETTING | SERIALIZER_SETTING) str
set(k: SETTING, v: Any) None
set(k: SERIALIZER_SETTING, v: Any) None

Set value of the setting named k to v.

Raises:

RuntimeError – If there is no setting with name k.

setting_names() tuple[SETTING, Ellipsis]
setting_names() tuple[SERIALIZER_SETTING, Ellipsis]
class ifcopenshell.geom.main.tree(file: tree.__init__.file | None = None, settings: tree.__init__.settings | None = None)

Bases: ifcopenshell.ifcopenshell_wrapper.tree

add_file(file: tree.add_file.file, settings: tree.add_file.settings) None
add_iterator(iterator: tree.add_iterator.iterator) None
clash_clearance_many(set_a, set_b, clearance=0.05, check_all=False)
clash_collision_many(set_a, set_b, allow_touching=False)
clash_intersection_many(set_a, set_b, tolerance=0.002, check_all=True)
select(value: ifcopenshell.entity_instance.entity_instance | ifcopenshell.ifcopenshell_wrapper.BRepElement | tuple[float, float, float] | OCC.Core.TopoDS.TopoDS_Shape, **kwargs) list[ifcopenshell.entity_instance.entity_instance]
select_box(value, **kwargs) list[ifcopenshell.entity_instance.entity_instance]
args
ifcopenshell.geom.main.consume_iterator(it: iterator, with_progress: Literal[False] = False) Generator[IteratorOutput, None, None]
ifcopenshell.geom.main.consume_iterator(it: iterator, with_progress: Literal[True]) Generator[tuple[int, IteratorOutput], None, None]
ifcopenshell.geom.main.consume_iterator(it: iterator, with_progress: bool) Generator[IteratorOutput | tuple[int, IteratorOutput], None, None]
ifcopenshell.geom.main.create_shape(settings: create_shape.settings, inst: ifcopenshell.entity_instance.entity_instance, repr: ifcopenshell.entity_instance.entity_instance | None = None, geometry_library: GEOMETRY_LIBRARY = 'opencascade') ShapeType | ShapeElementType | ifcopenshell.ifcopenshell_wrapper.Transformation | ifcopenshell.geom.occ_utils.shape_tuple | OCC.Core.TopoDS.TopoDS_Shape

Return a geometric representation from STEP-based IFCREPRESENTATIONSHAPE or Return an OpenCASCADE BRep if settings.USE_PYTHON_OPENCASCADE == True

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.

Raises:

RuntimeError – If failed to process shape. You can turn detailed logging to get more details.

Returns:

  • inst is IfcProduct and repr provided / None -> ShapeElementType

  • inst is IfcRepresentation and repr is None -> ShapeType

  • inst is IfcRepresentationItem and repr is None -> ShapeType

  • inst is IfcProfileDef and repr is None -> ShapeType

  • inst is IfcPlacement / IfcObjectPlacement -> Transformation

  • inst is IfcTypeProduct and repr is None -> None

  • inst is IfcTypeProduct and repr is provided -> RuntimeError

(for IfcTypeProducts provide just IfcRepresentation as inst).

If ‘use-python-opencascade’ is enabled in settings then

  • instead of ShapeElementType it returns shape_tuple,

  • instead of ShapeType it returns TopoDS.TopoDS_Shape.

Example:

settings = ifcopenshell.geom.settings()
settings.set(settings.USE_PYTHON_OPENCASCADE, True)

ifc_file = ifcopenshell.open(file_path)
products = ifc_file.by_type("IfcProduct")

for i, product in enumerate(products):
    if product.Representation is not None:
        try:
            created_shape = geom.create_shape(settings, inst=product)
            shape = created_shape.geometry # see #1124
            shape_gpXYZ = shape.Location().Transformation().TranslationPart() # These are methods of the TopoDS_Shape class from pythonOCC
            print(shape_gpXYZ.X(), shape_gpXYZ.Y(), shape_gpXYZ.Z()) # These are methods of the gpXYZ class from pythonOCC
        except:
            print("Shape creation failed")
ifcopenshell.geom.main.iterate(settings: iterate.settings, file_or_filename: ifcopenshell.file.file | str, num_threads: int = 1, include: list[ifcopenshell.entity_instance.entity_instance] | list[str] | None = None, exclude: list[ifcopenshell.entity_instance.entity_instance] | list[str] | None = None, with_progress: Literal[False] = False, cache: serializers.hdf5 | None = None, geometry_library: GEOMETRY_LIBRARY = 'opencascade') Generator[IteratorOutput, None, None]
ifcopenshell.geom.main.iterate(settings: iterate.settings, file_or_filename: ifcopenshell.file.file | str, num_threads: int = 1, include: list[ifcopenshell.entity_instance.entity_instance] | list[str] | None = None, exclude: list[ifcopenshell.entity_instance.entity_instance] | list[str] | None = None, with_progress: Literal[True] = True, cache: serializers.hdf5 | None = None, geometry_library: GEOMETRY_LIBRARY = 'opencascade') Generator[tuple[int, IteratorOutput], None, None]
ifcopenshell.geom.main.iterate(settings: iterate.settings, file_or_filename: ifcopenshell.file.file | str, num_threads: int = 1, include: list[ifcopenshell.entity_instance.entity_instance] | list[str] | None = None, exclude: list[ifcopenshell.entity_instance.entity_instance] | list[str] | None = None, with_progress: bool = False, cache: serializers.hdf5 | None = None, geometry_library: GEOMETRY_LIBRARY = 'opencascade') Generator[IteratorOutput | tuple[int, IteratorOutput], None, None]
ifcopenshell.geom.main.make_shape_function(fn)
ifcopenshell.geom.main.transform_string(v: str | serializers.buffer) serializers.buffer
ifcopenshell.geom.main.wrap_shape_creation(settings, shape)
ifcopenshell.geom.main.wrap_shape_creation(settings, shape)
ifcopenshell.geom.main.GEOMETRY_LIBRARY
ifcopenshell.geom.main.IteratorOutput
ifcopenshell.geom.main.SERIALIZER_SETTING
ifcopenshell.geom.main.SETTING
ifcopenshell.geom.main.ShapeElementType
ifcopenshell.geom.main.ShapeType
ifcopenshell.geom.main.T
ifcopenshell.geom.main.serialise
ifcopenshell.geom.main.tesselate