ifcopenshell.api.geometry

Create geometric representations and assign them to elements

These functions support both the creation of arbitrary geometry as well as geometry that follows parametric rules (e.g. layered geometry or profiled geometry extrusions).

Submodules

Package Contents

ifcopenshell.api.geometry.add_axis_representation(file: ifcopenshell.file, context: ifcopenshell.entity_instance, axis: tuple[COORD, COORD]) ifcopenshell.entity_instance

Adds a new axis representation

Certain objects are typically “axis-based”, such as walls, beams, and columns. This means you can represent them abstractly by simply drawing a single line either in 2D (such as for walls) or 3D (for beams and columns). Humans can understand this axis-based representation as being a simplification of a layered extrusion or a profile that is being extruded along that axis and joined to other elements.

Using an axis-based representation makes it easy for users and computers to analyse connectivity and spatial relationships, as well as makes it easy to parametrically edit these objects by simply stretching the start or end of the axis.

For now, only simple straight line axes are supported, represented by a start and end coordinate. The order is important. For walls, the start must be at the minimum local X ordinate, and the end at the maximum local X ordinate. For beams and columns, the start is at the minimum local Z ordinate, and the end of the maximum local Z ordinate. The first coordinate is the “start” and the second coordinate is the “end”. This stat and end is then used to determine any parametric junctions with other elements.

Using an axis-representation is optional, but highly recommended for “standard” representations of walls, beams, columns, and other structural members. A rule of thumb is that if you can draw it as a line on paper, you can probably represent it using an axis.

Parameters:
  • context (ifcopenshell.entity_instance) – The IfcGeometricRepresentationContext that the representation is part of. This must be either a Model/Axis/GRAPH_VIEW (3D) or Plan/Axis/GRAPH_VIEW (2D).

  • axis (list[list[float]]) – The axis, as a list of two coordinates, the coordinates being either a list of 2 or 3 float coordinates depending on whether the axis is 2D or 3D.

Returns:

The newly created IfcShapeRepresentation entity

Return type:

ifcopenshell.entity_instance

Example:

context = ifcopenshell.util.representation.get_context(model, "Plan", "Axis", "GRAPH_VIEW")
axis = ifcopenshell.api.geometry.add_axis_representation(model,
    context=context, axis=[(0.0, 0.0), (1.0, 0.0)])
ifcopenshell.api.geometry.add_boolean(file: ifcopenshell.file, representation: ifcopenshell.entity_instance, operator: str = 'DIFFERENCE', type: Literal['IfcHalfSpaceSolid', 'Mesh'] = 'IfcHalfSpaceSolid', matrix: NPArrayOfFloats | None = None, blender_obj: bpy.types.Object | None = None, blender_void: bpy.types.Object | None = None, should_force_faceted_brep: bool = False, should_force_triangulation: bool = False) list[ifcopenshell.entity_instance]

For type values: - “IfcHalfSpaceSolid” - matrix is not optional. - “Mesh” - blender_obj and blender_void are not optional

ifcopenshell.api.geometry.add_footprint_representation(file, context: ifcopenshell.entity_instance, curves: list[ifcopenshell.entity_instance]) ifcopenshell.entity_instance
ifcopenshell.api.geometry.add_mesh_representation(file: ifcopenshell.file, context: ifcopenshell.entity_instance, vertices: list[COORD_3D], edges: list[tuple[int, int]] = None, faces: list[list[int]] = None, cooridnate_offset: COORD_3D | None = None, unit_scale: float | None = None, force_faceted_brep: bool = False) ifcopenshell.entity_instance
ifcopenshell.api.geometry.add_profile_representation(file: ifcopenshell.file, context: ifcopenshell.entity_instance, profile: ifcopenshell.entity_instance, depth: float = 1.0, cardinal_point: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] = 5, clippings: list[ifcopenshell.util.data.Clipping | dict[str, Any]] | None = None, placement_zx_axes: tuple[VECTOR_3D | None, VECTOR_3D | None] = (None, None)) ifcopenshell.entity_instance
ifcopenshell.api.geometry.add_slab_representation(file, context: ifcopenshell.entity_instance, depth: float = 0.2, x_angle: float = 0.0, clippings: list[ifcopenshell.util.data.Clipping | dict[str, Any]] | None = None) ifcopenshell.entity_instance
ifcopenshell.api.geometry.add_wall_representation(file: ifcopenshell.file, context: ifcopenshell.entity_instance, length: float = 1.0, height: float = 3.0, offset: float = 0.0, thickness: float = 0.2, x_angle: float = 0.0, clippings: list[ifcopenshell.util.data.Clipping | dict[str, Any]] | None = None, booleans: list[ifcopenshell.entity_instance] | None = None) ifcopenshell.entity_instance
ifcopenshell.api.geometry.assign_representation(file: ifcopenshell.file, product: ifcopenshell.entity_instance, representation: ifcopenshell.entity_instance) None
ifcopenshell.api.geometry.connect_element(file: ifcopenshell.file, relating_element: ifcopenshell.entity_instance, related_element: ifcopenshell.entity_instance, description: str | None = None) ifcopenshell.entity_instance
ifcopenshell.api.geometry.connect_path(file: ifcopenshell.file, relating_element: ifcopenshell.entity_instance, related_element: ifcopenshell.entity_instance, relating_connection: str = 'NOTDEFINED', related_connection: str = 'NOTDEFINED', description: str | None = None) ifcopenshell.entity_instance
ifcopenshell.api.geometry.create_2pt_wall(file: ifcopenshell.file, element: ifcopenshell.entity_instance, context: ifcopenshell.entity_instance, p1: tuple[float, float], p2: tuple[float, float], elevation: float, height: float, thickness: float, is_si: bool = True) ifcopenshell.entity_instance
ifcopenshell.api.geometry.disconnect_element(file: ifcopenshell.file, relating_element: ifcopenshell.entity_instance, related_element: ifcopenshell.entity_instance) None
ifcopenshell.api.geometry.disconnect_path(file: ifcopenshell.file, element: ifcopenshell.entity_instance | None = None, connection_type: str | None = None, relating_element: ifcopenshell.entity_instance | None = None, related_element: ifcopenshell.entity_instance | None = None) None

There are two options to use this API method: - provide element (connected from) and connection_type that should be disconnected. - provide connected elements to disconnect explicitly: relating_element (connected from) and related_element (connected to)

ifcopenshell.api.geometry.edit_object_placement(file: ifcopenshell.file, product: ifcopenshell.entity_instance, matrix: NPArrayOfFloats | None = None, is_si: bool = True, should_transform_children: bool = False) ifcopenshell.entity_instance
ifcopenshell.api.geometry.map_representation(file: ifcopenshell.file, representation: ifcopenshell.entity_instance) ifcopenshell.entity_instance
ifcopenshell.api.geometry.remove_boolean(file: ifcopenshell.file, item: ifcopenshell.entity_instance) None
ifcopenshell.api.geometry.remove_representation(file: ifcopenshell.file, representation: ifcopenshell.entity_instance) None

Remove a representation.

Also purges representation items and their related elements like IfcStyledItem, tessellated facesets colours and UV map.

Parameters:

representation (ifcopenshell.entity_instance) – IfcRepresentation to remove. Note that it’s expected that IfcRepresentation won’t be in use before calling this method (in such elements as IfcProductRepresentation, IfcShapeAspect) otherwise representation won’t be removed.

Returns:

None

Return type:

None

ifcopenshell.api.geometry.unassign_representation(file: ifcopenshell.file, product: ifcopenshell.entity_instance, representation: ifcopenshell.entity_instance) None