AutoCAD.Spline

Inherits from AutoCAD.Entity

Description

A class that encapsulates a spline in a DWG file.

This class is a FlexScript wrapper for the AcDbSpline class.

Properties

degree The degree of the spline's polynomial representation. A value in the range 1 to 25.
fitTolerance The tolerance value used for curve fitting.
hasFitData Returns 1 if the spline has fit data associated with it, otherwise 0.
isNull Returns 1 if the spline has no underlying gelib object to maintain the spline information, otherwise 0.
isRational Returns 1 if the spline is rational, otherwise 0.
numControlPoints Returns the number of control points in the spline.
numFitPoints Returns the number of fit points associated with the spline.
type Returns the type of spline.

Methods

elevateDegree Increases the degree of the spline to degree.
getControlPointAt Gets the value of the control point at position index in the list of control points.
getFitData If the spline has fit data, then this method gets all the fit points, fit tolerance, knot parameterization, and, if tangents exist, the start and end tangents of the spline.
getFitPointAt Gets the fit point at index.
getFitTangents Gets the start point and end point tangent vectors.
getNurbsData Gets the NURBS data of the spline which includes the degree, if the spline is rational, if the spline is closed, if the spline is periodic, the control point coordinates, knot values, weights for the control points, control point tolerance, and knot value tolerance.
getWeightAt Returns the weight of the control point at index.
insertControlPointAt Add a control point on the spline at the given knot parameter.
insertFitPointAt Adds point to the list of fit points and refits the spline.
insertKnot Inserts a new knot into the spline at the location on the spline defined by param.
purgeFitData Purges the fit data if the spline is a fitted spline.
rebuild Rebuild the spline with the degree and number of control points.
removeControlPointAt Remove a control point at the given index.
removeFitPointAt Removes the fit point at index in the list of fit points of the spline and refits the spline.
setControlPointAt Sets point to be the control point at the index position in the control points list replacing the point value that was previously at index position.
setFitData
setFitPointAt Sets point to be the fit point at the index position in the fit points list (replacing the point value previously at index) and then refits the spline.
setFitTangents Sets the start end tangents of spline to be startTangent and endTangent respectively and refits the spline.
setNurbsData This function replaces any existing spline data with the data passed in.
setWeightAt Changes the weight of the point at the index location in the control points array to weight.

Static Methods

create Creates a new AutoCAD.Spline object.

Details

Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.degree

readonly int degree

Description

The degree of the spline's polynomial representation. A value in the range 1 to 25.

Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.fitTolerance

double fitTolerance

Description

The tolerance value used for curve fitting.

This is the maximum distance (in drawing units) that the spline curve is allowed to deviate from the fit points.
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.hasFitData

readonly int hasFitData

Description

Returns 1 if the spline has fit data associated with it, otherwise 0.

Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.isNull

readonly int isNull

Description

Returns 1 if the spline has no underlying gelib object to maintain the spline information, otherwise 0.

For more information, reference the AcDbSpline class.
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.isRational

readonly int isRational

Description

Returns 1 if the spline is rational, otherwise 0.

Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.numControlPoints

readonly int numControlPoints

Description

Returns the number of control points in the spline.

Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.numFitPoints

readonly int numFitPoints

Description

Returns the number of fit points associated with the spline.

Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.type

int type

Description

Returns the type of spline.

The spline was either created by fit points or by control points.
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.elevateDegree()

elevateDegree( int degree )

Parameters

degree The new degree to elevate to.

Description

Increases the degree of the spline to degree.

Increases the degree (which is the same as the order -1) of the spline to degree. Once incremented it cannot be decremented. The valid range is between (current degree) and 25. The spline's order is the degree + 1. Elevating degree won't change the shape. When the spline is periodic, elevating degree will make it non-periodic.
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.getControlPointAt()

Vec3 getControlPointAt( int index )

Parameters

index Input index (0 based) of the point to get.

Returns

Vec3 The control point coordinates.

Description

Gets the value of the control point at position index in the list of control points.

If index is negative or more than the number of control points in the spline, then point is set to the last control point.
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.getFitData()

Array getFitData( )

Returns

Array An array holding all the fit data information.

Description

If the spline has fit data, then this method gets all the fit points, fit tolerance, knot parameterization, and, if tangents exist, the start and end tangents of the spline.


                ...
                // iter is a block table's iterator
                AutoCAD.entity ent = iter.getEntity();
                var spline = ent.as(AutoCAD.Spline);
                Array fitData = spline.fitData;
                Array fitPoints = fitData[1];
                int tangentsExist = fitData[2];
                Array startTangent = fitData[3];
                Array endTangent = fitData[4];
                int knotParam = fitData[5];
                int degree = fitData[6];
                double fitTolerance = fitData[7];
                ...
            
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.getFitPointAt()

