From c7eca135de09d390031bd1caa3645a383dba9ea0 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 8 Nov 2022 20:18:08 +1100 Subject: [PATCH] Document how you can get the matrix of elements from IfcOpenShell Python. --- .../ifcopenshell-python/geometry_processing.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ifcopenshell-python/docs/ifcopenshell-python/geometry_processing.rst b/src/ifcopenshell-python/docs/ifcopenshell-python/geometry_processing.rst index c8ffdf4ee0..b9ff3849fe 100644 --- a/src/ifcopenshell-python/docs/ifcopenshell-python/geometry_processing.rst +++ b/src/ifcopenshell-python/docs/ifcopenshell-python/geometry_processing.rst @@ -41,6 +41,20 @@ related information in ``shape.geometry``: # IfcShapeRepresentation.id{-layerset-LayerSet.id}{-material-Material.id}{-openings-[Opening n.id ...]}{-world-coords} print(shape.geometry.id()) + # A 4x4 matrix representing the location and rotation of the element, in the form: + # [ [ 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 ] ] + # The position is given by the last column: (x, y, z) + # The rotation is described by the first three columns, by explicitly specifying the local X, Y, Z axes. + # The first column is a normalised vector of the local X axis: (x_x, x_y, x_z) + # The second column is a normalised vector of the local Y axis: (y_x, y_y, y_z) + # The third column is a normalised vector of the local Z axis: (z_x, z_y, z_z) + # The axes follow a right-handed coordinate system. + # Objects are never scaled, so the scale factor of the matrix is always 1. + matrix = shape.transformation.matrix.data + # Indices of vertices per triangle face e.g. [f1v1, f1v2, f1v3, f2v1, f2v2, f2v3, ...] faces = shape.geometry.faces @@ -163,6 +177,7 @@ Here is a simple example in Python: if iterator.initialize(): while True: shape = iterator.get() + matrix = shape.transformation.matrix.data faces = shape.geometry.faces edges = shape.geometry.edges verts = shape.geometry.verts