ifcopenshell.util.shape_builder

Module Contents

class ifcopenshell.util.shape_builder.ShapeBuilder(ifc_file: ifcopenshell.file)
block(position: VectorType = (0.0, 0.0, 0.0), x_length: float = 1.0, y_length: float = 1.0, z_length: float = 1.0) ifcopenshell.entity_instance
Parameters:
  • position – the bottom left (min X/Y of the cube).

  • x_length – the X length, in the +X direction

  • y_length – the Y length, in the +Y direction

  • z_length – the Z length, in the +Z direction

Returns:

IfcBlock

circle(center: VectorType = (0.0, 0.0), radius: float = 1.0) ifcopenshell.entity_instance
Parameters:
  • center – circle 2D position

  • radius – radius of the circle

Returns:

IfcCircle

create_axis2_placement_2d(position: VectorType = (0.0, 0.0), x_direction: VectorType | None = None) ifcopenshell.entity_instance

Create IfcAxis2Placement2D.

Parameters:
  • position – 2D origin of the placement.

  • x_direction – Direction of the local X axis. If not provided, defaults to the global X axis (1, 0).

Returns:

IfcAxis2Placement2D

create_axis2_placement_3d(position: VectorType = (0.0, 0.0, 0.0), z_axis: VectorType = (0.0, 0.0, 1.0), x_axis: VectorType = (1.0, 0.0, 0.0)) ifcopenshell.entity_instance

Create IfcAxis2Placement3D.

Parameters:
  • position – placement position (Axis).

  • z_axis – local Z axis direction.

  • x_axis – local X axis direction (RefDirection).

Returns:

IfcAxis2Placement3D

create_axis2_placement_3d_from_matrix(matrix: numpy.typing.NDArray[numpy.float64] | None = None) ifcopenshell.entity_instance

Create IfcAxis2Placement3D from numpy matrix.

Parameters:

matrix – 4x4 transformation matrix, defaults to np.eye(4)

Returns:

IfcAxis2Placement3D

create_ellipse_curve(x_axis_radius: float, y_axis_radius: float, position: VectorType = (0.0, 0.0), trim_points: SequenceOfVectors = (), ref_x_direction: VectorType = (1.0, 0.0), trim_points_mask: collections.abc.Sequence[int] = ()) ifcopenshell.entity_instance

Create an IfcEllipse, optionally trimmed to an arc.

If neither trim_points nor trim_points_mask is provided, a full IfcEllipse is returned. Trimming points must be given in counter-clockwise order. For example, to get the arc above the Y-axis use mask (0, 2); below the Y-axis use (2, 0).

A trimmed result (IfcTrimmedCurve) includes a closing segment between the trim points, making it suitable for use as a profile in extrude().

Parameters:
  • x_axis_radius – Semi-axis length along the local X axis.

  • y_axis_radius – Semi-axis length along the local Y axis.

  • position – 2D centre of the ellipse.

  • trim_points – Explicit pair of 2D trim points. Takes precedence over trim_points_mask.

  • ref_x_direction – Direction of the local X axis.

  • trim_points_mask – Pair of cardinal-point indices (0–3) used when trim_points is empty. See get_trim_points_from_mask() for index definitions.

Returns:

IfcEllipse (untrimmed) or IfcTrimmedCurve (trimmed).

create_swept_disk_solid(path_curve: ifcopenshell.entity_instance, radius: float) ifcopenshell.entity_instance

Create an IfcSweptDiskSolid — a circular cross-section swept along a 3D path.

Useful for modelling round pipes, conduits, and cables.

Parameters:
  • path_curve – A 3D curve entity defining the centreline path. Must have Dim == 3.

  • radius – Radius of the circular disk cross-section.

Returns:

IfcSweptDiskSolid

create_transition_arc_ifc(width: float, height: float, create_ifc_curve: bool = False) tuple[SequenceOfVectors, list[list[int]], ifcopenshell.entity_instance | None]