Vec3 getFitPointAt( int index )

Parameters

index The index of the fit point to get.

Returns

Vec3 The fit point coordinates.

Description

Gets the fit point at index.

Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.getFitTangents()

Array getFitTangents( )

Returns

Array An array with the coordinates for the start and end tangents.

Description

Gets the start point and end point tangent vectors.


                ...
                 // iter is a block table's iterator
                AutoCAD.entity ent = iter.getEntity();
                var spline = ent.as(AutoCAD.Spline);
                Array tangents = spline.getFitTangents();
                Vec3 startTangent = tangents[1];
                Vec3 endTangent = tangents[2];
                ...
            
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.getNurbsData()

Array getNurbsData( )

Returns

Array An array with the coordinates for the start and end tangents.

Description

Gets the NURBS data of the spline which includes the degree, if the spline is rational, if the spline is closed, if the spline is periodic, the control point coordinates, knot values, weights for the control points, control point tolerance, and knot value tolerance.


                ...
                 // iter is a block table's iterator
                AutoCAD.entity ent = iter.getEntity();
                var spline = ent.as(AutoCAD.Spline);
                Array nurbsData = spline.getNurbsData();
                int degree = nurbsData[1];
                int isRational = nurbsData[2];
                int isClosed = nurbsData[3];
                int isPeriodic = nurbsData[4];
                Array controlPoints = nurbsData[5];
                Array knots = nurbsData[6];
                Array weights = nurbsData[7];
                double controlPointTolerance = nurbsData[8];
                double knotTolerance = nurbsData[9];
                ...
            
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.getWeightAt()

double getWeightAt( int index )

Parameters

index Input index (0 based) of the control point.

Returns

double The weight of the control point at index.

Description

Returns the weight of the control point at index.

Weights can only exist for rational splines, so if the spline is not rational, -1 is returned. If index is negative or greater than the number of control points, then 1 is returned.
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.insertControlPointAt()

insertControlPointAt( int index , Vec3 controlPoint , double weight = 1.0 )

Parameters

index Input knot parameter.
controlPoint Input control point.
weight Input weight.

Description

Add a control point on the spline at the given knot parameter.

If the spline is non-rational, the weight value will be ignored.
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.insertFitPointAt()

insertFitPointAt( int index , Vec3 point )

Parameters

index Input index (0 based) where new fit point is to be inserted.
point Input new fit point.

Description

Adds point to the list of fit points and refits the spline.

point is added at the index position in the fit points list. If index is negative, then point is added at the beginning of the spline. If index is greater than the number of fit points in the spline, then point is added at the end of the spline.
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.insertKnot()

insertKnot( double param )

Parameters

param Input parameter where the knot is to be added.

Description

Inserts a new knot into the spline at the location on the spline defined by param.

The param value must be within the spline's parameter range. To obtain the spline's parameter range, use the getNurbsData() method to obtain an array of the current knot values. The first knot value is the spline's start parameter value, while the last knot is the spline's end parameter.
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.purgeFitData()

purgeFitData( )

Description

Purges the fit data if the spline is a fitted spline.

Once the fit data has been removed, the spline uses its control point or NURBS data.
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.rebuild()

rebuild( int degree , int numControlPoints )

Parameters

degree The new degree.
numControlPoints The new number of control points.

Description

Rebuild the spline with the degree and number of control points.

This will change the shape of the spline. The degree can't be higher than 11.
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.removeControlPointAt()

removeControlPointAt( int index )

Parameters

index Input index.

Description

Remove a control point at the given index.

Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.removeFitPointAt()

removeFitPointAt( int index )

Parameters

index Index (0 based) of the fit point to be removed.

Description

Removes the fit point at index in the list of fit points of the spline and refits the spline.

There must be at least three fit points in the spline for this function to succeed.
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.setControlPointAt()

setControlPointAt( int index , Vec3 point )

Parameters

index Input index (0 based) of the control point to replace.
point Input new control point.

Description

Sets point to be the control point at the index position in the control points list replacing the point value that was previously at index position.

Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.setFitData()

setFitData( Array fitPoints , int isPeriodic , int knotParam , int degree = 3 , double fitTolerance = 0.0 )
setFitData( Array fitPoints , Vec3 startTangent , Vec3 endTangent , int knotParam , int degree = 3 , double fitTolerance = 0.0 )

Parameters

