ifcopenshell.util.placement

Module Contents

ifcopenshell.util.placement.a2p(o: collections.abc.Iterable[float], z: collections.abc.Iterable[float], x: collections.abc.Iterable[float]) → MatrixType

Converts a location, X, and Z axis vector to a 4x4 transformation matrix

IFC uses a right-handed coordinate system, so it is not necessary to provide the Y axis.

Parameters:
  • o – The origin (i.e. location) of the matrix

  • z – The +Z vector / axis of the matrix

  • x – The +X vector / axis of the matrix

Returns:

A 4x4 numpy matrix

ifcopenshell.util.placement.get_mappeditem_transformation(item: ifcopenshell.entity_instance) → MatrixType

Parse an IfcMappedItem into a 4x4 transformation matrix

Mapped items take a representation with an origin and transform them with a cartesian transformation operation. This function returns the final transformation matrix.

Parameters:

item – The IfcMappedItem entity

Returns:

A 4x4 numpy transformation matrix

ifcopenshell.util.placement.get_placement(placement: ifcopenshell.entity_instance | None = None, should_return_si: bool = False) → MatrixType

Parse an object or coordinate placement into a 4x4 transformation matrix

If an IfcObjectPlacement is provided, this is the fully composed matrix with all of its parents.

[ [ x_x, y_x, z_x, x   ]
  [ x_y, y_y, z_y, y   ]
  [ x_z, y_z, z_z, z   ]
  [ 0.0, 0.0, 0.0, 1.0 ] ]

Example:

placement = file.by_type("IfcBeam")[0].ObjectPlacement
matrix = ifcopenshell.util.placement.get_placement(placement)
Parameters:
  • placement – The IfcObjectPlacement, IfcPlacement or IfcCartesianTransformationOperator entity. None gives the identity matrix.

  • should_return_si – Return the translation in metres instead of the file’s length unit.

Returns:

A 4x4 numpy matrix

ifcopenshell.util.placement.get_storey_elevation(storey: ifcopenshell.entity_instance) → float

Get the Z elevation in project units of a buildling storey

Building storeys store elevation in two possible locations: the Z value of its placement, or as a fallback the Elevation attribute.

Parameters:

storey – The IfcBuildingStorey entity

Returns:

The elevation in project units

ifcopenshell.util.placement.rotation(angle: float, axis: Literal['X', 'Y', 'Z'], is_degrees=True) → MatrixType

Create a 4x4 numpy matrix representing an euler rotation

Parameters:
  • angle – The angle of rotation

  • axis – The axis to rotate around, either X, Y, or Z.

  • is_degrees – Whether or not the angle is specified in degrees or radians. Defaults to true (i.e. degrees).

Returns:

A 4x4 numpy rotation matrix

ifcopenshell.util.placement.MatrixType

npt.NDArray[np.float64]