Create an arc fitting inside a rectangle of the given width and height.

If a single arc cannot span the full width, the longest possible radius is used and a straight segment is inserted in the middle.

Parameters:
  • width – Width of the bounding rectangle.

  • height – Height of the bounding rectangle (also the maximum arc radius).

  • create_ifc_curve – If True, also create and return an IfcIndexedPolyCurve. If False, only return the raw point and segment data.

Returns:

A tuple (points, segments, ifc_curve) where ifc_curve is an IfcIndexedPolyCurve when create_ifc_curve=True, otherwise None.

create_z_profile_lips_curve(FirstFlangeWidth: float, SecondFlangeWidth: float, Depth: float, Girth: float, WallThickness: float, FilletRadius: float) ifcopenshell.entity_instance

Create a Z-profile (cold-formed steel section) outline curve with lips and fillets.

All dimensions are in the IFC project’s length units.

Parameters:
  • FirstFlangeWidth – Width of the first (top) flange, measured from the web centreline.

  • SecondFlangeWidth – Width of the second (bottom) flange, measured from the web centreline.

  • Depth – Total depth of the section (web height).

  • Girth – Length of the return lips on each flange.

  • WallThickness – Uniform material thickness.

  • FilletRadius – Inner bend radius at each corner.

Returns:

IfcIndexedPolyCurve representing the closed Z-profile outline.

curve_between_two_points(points: tuple[VectorType, VectorType]) ifcopenshell.entity_instance

Simple circle based curve between two points Good for creating curves and fillets, won’t work for continuous ellipse shapes.

Parameters:

points – tuple of 2 points.

Returns:

IfcIndexePolyCurve

deep_copy(element: ifcopenshell.entity_instance) ifcopenshell.entity_instance

Create a deep copy of an IFC element and all its referenced entities.

Parameters:

element – The IFC entity to copy.

Returns:

A new independent copy of the element.

edge(start: VectorType = (0.0, 0.0, 0.0), end: VectorType = (1.0, 0.0, 0.0)) ifcopenshell.entity_instance

Create a topological edge

Parameters:
  • start – The start coordinates of the vertex.

  • end – The end coordinates of the vertex.

Returns:

IfcEdge

extrude(profile_or_curve: ifcopenshell.entity_instance, magnitude: float = 1.0, position: VectorType = (0.0, 0.0, 0.0), extrusion_vector: VectorType = (0.0, 0.0, 1.0), position_z_axis: VectorType = (0.0, 0.0, 1.0), position_x_axis: VectorType = (1.0, 0.0, 0.0), position_y_axis: VectorType | None = None) ifcopenshell.entity_instance

Extrude profile or curve to get IfcExtrudedAreaSolid.

REMEMBER when handling custom axes - IFC is using RIGHT handed coordinate system.

Position and position axes are in world space, extrusion vector in placement space defined by position_x_axis/position_y_axis/position_z_axis

NOTE: changing position also changes the resulting geometry origin.

Parameters:
  • profile_or_curve – Profile or a curve to extrude (curve will automatically converted to a profile).

  • extrusion_vector – as defined in coordinate system position_x_axis+position_z_axis

  • position – as defined in default IFC coordinate system, not in position_x_axis+position_z_axis

  • position_y_axis – optional, could be used to calculate Z-axis based on Y-axis

Returns:

IfcExtrudedAreaSolid

extrude_face_set(points: SequenceOfVectors, magnitude: float, extrusion_vector: VectorType = (0, 0, 1), offset: VectorType | None = None, start_cap: bool = True, end_cap: bool = True) ifcopenshell.entity_instance

Method to extrude by creating face sets rather than creating IfcExtrudedAreaSolid.

Useful if your representation is already using face sets and you need to avoid using SweptSolid to assure CorrectItemsForType.

Parameters:
  • points – list of points, assuming they form consecutive closed polyline.

  • magnitude – extrusion magnitude

  • extrusion_vector – extrusion direction.

  • offset – offset from the points

  • start_cap – if True, create start cap.

  • end_cap – if True, create end cap.

