cape.step: Python interface to STEP Files

This module provides an interface to import points, curves, and potentially other entities in the future from STEP files following ISO 10303-21. It provides the class cape.step.STEP, which allows the user to read (preferably simple) STEP files. Its primary purpose is to read STEP files and write Plot3D curve files.

See also:

  • pc_Step2Crv

  • pc_StepTri2Crv

class cape.step.STEP(fname=None, xtol=None, ytol=None, ztol=None)

Interface for STEP files

Call:
>>> stp = STEP(fname)
Inputs:
fname: str

Name of STEP file to read (.stp or .step)

Outputs:
stp: cape.step.STEP

STEP file interface

stp.npt: int

Number of points defined in file

stp.ncrv: int

Number of curves

stp.pts: np.ndarray (float) shape=(npt,3)

Array of coordinates of all points defined in file

stp.ipt: np.ndarray (int) shape=(npt,)

Array of point entity indices; pts[i] is entity pts[ipt[i]]

stp.crvs: list (np.ndarray | None)

List of sampled curves; initialized to None

stp.ocrv: list (int)

Order of each spline

stp.icrv: list (np.ndarray (int))

Array of indices of knots for each spline

Versions:
  • 2016-05-10 @ddalle: First version

EvaluateCurve(j, u)

Evaluate B-spline of curve j

Call:
>>> Y = stp.EvaluateCurve(j, u)
Inputs:
stp: cape.step.STEP

STEP file interface

j: int

Curve number

u: np.ndarray (float)

Values of input parameter to splev(); like arc length

Outputs:
Y: np.ndarray (float) shape=(u.size,3)

Points along the spline

Versions:
  • 2016-05-10 @ddalle: First version

GetCurveKnots(j)

Get knots of curve j

Call:
>>> X = stp.GetCurveKnots(j)
Inputs:
stp: cape.step.STEP

STEP file interface

j: int

Curve number

Outputs:
X: np.ndarray (float) shape=(ncrvj,3)

Matrix of x, y, and z coordinates of curve j

Versions:
  • 2016-05-10 @ddalle: First version

GetTurningAngle(j)

Calculate turning angles between each segment of sampled curve j

Call:
>>> theta = stp.GetTurningAngle(j)
Inputs:
stp: cape.step.STEP

STEP file interface

j: int

Curve number

Outputs:
theta: np.ndarray (float)

Angle between each pair of segments in degrees

Versions:
  • 2016-05-10 @ddalle: First version

GetWeightedTurningAngle(j)

Calculate turning angles between each segment of sampled curve j

The turning angle is weighted by the sum of the lengths of the neighboring segments

Call:
>>> a = stp.GetWeightedTurningAngle(j)
Inputs:
stp: cape.step.STEP

STEP file interface

j: int

Curve number

Outputs:
a: np.ndarray (float)

Length-weighted angle for each pair (in degree-inches)

Versions:
  • 2016-05-10 @ddalle: First version

LinkCurves(axis='x', ds=1.0)

Reorder curves into a single chain

This also ensures that the end of curve j is the start of j+1.

Call:
>>> stp.LinkCurves(axis='x', ds=1.0)
Inputs:
stp: cape.step.STEP

STEP file interface

axis: {x} | y | z | -x | -y | -z

Dominant sorting axis

ds: None | float

Maximum gap to close between start and end points

Versions:
  • 2016-05-10 @ddalle: First version

Read(fname)

Read a STEP file

Call:
>>> stp.Read(fname)
Inputs:
stp: cape.step.STEP

STEP file interface

fname: str

Name of file to read

Versions:
  • 2016-05-10 @ddalle: First version

SampleCurve(j, n=None, ds=None, dth=None, da=None)

Evaluate a B-spline with uniformly distributed points

Call:
>>> y = stp.SampleCurve(j, n=None, ds=None, dth=None)
Inputs:
stp: cape.step.STEP

STEP file interface

j: int

Curve number

n: int

