This documentation is for the free plugin Py4D in CINEMA 4D R11.5 and not for the C4DSDK of Python in CINEMA 4D R12. For R12, please visit PluginCafe.com

c4d.utils.SplineHelp - a helper class for Splines

Helper class for SplineObject. All values returned are in global space. The slow part is the InitSpline.

class c4d.utils.SplineHelp

Methods

SplineHelp.__init__()
Return type:SplineHelp
Returns:A new splinehelp object.
SplineHelp.InitSpline(op[, up=c4d.Vector(0.0)][, rail=None][, target_rail=True][, use_deformed_points=False][, force_update=False][, use_global_space=True])

Call before using the spline help class. (Must be called before any other command.)

Parameters:
  • op (SplineObject) – The spline object to use.
  • up (Vector) – Optional upvector for the spline normals generation. This is only used at the start of splines/segments; this way it avoids gimbal lock if at all possible.
  • rail (BaseObject) – Optional rail spline object for the spline normals generation.
  • target_rail (bool) – The optional rail spline is not only used as up-vector but also as target. This is used for instance in MoGraph’s Rail options (Cloner, Spline effector, Spline Wrap etc.).
  • use_deformed_points (bool) – Use deformed point positions of the spline.
  • force_update (bool) – The spline help class internally caches its own content. Thus it will be much faster if the same splines are used for initialization. However, a full initialization can be forced by setting this parameter to True.
  • use_global_space (bool) – If True the resulting matrices are in global space rather than in the spline objects’ local space.
Return type:

bool

Returns:

True if successful, otherwise False.

SplineHelp.FreeSpline()
Called to free the spline data. Recalling InitSpline or calling SplineHelp.__free__ will automatically call this.
SplineHelp.GetSegmentCount()

Gets the number of segments in the spline.

Note

Unlike the way CINEMA 4D handles segments where a segmenet count of 0 means there’s either no segments or 1 segment, this returns 1 segment if there is 1 and 0 if there are 0.

Return type:int
Returns:Segment count.
SplineHelp.Exists()

Useful check to see if the spline helper contains data and has been inited.

Return type:bool:
Returns:True if the spline helper is ready to use, otherwise False.
SplineHelp.GetVertexMatrix(index)

Retrieves a full matrix for a specific point of the line.

Note

This is not the spline vertex, but instead the line object’s vertex. (Calculated with LOD=1.0.)

Parameter:index (int) – Line object vertex index, 0 <= index < lineobjectpointcount.
SplineHelp.GetPointValue(offset, segment)

Converts a natural offset value to a real percentage offset value.

Note

This percentage uses the realworld units for its offset, so regardless of how the spline’s points and interpolation is set, a gap of 2% on a 100m long spline will always be 2m whereas normally in spline natural space, a gap of 2% can vary a great deal depending on the spline’s interpolation etc.

Parameters:
  • offset (float) – The offset given in spline space.
  • segment (int) – Segment index, 0 <= segment < GetSegmentCount
Return type:

float

Returns:

The realworld percentage offset.

SplineHelp.GetPointIndex(offset, segment)

Converts a natural offset value to a real percentage offset value.

Note

This percentage uses the realworld units for its offset, so regardless of how the spline’s points and interpolation is set, a gap of 2% on a 100m long spline will always be 2m whereas normally in spline natural space, a gap of 2% can vary a great deal depending on the spline’s interpolation etc.

Parameters:
  • offset (float) – The offset given in spline space.
  • segment (int) – Segment index, 0 <= segment < GetSegmentCount
Return type:

int

Returns:

The nearest line object point index, rounded down.

SplineHelp.GetPos(offset[, segment=0, smooth=True])

Converts a natural offset value to a real percentage offset value.

Note

This percentage uses the realworld units for its offset, so regardless of how the spline’s points and interpolation is set, a gap of 2% on a 100m long spline will always be 2m whereas normally in spline natural space, a gap of 2% can vary a great deal depending on the spline’s interpolation etc.

Parameters:
  • offset (float) – The spline offset.
  • segment (int) – Segment index, 0 <= segment < GetSegmentCount
  • smooth (bool) – Smoothed position.
Return type:

Vector

Returns:

The position given by offset.

SplineHelp.GetTangent(offset[, segment=0, smooth=True])

Gets a tangent vector for any point along the spline.

Parameters:
  • offset (float) – The spline offset.
  • segment (int) – Segment index, 0 <= segment < GetSegmentCount
  • smooth (bool) – Smoothed tangent.
Return type:

Vector

Returns:

The tangent.

SplineHelp.GetNormal(offset[, segment=0, smooth=True])

Gets a normal vector for any point along the spline.

Parameters:
  • offset (float) – The spline offset.
  • segment (int) – Segment index, 0 <= segment < GetSegmentCount
  • smooth (bool) – Smoothed normal.
Return type:

Vector

Returns:

The tangent.

SplineHelp.GetCrossNormal(offset[, segment=0, smooth=True])

Gets a cross normal vector (i.e. perpendicular to the normal and the tangent) for any point along the spline.

Parameters:
  • offset (float) – The spline offset.
  • segment (int) – Segment index, 0 <= segment < GetSegmentCount
  • smooth (bool) – Smoothed cross normal.
Return type:

Vector

Returns:

The tangent.

SplineHelp.GetSplineLength([i=NOTOK])

Returns the spline’s realworld unit length including all segments.

Param:Returns the spline’s realworld unit length including all segments. If argument i is NOT_OK, the whole spline length will be returned, otherwise the specific segment’s length returns.
Return type:float
Returns:The length
SplineHelp.SplineToLineIndex(index)

Converts a spline vertex index to its corresponding line object vertex index.

Parameter:index (int) – The spline vertex index.
Return type:int
Returns:The line object vertex index.

Table Of Contents

This Page