Returns:

IfcPolygonalFaceSet

extrude_kwargs(axis: Literal['Y', 'X', 'Z']) dict[str, tuple[float, float, float]]

Shortcut to get kwargs for extrude() to extrude along a principal axis.

Assumes the 2D profile lies in the plane perpendicular to the extrusion axis: XZ plane for Y-axis extrusion, YZ plane for X-axis extrusion, XY plane for Z-axis extrusion.

Extruding along X or Y with other kwargs may violate the IFC ValidExtrusionDirection constraint.

Parameters:

axis – The extrusion axis: 'X', 'Y', or 'Z'.

Returns:

A dict with keys position_x_axis, position_z_axis, and extrusion_vector suitable for passing as **kwargs to extrude().

face(points: SequenceOfVectors) ifcopenshell.entity_instance

Create a single topological face

There are many types of faces, but for now we only support planar polyloop defined faces with an outer boundary.

Parameters:

points – ordered list of 3d coordinates representing the outer boundary

Returns:

IfcFace

faceted_brep(points: SequenceOfVectors, faces: collections.abc.Sequence[collections.abc.Sequence[int]]) ifcopenshell.entity_instance

Generate an IfcFacetedBrep with a closed shell

Note that polygonal_face_set() is recommended in IFC4.

Parameters:
  • points – list of 3d coordinates

  • faces – list of faces consisted of point indices (points indices starting from 0)

Returns:

IfcFacetedBrep

get_polyline_coords(polyline: ifcopenshell.entity_instance) numpy.ndarray

Extract the coordinate array from a polyline entity.

Parameters:

polyline – An IfcIndexedPolyCurve or IfcPolyline entity.

Returns:

Numpy array of the polyline’s point coordinates.

static get_rectangle_coords(size: VectorType = (1.0, 1.0), position: VectorType | None = None) numpy.ndarray

Get rectangle coords arranged as below:

3 2
0 1
Parameters:
  • size – rectangle size, could be either 2d or 3d. Use 0 for one of 3d dimensions to create 2d rectangle in 3d space.

  • position – rectangle position. if position not specified zero-vector will be used

Returns:

list of rectangle coords

get_representation(context: ifcopenshell.entity_instance, items: ifcopenshell.entity_instance | collections.abc.Sequence[ifcopenshell.entity_instance], representation_type: str | None = None) ifcopenshell.entity_instance

Create IFC representation for the specified context and items.

All items must belong to the same geometry category. IFC prohibits mixing incompatible item types in one representation (e.g. IfcExtrudedAreaSolid with IfcBlock, or solids with curves). When representation_type is omitted the type is inferred via ifcopenshell.util.representation.guess_type(); if the items are heterogeneous guess_type returns None and the representation is written with no RepresentationType, which fails IFC validation. Avoid mixing swept-solid primitives (IfcExtrudedAreaSolid, IfcRevolvedAreaSolid) with CSG primitives (IfcBlock, IfcSphere, etc.) or any other category in a single call.

Parameters:
  • context – IfcGeometricRepresentationSubContext

  • items – A single item or list of items, all of the same geometry category (e.g. all IfcExtrudedAreaSolid, all IfcIndexedPolyCurve)

  • representation_type – Explicitly specified RepresentationType. If not provided it will be guessed from the items types.

Returns:

IfcShapeRepresentation

get_simple_2dcurve_data(coords: SequenceOfVectors, fillets: collections.abc.Sequence[int] = (), fillet_radius: float | collections.abc.Sequence[float] = (), closed: bool = True, create_ifc_curve: bool = False) tuple[list[VectorType], list[list[int]], ifcopenshell.entity_instance | None]

Creates simple 2D curve from set of 2d coords and list of points with fillets. Simple curve means that all fillets are based on 90 degree angle.

