CreateOffset Method


Creates a new curve that is an offset of the existing curve.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 17.0.0.0 (17.0.484.0)
Since: 2015

Syntax

C#
public Curve CreateOffset(
	double offsetDist,
	XYZ referenceVector
)
Visual Basic
Public Function CreateOffset ( _
	offsetDist As Double, _
	referenceVector As XYZ _
) As Curve
Visual C++
public:
Curve^ CreateOffset(
	double offsetDist, 
	XYZ^ referenceVector
)

Parameters

offsetDist
Type: System Double
The signed distance that controls the offset.
referenceVector
Type: Autodesk.Revit.DB XYZ
A reference vector to define the offset direction.

Return Value

The new curve.

Remarks

The offset curve is obtained by moving the points of the given curve by a certain distance (not necessarily the input distance) to the right relative to the reference vector. If the distance is negative, then the offset will be actually on the left side. The precise role played by the reference vector depends on the curve type in an inconsistent way, as specified in detail below. We plan to update this function to have a more consistent and understandable behavior.

For Line, HermiteSpline, NurbSpline and Cylindrical Helix, the right direction is along the cross product of the tangent at that point and the reference vector. In other words, the "right" side of the curve at a given point on the curve is defined with the reference vector being thought of as the upward direction and curve tangent being thought of as the forward direction, as if you are walking along the curve with your body aligned to the reference vector.

For Arc and Ellipse, the right direction is defined relative to the axis of the arc or ellipse in conjunction with the reference vector. If the dot product of the reference vector with the axis is positive, then the right direction is along the cross product of the curve tangent the axis. If the dot product is negetive, then it is in the other way. If the dot product is zero, then it is an input error.

More details of the behavior depending on the type of curve: Line: For a Line, a vecPerp is computed as the cross product of the line direction and the reference vector. The offset is obtained by moving the line by the given distance along the direction of the vecPerp. Note: vecPerp can be zero vector if the reference vector is parallel to the line direction. In that case, the offset is simply a copy of the given line. No error is reported. Arc: For an Arc, the offset is done in the plane of the arc. The resulting offset is another arc in the same plane as the given arc and with the same center. The radius is increased or decreased by the offset distance depending on the offset is to the right or left. The reference vector is used to determine if the offset is to be done to the right or left of the arc, based on the dot product of the reference vector with the axis (normal vector) of the arc. If the dot product is positive then the offset is to the right relative to the axis of the arc; if not, it is to the left. If the dot product is zero, that is, reference vector is perpendicular to the axis, the function will return NULL and report an error. Ellipse: An Ellipse is also a planar curve like the Arc. The offset is done in the plane of the ellipse. Note that the offset of an ellipse is not an ellipse in general. It will be approximated by a Hermite spline curve. The offset curve is obtained by offsetting the points of the ellipse, by the given offset distance, to the right or left relative to the axis (normal vector) of the ellipse. The reference vector is used to determine if the offset is to be done to the right or left of the ellipse, based on the dot product of the reference vector with the axis of the ellipse. If the dot product is positive then the offset is to the right relative to the axis of the ellipse; if not, it is to the left. If the dot product is zero, that is, reference vector is perpendicular to the axis, the function will return NULL and report an error. HermiteSpline, NurbSpline and Cylindrical Helix: A Hermite or Nurbs spline curve can be planar or non-planar; a cylindrical helix is non-planar. For these three types of curves, the offset is computed in a general way as follows: Let P be a point on the given curve and let T be the unit tangent vector at P, assuming that the derivative of the curve at P is not zero. The offset vector at P is the cross product of T and the reference vector. Then the offset point Q corresponding to P is computed as: Q = P + (offset distance) * (offset vector at P). The offset depends on the magnitude as well as the direction of the reference vector. If the magnitude of the reference vector is not one, then the actual distance moved will not be the given offset distance. NOTE: If the curve is a planar Hermite or Nurbs spline curve, the offset curve may not lie on the same plane – unlike the case of arc and ellipse.

Exceptions

Exception Condition
Autodesk.Revit.Exceptions InvalidOperationException Cannot create the offset of the curve.

See Also