(Minimum) number of intervals to use

ds: float

Upper bound of uniform spacing

dth: float | {None}

Maximum allowed turning angle in degrees

da: float | {None}

Maximum allowed length-weighted turning angle

Outputs:
y np.ndarray (float) shape=(n,3)

Uniformly spaced points along the spline

Versions:
  • 2016-05-10 @ddalle: First version

SampleCurves(J=None, n=None, ds=None, dth=None, da=None)

Evaluate a list of B-splines with uniformly distributed points

Call:
>>> stp.SampleCurves(J=None, n=None, ds=None, dth=None, da=None)
Inputs:
stp: cape.step.STEP

STEP file interface

J: {None} | int

List of curve numbers (defaults to all curves)

n: int

Number of intervals to use

ds: float

Upper bound of uniform spacing

dth: float | {None}

Maximum allowed turning angle in degrees

da: float | {None}

Maximum allowed length-weighted turning angle

Versions:
  • 2016-05-10 @ddalle: First version

WritePlot3DCurves(fname, J=None, bin=False, endian=None)

Write list of curves to Plot3D format

Call:
>>> stp.WritePlot3DCurves(fname, J=None)
Inputs:
stp: cape.step.STEP

STEP file interface

fname: str

Name of Plot3D file to create

J: {None} | list (int)

List of curve indices to write (default is all)

Versions:
  • 2016-05-10 @ddalle: First version

WritePlot3DCurvesASCII(fname, J=None)

Write list of curves to ASCII Plot3D format

Call:
>>> stp.WritePlot3DCurvesASCII(fname, J=None)
Inputs:
stp: cape.step.STEP

STEP file interface

fname: str

Name of Plot3D file to create

J: {None} | list (int)

List of curve indices to write (default is all)

Versions:
  • 2016-05-10 @ddalle: First version

WritePlot3DCurvesBin(fname, J=None, **kw)

Write list of curves to ASCII Plot3D format

Call:
>>> stp.WritePlot3DCurvesBin(fname, J=None, endian=None, **kw)
Inputs:
stp: cape.step.STEP

STEP file interface

fname: str

Name of Plot3D file to create

J: {None} | list (int)

List of curve indices to write (default is all)

endian: {None} | "big" | "little"

Byte order; use system default if not specified

single: True | {False}

Whether or not to write single-precision

Versions:
  • 2016-05-10 @ddalle: First version

WritePlot3DCurves_lr4(fname, J)

Write list of curves to single-precision little-endian file

Call:
>>> stp.WritePlot3DCurves_lr4(fname)
Inputs:
stp: cape.step.STEP

STEP file interface

fname: str

Name of Plot3D file to create

J: {None} | list (int)

List of curve indices to write (default is all)

Versions:
  • 2016-09-29 @ddalle: First version

WritePlot3DCurves_lr8(fname, J)

Write list of curves to single-precision little-endian file

Call:
>>> stp.WritePlot3DCurves_lr4(fname)
Inputs:
stp: cape.step.STEP

STEP file interface

fname: str

Name of Plot3D file to create

J: {None} | list (int)

List of curve indices to write (default is all)

Versions:
  • 2016-09-29 @ddalle: First version

WritePlot3DCurves_r4(fname, J)

Write list of curves to double-precision big-endian file

Call:
>>> stp.WritePlot3DCurves_r4(fname)
Inputs:
stp: cape.step.STEP

STEP file interface

fname: str

Name of Plot3D file to create

J: {None} | list (int)

List of curve indices to write (default is all)

Versions:
  • 2016-09-29 @ddalle: First version

WritePlot3DCurves_r8(fname, J)

Write list of curves to double-precision big-endian file

Call:
>>> stp.WritePlot3DCurves_r8(fname)
Inputs:
stp: cape.step.STEP

STEP file interface

fname: str

Name of Plot3D file to create

J: {None} | list (int)

List of curve indices to write (default is all)

Versions:
  • 2016-09-29 @ddalle: First version