Parameters:
  • coords – list of 2d coords. Example: ((x0,y0), (x1,y1), (x2, y2))

  • fillets – list of points from coords to base fillet on. Example: (1,)

  • fillet_radius – list of fillet radius for each of corresponding point form fillets. Example: (5.,) Note: fillet_radius could be just 1 float value if it’s the same for all fillets.

  • closed – boolean whether curve should be closed (whether last point connected to first one).

  • create_ifc_curve – create IfcIndexedPolyCurve or just return the data.

Returns:

(points, segments, ifc_curve) for the created simple curve if both points in e are equally far from pt, then v1 is returned.

get_trim_points_from_mask(x_axis_radius: float, y_axis_radius: float, trim_points_mask: collections.abc.Sequence[int], position_offset: VectorType | None = None) numpy.ndarray

Get cardinal-point coordinates of an ellipse by index mask.

The four cardinal points are numbered 0–3 counter-clockwise starting from the positive X axis: 0 → (x, 0), 1 → (0, y), 2 → (-x, 0), 3 → (0, -y).

Example: mask (0, 1, 2, 3) returns all four points in order.

Parameters:
  • x_axis_radius – Radius (semi-axis length) along the X axis.

  • y_axis_radius – Radius (semi-axis length) along the Y axis.

  • trim_points_mask – Sequence of cardinal-point indices (0–3) to select.

  • position_offset – Optional 2D offset added to all returned points.

Returns:

Numpy array of the selected 2D points.

half_space_solid(plane: ifcopenshell.entity_instance, agreement_flag: bool = False) ifcopenshell.entity_instance
Parameters:
  • plane – The IfcPlane representing the half space.

  • agreement_flag – If False (default), the plane normal points toward the removed material (the void). The kept region is on the opposite side from the normal.

Returns:

IfcHalfSpaceSolid

mep_bend_shape(segment: ifcopenshell.entity_instance, start_length: float, end_length: float, angle: float, radius: float, bend_vector: VectorType, flip_z_axis: bool) tuple[ifcopenshell.entity_instance, dict[str, Any]]

Generate a MEP bend shape for the provided segments.

Parameters:
  • segment – IfcFlowSegment for a bend. Note that for a bend start and end segments types should match.

  • angle – bend angle, in radians

  • radius – bend radius

  • bend_vector – offset between start and end segments in local space of start segment used mainly to determine the second bend axis and it’s direction (positive or negative), the actual magnitude of the vector is not important (though near zero values will be ignored).

  • flip_z_axis – since we cannot determine z axis direction from the profile offset, there is an option to flip it if bend is going by start segment Z- axis.

Returns:

tuple of Model/Body/MODEL_VIEW IfcRepresentation and dictionary of transition shape data

mep_transition_calculate(start_half_dim: numpy.ndarray, end_half_dim: numpy.ndarray, offset: numpy.ndarray, diff: numpy.ndarray | None = None, end_profile: bool = False, length: float | None = None, angle: float | None = None, verbose: bool = True) float | None

Calculate MEP transition length from angle, or transition angle from length.

Low-level calculation kernel used by mep_transition_length(). Provide either angle or length (not both); the other value is computed and returned.

Parameters:
  • start_half_dim – Half-dimensions of the start profile [half_x, half_y, depth].

  • end_half_dim – Half-dimensions of the end profile [half_x, half_y, depth].

  • offset – 2D XY offset between profile centrelines.

  • diff – Pre-computed absolute difference of start and end half-dimensions (XY only). Computed from start_half_dim and end_half_dim if not provided.

  • end_profile – If True, swap X and Y axes to compute from the end-profile perspective.

  • length – Known transition length. If provided, the corresponding angle is returned.

  • angle – Known transition angle, in degrees. If provided, the corresponding length is returned.

  • verbose – If True, print diagnostic values during calculation.

Returns:

Transition length (if angle was given) or transition angle in degrees (if length was given), or None if the geometry is not feasible.

