Foundation Classes

Important

When using this low level API, the unit system is always Si with unit meters

Point objects

class Pnt

Point class. Supports get/set operations through indexing. For example x[0] = 1.0

Pnt.Pnt()
Pnt.Pnt(x, y, z)
Pnt.Pnt(vec)
Parameters:

vec (list[float]) – vector containing 3 floating point values for X, Y, Z

Pnt.X()
Pnt.Y()
Pnt.Z()
Pnt.SetX(value)
Pnt.SetY(value)
Pnt.SetZ(value)
Pnt.Transform(tr)

Vector objects

class Vec

Vector class. Supports get/set operations through indexing. For example x[0] = 1.0

Vec.Vec()
Vec.Vec(x, y, z)
Vec.Vec(vec)
Parameters:

vec (list[float]) – vector containing 3 floating point values for X, Y, Z

Vec.X()
Vec.Y()
Vec.Z()
Vec.SetX(value)
Vec.SetY(value)
Vec.SetZ(value)
Vec.Transform(tr)

Direction objects

class Dir

Direction class. Must be non-zero. Supports get/set operations through indexing. For example x[0] = 1.0

Dir.Dir(x, y, z)
Dir.Dir(vec)
Parameters:

vec (list[float]) – vector containing 3 floating point values for X, Y, Z. Will throw an error if vector is zero magnitude.

Dir.X()
Dir.Y()
Dir.Z()
Dir.SetX(value)
Dir.SetY(value)
Dir.SetZ(value)
Dir.Transform(tr)

Ax1 objects

class Ax1

Single axis class. Defined by a point and a direction

Ax1.Ax1(point, direction)
Parameters:
  • point (Pnt) – Location of axis

  • direction (Dir) – Direction of Z-Axis

Ax1.Ax1()
Ax1.Location()
Ax1.XDirection()
Ax1.YDirection()
Ax1.Direction()
Ax1.Transform(tr)

Ax2 objects

class Ax2

Common axis class. Defined by a point and 2 directions

Ax2.Ax2(point, direction, directionX)
Parameters:
  • point (Pnt) – Location of axis

  • direction (Dir) – Direction of Z-Axis

  • directionX (Dir) – Direction of X-Axis

Ax2.Ax2()
Ax2.Location()
Ax2.XDirection()
Ax2.YDirection()
Ax2.Direction()
Ax2.Transform(tr)

Ax3 objects

class Ax3

Axis 3 class. Defined by a point and 2 directions.

Ax3.Ax3(point, direction, directionX)
Parameters:
  • point (Pnt) – Location of axis

  • direction (Dir) – Direction of Z-Axis

  • directionX (Dir) – Direction of X-Axis

Ax3.Ax3()
Ax3.Location()
Ax3.XDirection()
Ax3.YDirection()
Ax3.Direction()
Ax3.Transform(tr)

Trsf objects

Transform objects that can be applied to most foundation classes

Example usage:

ax = Ax1(Pnt(), Dir(0, 0, 1))
rot = math.pi * 0.5

# Create identify transform
tr = Trsf()

# Set rotation transform using Ax1 and rotation angle [rad]
tr.SetRotation(ax, rot)

# Point will be rotated about Z axis by 90 degrees
p = Pnt(1, 0, 0)
p.Transform(tr)
class Trsf

Transformation. Supports rotation, translation, scaling.

Trsf.Trsf()
Trsf.Trsf(tr)
Trsf.SetRotation(ax1, angleRad)

Set the transform to a rotation about an axis

Trsf.SetScale(point, scaleFactor)

Set scale transform about an anchor point

Trsf.SetDisplacement(ax3_0, ax3_1)

Set transform as the affine transform between two defined Ax3 coordinate systems

Trsf.SetTranslation(vec)

Set as translation by a vector

Trsf.SetValues(a11, a12, a13, a14, a21, a22, a23, a24, a31, a32, a33, a34)

Set transform matrix values

Trsf.GetValue(i, j)

Get transform matrix by row and column index. Indexing is 1-based

Parameters:
  • i (int) – row index (1-based)

  • j (int) – column index (1-based)

Returns:

matrix value at a_ij

Trsf.Invert()

Invert the transform matrix

Lin objects

A Line defined as point and a direction

class Lin

Line defined as Ax1

Lin.Lin()
Lin.Lin(ax1)
Parameters:

ax1 (Ax1) – Line defined from an Axis

Lin.Lin(point, direction)
Parameters:
  • point (Pnt) – Location of axis

  • direction (Dir) – Direction line

Lin.Location()
Lin.Direction()
Lin.Position()
Lin.SetLocation(point)
Lin.SetDirection(direction)
Lin.SetPosition(position)
Lin.Transform(tr)

IntCurvesFace_ShapeIntersector

Intersect shapes with Lin objects. Useful for extracting faces for usage as an InletOutlet definition

Example usage:

s = TopoDS_Shape.CreateDisc(Ax2(Pnt(), Dir(0, 0, 1)), 0.1)
line = Lin(Pnt(0, 0, -1), Dir(0, 0, 1))

# Create intersection algorithm object
alg = IntCurvesFace_ShapeIntersector()