fitPoints Array of points through which to fit the curve.
isPeriodic Whether to create a periodic spline fitting the array of points or not.
knotParam Knot parameterization which defines the knot values.
degree Degree of the spline to be created (in the range 1 to 11).
fitTolerance Tolerance to which the spline should approximate fitPoints.
startTangent Input start tangent for spline.
endTangent Input end tangent for spline.

Description

spline.setFitData(fitPoints, isPeriodic, AutoCAD.KnotParam.kUniform, 4, 0.2);

Resets a spline that attempts to fit a curve to the array of points within the tolerance fitTolerance. A fitTolerance of 0 causes the curve to be interpolated precisely through all the points in the points array. The curve degree may be in the range 1 to 11. The periodic specifies whether to create a periodic spline fitting the array of points or not. The knotParam specifies the way that the knots are created. The different knot sequences have an impact on the curve shape. AutoCAD provides three options : kChord, kSqrtChord and kUniform. kUniform is the default value.


spline.setFitData(fitPoints, startTangent, endTangent, AutoCAD.knotParam.kUniform, 3, 0);

Replaces any existing spline data (fit or NURBS) with the fit data fitPoints, startTangent, endTangent, knot parameterization, fitTolerance. fitPoints must contain 2 or more points. The magnitude of startTangent and endTangent affects the shape of the curve. degree has no effect; a spline with degree=3 is always constructed when interpolating a series of fit points. If fitTolerance is 0, then the spline passes through all the fit points; otherwise the spline passes within fitTolerance of each fit point.

Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.setFitPointAt()

setFitPointAt( int index , Vec3 point )

Parameters

index Input index (0 based) of the fit point to replace.
point Input new fit point.

Description

Sets point to be the fit point at the index position in the fit points list (replacing the point value previously at index) and then refits the spline.

Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.setFitTangents()

setFitTangents( Vec3 startTangent , Vec3 endTangent )

Parameters

startTangent New start tangent vector.
endTangent New end tangent vector.

Description

Sets the start end tangents of spline to be startTangent and endTangent respectively and refits the spline.

Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.setNurbsData()

setNurbsData( int degree , int rational , int closed , int periodic , Array controlPoints , Array knots , Array weights , double controlPointTolerance = 0.0 , double knotTolerance = 0.0 )

Parameters

degree Input degree of spline (in the range 1 to 25).
rational Whether or not the spline is to be rational.
closed Whether or not the spline is to be closed.
periodic Whether or not the spline is to be periodic.
controlPoints Input array of control points.
knots Input array of knot values.
weights Input array of weights for control points.
controlPointTolerance Input control points tolerance (in drawing units).
knotTolerance Input knot tolerance (in drawing units).

Description

This function replaces any existing spline data with the data passed in.

periodic should only be set to 1 if the spline is closed. A periodic spline is a spline with period T such that the point at parameter value t + T is the same as the point at parameter value t for any value of t.


The weights array is only used when rational is 1. If used, it must have the same number of entries as the controlPoints array. All weight values must be greater than 0.0.


If periodic is 0, then the length of the knots array must be greater than the length of the controlPoints array by degree + 1. If periodic is 1, then the length of the knots array must be greater than the controlPoints array by 1. The first and last control points must NOT be identical.


The knotTolerance value is used to determine which knot values are to be treated as the same. If the difference between two knot values is less than knotTolerance, then the two values are treated as the same (and the first of the two values will be used).


The controlPointTolerance value is used to determine if two control points are to be treated as the same point. If the distance between two control points is less than controlPointTolerance, then those two points are treated as the same point. If the first and last control points are within controlPointTolerance, the spline is closed regardless of the closed value.


When creating periodic spline, we accept two format of data:

  1. The length of knot vector must be greater than length of the control array by 1. The first and the last control points must NOT be identical.
  2. The knot vector and control array must have same length, and the first and the last control points must be identical.
The first format is preferred and will be returned when calling getNurbsData(), even if you use set data using the second format.


The knot vector should contains distinct knot value. For example, if we want to create a periodic spline with four control points, the knot vector could be (0, 1, 2, 3, 4).

Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.setWeightAt()

setWeightAt( int index , double weight )

Parameters

index Input index (0 based) of the control point at which to change the weight.
weight Input new weight value.

Description

Changes the weight of the point at the index location in the control points array to weight.

If the spline is not a rational spline, then it is converted to a rational spline.
Do no remove, this fixes the anchor on doc.flexsim.com

AutoCAD.Spline.create()

static AutoCAD.Spline create( )

Returns

AutoCAD.Spline A new AutoCAD.Spline object.

Description

Creates a new AutoCAD.Spline object.

var spline = AutoCAD.Spline.create();