mep_transition_length(start_half_dim: numpy.ndarray, end_half_dim: numpy.ndarray, angle: float, profile_offset: VectorType = (0.0, 0.0), verbose: bool = True) float | None

Get the transition length for two profile half-dimensions, an angle, and an XY offset.

Unlike mep_transition_calculate(), this method checks that the resulting length satisfies the angle constraint from both the start and end profile perspectives.

Parameters:
  • start_half_dim – Half-dimensions of the start profile as a 3-element array [half_x, half_y, depth]. For circular profiles half_x == half_y == radius.

  • end_half_dim – Half-dimensions of the end profile in the same format.

  • angle – Maximum allowed transition angle, in degrees.

  • profile_offset – 2D XY offset between the centrelines of the start and end profiles.

  • verbose – If True, print diagnostic values during calculation.

Returns:

Transition length in project length units, or None if no valid length exists for the given angle and offset.

mep_transition_shape(start_segment: ifcopenshell.entity_instance, end_segment: ifcopenshell.entity_instance, start_length: float, end_length: float, angle: float = 30.0, profile_offset: VectorType = (0.0, 0.0)) tuple[ifcopenshell.entity_instance, dict[str, Any]] | tuple[None, None]

Generate a MEP transition shape for the provided segments.

Parameters:
  • start_segment – Starting segment.

  • end_segment – Ending segment.

  • start_length – Start transition length.

  • end_length – End transition length.

  • angle – Transition angle, in degrees. Good default values from angle = 30/60 deg 30 degree angle will result in 75 degrees on the transition (= 90 - α/2) - https://i.imgur.com/tcoYDWu.png

  • profile_offset – 2D vector for profile offset.

Returns:

A tuple of Model/Body/MODEL_VIEW IfcRepresentation and dictionary of transition shape data. Or (None, None) if there was an error in the process.

mesh(points: SequenceOfVectors, faces: collections.abc.Sequence[collections.abc.Sequence[int]]) ifcopenshell.entity_instance

Create a tessellated mesh from points and face indices.

Delegates to faceted_brep() for IFC2X3, or polygonal_face_set() for IFC4 and later.

Parameters:
  • points – List of 3D coordinates.

  • faces – List of faces, each face a sequence of zero-based point indices.

Returns:

IfcFacetedBrep (IFC2X3) or IfcPolygonalFaceSet (IFC4+).

mirror(curve_or_item: ifcopenshell.entity_instance | list[ifcopenshell.entity_instance], mirror_axes: VectorType | SequenceOfVectors = (1.0, 1.0), mirror_point: VectorType = (0.0, 0.0), create_copy: bool = False, placement_matrix: numpy.ndarray | None = None) ifcopenshell.entity_instance | list[ifcopenshell.entity_instance]

Mirror curve/representaiton item/representation.

Parameters:
  • curve_or_item – A single item to mirror or a sequence of them.

  • mirror_axes

    A vector of values, should have value > 0 for axes where mirror should be applied. Example: mirroring A(1,0) by axis (1,0) will result in A’(-1,0)

    Also could be a list of mirrors to apply to curve_or_item multiple mirror_axes will result in multiple resulting curves Example: curve_or_item = [a, b], mirror_axes=[v1, v2], result = [av1, av2, bv1, bv2]

  • mirror_point – Point relative to which mirror should be applied.

  • create_copy – Whether to mirror the provided item or it’s copy.

  • placement_matrix – Optional placement matrix to use for polylines.

Returns:

Mirrored curve/item/representation or a sequence of them.

mirror_2d_point(point_2d: VectorType, mirror_axes: VectorType = (1.0, 1.0), mirror_point: VectorType = (0.0, 0.0)) numpy.ndarray

Mirror a single 2D point across the specified axes.

Parameters:
  • point_2d – The 2D point to mirror.

  • mirror_axes – Indicates which axes to mirror across. A positive value in a component means that axis is mirrored (negated relative to mirror_point). Example: (1, 0) mirrors across the Y-axis (negates X only), (1, 1) mirrors across both axes.

  • mirror_point – Origin of the mirror operation.