# Load the shape you need to intersect
alg.Load(s, 1e-6)

# Perform the intersection with a given line
alg.Perform(line, -1000, 1000)

# Use the output. Note that 1-based indexing is used
print (alg.Pnt(1))
class IntCurvesFace_ShapeIntersector
IntCurvesFace_ShapeIntersector.IntCurvesFace_ShapeIntersector()
IntCurvesFace_ShapeIntersector.Load(shape, tolerance)

Load the given shape into the intersector algorithm

IntCurvesFace_ShapeIntersector.Perform(line, minParam, maxParam)

Intersect the input line with the loaded shape. minParam and maxParam are usually set to large negative and positive values

IntCurvesFace_ShapeIntersector.IsDone()

Returns True if the intersector algorithm is done

IntCurvesFace_ShapeIntersector.NbPnt()

Returns number of intersections

IntCurvesFace_ShapeIntersector.Pnt(index)

Returns the intersection point at the i-th index value. 1-based indexing

IntCurvesFace_ShapeIntersector.Face(index)

Returns the intersected face at the i-th index value. 1-based indexing

BRepCompoundBuilder

Create TopoDS_Compound objects by appending Shapes

class BRepCompoundBuilder

Build compound shapes

BRepCompoundBuilder.Add(shape)

Add a shape to the compound

BRepCompoundBuilder.GetShape()

Return the currently defined compound shape

Shape Topology

class TopoDS_Shape

Base class for geometry topology

TopoDS_Shape.TopoDS_Shape()
TopoDS_Shape.IsNull()

Returns True if the shape is null, or otherwise contains no data

TopoDS_Shape.ShapeType()

Returns shape type

TopoDS_Shape.Transform()

Transform this shape in place

TopoDS_Shape.Transformed()

Transform the shape and return a copy

TopoDS_Shape.ComputeBoundingBox()

Compute the bounding box and return it

TopoDS_Shape.SaveAsSTEP(filename)

Save the shape as a STEP file

TopoDS_Shape.SaveAsIGES(filename)

Save the shape as an IGES file

TopoDS_Shape.SaveAsOCCBrep(filename)

Save the shape as an OCC Brep file format

classmethod TopoDS_Shape.LoadFromFile(filename)

Load the shape from a supported file type: *.iges, *.step, *.brep, *.xt, *.xt_b, *.stl, *.obj

classmethod TopoDS_Shape.CreateSolidCylinder(ax2, diameter, length)
classmethod TopoDS_Shape.CreatePipeCylinder(ax2, diameter, length)
classmethod TopoDS_Shape.CreateBox(p1, p2)
classmethod TopoDS_Shape.CreateDisc(ax2, diameter)
classmethod TopoDS_Shape.CreateSphere(point, diameter)
class TopoDS_Compound

Derived from TopoDS_Shape

class TopoDS_CompSolid

Derived from TopoDS_Shape

class TopoDS_Edge

Derived from TopoDS_Shape

class TopoDS_Shell

Derived from TopoDS_Shape

class TopoDS_Solid

Derived from TopoDS_Shape

class TopoDS_Vertex

Derived from TopoDS_Shape

class TopoDS_Wire

Derived from TopoDS_Shape

Meshes

class Mesh
Mesh.Transform(tr)

Transform the mesh

Mesh.NFaces()

Returns the number of faces in the mesh

Mesh.NNodes()

Return number of nodes in mesh

Mesh.SaveAsSTL(filename)

Save mesh in STL binary format

Mesh.ComputeBoundingBox()

Compute and return the bounding box

classmethod Mesh.LoadFromFile(tr)

Load a mesh from a supported file type: *.stl, *.obj

Bounding box

class Bnd_Box

Bounding box class

Bnd_Box.Bnd_Box()

Construct empty box

Bnd_Box.Bnd_Box(pntMin, pntMax)
Parameters:
  • pntMin (Pnt) – Lower point

  • pntMax (Pnt) – Upper point

Construct box with min and max points

Bnd_Box.AddPoint(point)
Parameters:

point (Pnt) – Location to include in bounding box

Add a point to the bounding box

Bnd_Box.IsVoid()

Returns True if box is empty

Bnd_Box.GetMin()

Return minimum point

Bnd_Box.GetMax()

Return maximum point

Bnd_Box.GetCenter()

Return center point

Bnd_Box.GetDiagonal()

Return diagonal vector

class GProp_GProps

Class holds moment of inertia value calculation results

GProp_GProps.Mass()

Mass value

Return type:

float

GProp_GProps.CenterOfMass()
Return type:

gp_Pnt

GProp_GProps.MomentOfInertia(ax1)
Return type:

float

Parameters:

ax1 (Ax1) – axis

GProp_GProps.RadiusOfGyration(ax1)
Return type:

float

Parameters:

ax1 (Ax1) – axis

GProp_GProps.GetIxx()
Return type:

float

GProp_GProps.GetIyy()
Return type:

float

GProp_GProps.GetIzz()
Return type:

float

GProp_GProps.GetIxy()
Return type:

float

GProp_GProps.GetIxz()
Return type:

float

GProp_GProps.GetIyz()
Return type:

float