Returns:

Mirrored 2D point as a numpy array.

plane(location: VectorType = (0.0, 0.0, 0.0), normal: VectorType = (0.0, 0.0, 1.0)) ifcopenshell.entity_instance

Create IfcPlane.

Parameters:
  • location – plane position.

  • normal – plane normal direction.

Returns:

IfcPlane

polygonal_face_set(points: SequenceOfVectors, faces: collections.abc.Sequence[collections.abc.Sequence[int] | collections.abc.Sequence[collections.abc.Sequence[int]]]) ifcopenshell.entity_instance

Generate an IfcPolygonalFaceSet

Note that this is not available in IFC2X3.

Parameters:
  • points – list of 3d coordinates

  • faces – list of faces consisted of point indices (points indices starting from 0) in case of multiple sequences per face, the subsequent ones are inner voids

Returns:

IfcPolygonalFaceSet

polyline(points: SequenceOfVectors, closed: bool = False, position_offset: VectorType | None = None, arc_points: collections.abc.Sequence[int] = ()) ifcopenshell.entity_instance

Generate an IfcIndexedPolyCurve based on the provided points.

Parameters:
  • points – List of 2d or 3d points

  • closed – Whether polyline should be closed.

  • position_offset – offset to be applied to all points

  • arc_points – Indices of the middle points for arcs. For creating an arc segment, provide 3 points: arc_start, arc_middle and arc_end to points and add the arc_middle point’s index to arc_points

Returns:

IfcIndexedPolyCurve

Example:

# rectangle
points = Vector((0, 0)), Vector((1, 0)), Vector((1, 1)), Vector((0, 1))
position = Vector((2, 0))
# #2=IfcIndexedPolyCurve(#1,(IfcLineIndex((1,2,3,4,1))),$)
polyline = builder.polyline(points, closed=True, position_offset=position)

# arc between points (1,0) and (0,1). Second point in the arc should be it's middle
points = Vector((1, 0)), Vector((0.707, 0.707)), Vector((0, 1)), Vector((0,2))
arc_points = (1,) # point with index 1 is a middle of the arc
# 4=IfcIndexedPolyCurve(#3,(IfcArcIndex((1,2,3)),IfcLineIndex((3,4,1))),$)
curved_polyline = builder.polyline(points, closed=False, position_offset=position, arc_points=arc_points)
profile(outer_curve: ifcopenshell.entity_instance, name: str | None = None, inner_curves: collections.abc.Sequence[ifcopenshell.entity_instance] = (), profile_type: str = 'AREA') ifcopenshell.entity_instance

Create a profile.

Parameters:
  • outer_curve – Profile IfcCurve.

  • inner_curves – a sequence of IfcCurves.

Returns:

IfcArbitraryClosedProfileDef or IfcArbitraryProfileDefWithVoids.

rectangle(size: VectorType = (1.0, 1.0), position: VectorType | None = None) ifcopenshell.entity_instance

Generate a rectangle polyline.

Parameters:
  • size – rectangle.

  • position – rectangle position.

See get_rectangle_coords for more information.

Returns:

IfcIndexedPolyCurve

rotate(curve_or_item: ifcopenshell.entity_instance | collections.abc.Sequence[ifcopenshell.entity_instance], angle: float = 90.0, pivot_point: VectorType = (0.0, 0.0), counter_clockwise: bool = False, create_copy: bool = False) ifcopenshell.entity_instance | list[ifcopenshell.entity_instance]

Rotate curve/representaiton item/representation.

Parameters:
  • curve_or_item – A single item to rotate or a sequence of them.

  • angle – Rotation angle, in degrees.

  • pivot_point – Rotation pivot point.

  • counter_clockwise – Whether rotation is counter-clockwise.

  • create_copy – Whether to rotate the provided item or it’s copy.

Returns:

Rotated curve/representaiton item/representation or a sequence of them.

rotate_2d_point(point_2d: VectorType, angle: float = 90.0, pivot_point: VectorType = (0.0, 0.0), counter_clockwise: bool = False) numpy.ndarray

Rotate a single 2D point around a pivot.

Parameters:
  • point_2d – The 2D point to rotate.

  • angle – Rotation angle, in degrees. Defaults to 90.

  • pivot_point – The point to rotate around.

  • counter_clockwise – If True, rotate counter-clockwise. Defaults to clockwise.

Returns:

Rotated 2D point as a numpy array.

rotate_extrusion_kwargs_by_z(kwargs: dict[str, Any], angle: float, counter_clockwise: bool = False) dict[str, VectorType]

Rotate extrusion kwargs around the Z axis.

A shortcut to rotate the position_x_axis and position_z_axis values returned by extrude_kwargs() around the Z axis before passing them to extrude().

Parameters:
  • kwargs – A dict with position_x_axis and position_z_axis keys, as returned by extrude_kwargs(). The original dict is not mutated.

  • angle – Rotation angle, in radians.

  • counter_clockwise – If True, rotate counter-clockwise. Defaults to clockwise.

Returns:

A new dict with position_x_axis and position_z_axis rotated around Z.

set_polyline_coords(polyline: ifcopenshell.entity_instance, coords: SequenceOfVectors) None

Update the coordinates of a polyline entity in-place.

Parameters:
  • polyline – An IfcIndexedPolyCurve or IfcPolyline entity.

  • coords – New sequence of point coordinates. Must contain the same number of points as the original polyline.

sphere(radius: float = 1.0, center: VectorType = (0.0, 0.0, 0.0)) ifcopenshell.entity_instance
Parameters:
  • radius – radius of the sphere.

  • center – sphere position.

Returns:

IfcSphere

translate(curve_or_item: ifcopenshell.entity_instance | collections.abc.Sequence[ifcopenshell.entity_instance], translation: VectorType, create_copy: bool = False) ifcopenshell.entity_instance | list[ifcopenshell.entity_instance]

Translate curve/representaiton item/representation.

Parameters:
  • curve_or_item – A single item to translate or a sequence of them.

  • translation – Translation vector.

  • create_copy – Whether to translate the provided item or it’s copy.

Returns:

Translated curve/item/representation or a sequence of them.

triangulated_face_set(points: SequenceOfVectors, faces: collections.abc.Sequence[collections.abc.Sequence[int]]) ifcopenshell.entity_instance

Generate an IfcTriangulatedFaceSet

Note that this is not available in IFC2X3.

Parameters:
  • points – list of 3d coordinates

  • faces – list of triangles consisted of point indices (points indices starting from 0)

Returns:

IfcTriangulatedFaceSet

vertex(position: VectorType = (0.0, 0.0, 0.0)) ifcopenshell.entity_instance

Create a topological vertex

Commonly used in structural point elements.

Parameters:

position – The 3D coordinate of the vertex

Returns:

IfcVertexPoint

file
ifcopenshell.util.shape_builder.V(*args: float | int | VectorType | SequenceOfVectors) numpy.typing.NDArray[numpy.float64]

Convert floats / vector / sequence of vectors to numpy array.

Note that float argument type also allows passing ints, which will be converted to floats (a double type) as IfcOpenShell is strict about setting int/float attributes.

ifcopenshell.util.shape_builder.ifc_safe_vector_type(v: VectorType | SequenceOfVectors) Any

Convert vector / sequence of vectors to a list of floats that’s safe to save IFC attribute.

Basically converting all numbers in sequences to Python floats.

ifcopenshell.util.shape_builder.intersect_x_axis_2d(p1: VectorType, p2: VectorType, y=0) float | None

Intersect a line defined by 2 points to a horizontal line defined by y

Useful for axis-aligned intersection checks.

Parameters:
  • p1 – First 2D point of the line, order doesn’t matter

  • p2 – Second 2D point of the line, order doesn’t matter

  • y – Intersect at this y value (i.e. defaults to y=0)

ifcopenshell.util.shape_builder.is_x(value: float, x: float, si_conversion: float | None = None) bool
ifcopenshell.util.shape_builder.np_angle(a: VectorType, b: VectorType) float

Get angle between vectors in radians. Designed to work similar to Vector.angle.

ifcopenshell.util.shape_builder.np_angle_signed(a: VectorType, b: VectorType) float

Get signed angle between 2D vectors in radians (clockwise is positive). Designed to work similar to Vector.angle_signed.

ifcopenshell.util.shape_builder.np_apply_matrix(vectors: SequenceOfVectors, matrix: numpy.typing.NDArray) numpy.typing.NDArray
Parameters:
  • vectors – Nx3 array of vectors.

  • matrix – 4x4 transformation matrix.

ifcopenshell.util.shape_builder.np_intersect_line_line(v1: VectorType, v2: VectorType, v3: VectorType, v4: VectorType) tuple[numpy.ndarray, numpy.ndarray]

Get 2 closest points on each line. First line - (v1, v2). Second line - (v3, v4).

Designed to work similar to mathutils.geometry.intersect_line_line.

ifcopenshell.util.shape_builder.np_lerp(a: VectorType, b: VectorType, t: float) numpy.ndarray
ifcopenshell.util.shape_builder.np_matrix_normalized(matrix: numpy.ndarray) numpy.ndarray
ifcopenshell.util.shape_builder.np_matrix_to_euler(matrix: numpy.ndarray) tuple[float, float, float]

Convert a rotation matrix to Euler angles.

Designed to work similar to mathutils.Matrix.to_euler. Currently only XYZ rotation is supported.

ifcopenshell.util.shape_builder.np_normal(vectors: SequenceOfVectors) numpy.ndarray

Normal of 3D Polygon.

Designed to work similar to mathutils.geometry.normal.

ifcopenshell.util.shape_builder.np_normalized(v: VectorType) numpy.ndarray
ifcopenshell.util.shape_builder.np_rotation_matrix(angle: float, size: int, axis: Literal['X', 'Y', 'Z'] | VectorType | None = None) numpy.ndarray

Get rotation matrix. Designed to be similar to mathutils Matrix.Rotation but to use numpy.

Parameters:
  • float – Rotation angle, in radians.

  • size – Matrix size ([2;4]).

  • axis – Rotation axis. For 2x2 matrices Z assumed by default and argument can be omitted, for 3x3/4x4 matrices could be either axis literal or a rotation axis presented as a vector.

Returns:

Rotation matrix.

ifcopenshell.util.shape_builder.np_round_to_precision(v: numpy.ndarray, si_conversion: float) numpy.ndarray
ifcopenshell.util.shape_builder.np_to_3d(v: VectorType, z: float = 0.0) numpy.ndarray

Convert 2D/4D vector to 3D.

ifcopenshell.util.shape_builder.np_to_4d(v: VectorType, z: float = 0.0, w: float = 1.0) numpy.ndarray

Convert 2D/3D vector to 4D (e.g. for multiplying with 4x4 matrix).

ifcopenshell.util.shape_builder.np_to_4x4(matrix_3x3: numpy.ndarray) numpy.ndarray

Convert 3x3 matrix to 4x4.

ifcopenshell.util.shape_builder.np_translation_matrix(vector: VectorType) numpy.typing.NDArray[numpy.float64]

Get translation matrix.

Designed to be similar to mathutils Matrix.Rotation but to use numpy.

Parameters:

vector – 3D translation vector.

Returns:

An 4x4 identity matrix with a translation

ifcopenshell.util.shape_builder.round_to_precision(x: float, si_conversion: float) float
ifcopenshell.util.shape_builder.PRECISION = 1e-05
ifcopenshell.util.shape_builder.SequenceOfVectors
ifcopenshell.util.shape_builder.VectorType