Value > MAXWrapper > Node > GeometryClass > Shape > SplineShape |
SplineShapes are the general editable versions of all the shape objects, in the same way that Editable Meshes relate to geometry objects. They are the objects that a shape is converted to when you apply an Edit Spline modifier and the result of collapsing a modifier stack on a shape base object. MAXScript lets you construct SplineShapes from scratch, add individual curves (splines) and controls points (knots) or modify an existing shape by converting it to a SplineShape and using the methods listed below.
For practical examples of creating and modifying spline shapes, see also
MAXScript FAQ:How do I create a line between two points?
How To ... Flatten a SplineShape
How To ... Draw a Freehand Spline
You must convert existing shapes to SplineShapes (Editable Splines) in order to operate on them with the methods listed in this topic. Use the convertToSplineShape() function to do this.
Only the updateShape() function updates the shape's internal caches and images in 3ds Max viewports. This is because updates can be computationally expensive and you don't want them performed on every function call. However, you must make sure you do call the updateShape() function after a series of changes and before the shape is to be worked on in 3ds Max or by other functions in MAXScript.
The in and out vectors for Bezier control points are given as vector handle coordinates, not as true vectors as the names suggests.
Coordinates are given in the MAXScript working coordinate system - this is important to note if you are familiar with the corresponding SDK spline functions which always work in object-local coordinates.
If the updateShape() function is called on an object that is selected and currently open in the Modify panel, it will drop the current selection in order to avoid a potential crash in 3ds Max, which at the moment, does not support scripted changes to an object open in the Modify panel
If you are creating or modifying a spline object, and have not yet run updateShape() on the spline, 3ds Max will crash if you minimize and then maximize the 3ds Max window. This is because an only partially created spline is created, and the internal 3ds Max spline structure is left in an unstable state
Toggles the "Enable in Renderer" checkbox on and off.
Available in 3ds Max 8 and higher.
Toggles the "Enable In Viewport" checkbox on and off. When set to true, the mesh will be displayed in the viewports.
Available in 3ds Max 8 and higher.
<SplineShape>.render_useViewportSettings BooleanClass default: false -- boolean; useViewportSettings
Toggles the "Use Viewport Settings" checkbox on and off.
When set to true, the mesh displayed in the viewport will use the Viewport settings.
When false, the Renderer settings will be used for the viewport mesh, too.
Available in 3ds Max 8 and higher.
Toggles mapping coordinates generation on and off.
The U coordinate wraps once around the thickness of the spline; the V coordinate is mapped once along the length of the spline.
Available in 3ds Max 8 and higher.
Toggles the real-world map size option on and off.
Available in 3ds Max 8 and higher.
<SplineShape>.render_displayRenderSettings BooleanClass default: true -- boolean; displayRenderSettings
Toggles the state of the Viewport/Renderer radio buttons.
When set to true, the Renderer settings will be displayed in the rollout.
When false, the Viewport settings will be shown instead.
Available in 3ds Max 8 and higher.
When set to true, enables the Rectangular cross-section mode to be used in the renderer.
When false (default), enables the Radial cross-section mode.
Corresponds to the Radial/Rectangular radio buttons in the UI in Renderer mode.
Available in 3ds Max 8 and higher.
When set to true, enables the Rectangular cross-section mode to be used in the viewports.
When false (default), enables the Radial cross-section mode.
Corresponds to the Radial/Rectangular radio buttons in the UI in Viewport mode.
Available in 3ds Max 8 and higher.
Get/Set the diameter of the Radial renderable spline mesh.
Available in 3ds Max 8 and higher.
Get/Set the number of sides for the spline mesh in the renderer.
A value of 4 will give you a square cross section, for example.
Available in 3ds Max 8 and higher.
Get/Set the rotational position of the Radial cross-section in the renderer.
Get/Set the length of the Rectangular renderable spline mesh.
Available in 3ds Max 8 and higher.
Get/Set the width of the Rectangular renderable spline mesh.
Available in 3ds Max 8 and higher.
Get/Set rotational position of the Radial cross-section in the renderer.
Available in 3ds Max 8 and higher.
Controls the state of the Aspect Lock checkbutton.
When set to true, changing the Width will affect the Height and vice-versa, preserving the aspect at the time the lock was engaged.
Get/Set the diameter of the Radial renderable spline mesh in the viewport.
Available in 3ds Max 8 and higher.
Gets/Sets the number of sides for the Radial spline mesh in the viewports.
A value of 4 will give you a square cross section, for example.
Available in 3ds Max 8 and higher.
Gets/Sets the rotational position of the cross-section in the viewports.
Get/Set the length of the Rectangular spline mesh in the viewports.
Available in 3ds Max 8 and higher.
Get/Set the width of the Rectangular spline mesh in the viewports.
Available in 3ds Max 8 and higher.
Get/Set rotational position of the Rectangular cross-section in the viewports.
Available in 3ds Max 8 and higher.
Controls the state of the Aspect Lock checkbutton.
When set to true, changing the Width will affect the Height and vice-versa, preserving the aspect at the time the lock was engaged.
Controls the state of the Auto Smooth checkbox.
When set to true, auto smoothing will be enabled.
Available in 3ds Max 8 and higher.
Get/set the Auto Smooth Threshold value.Available in 3ds Max 8 and higher.
Up to 3*N vertex and tangent coordinates are available as properties, where N is the number of vertices in the SplineShape.
A vertex and its tangents are available as properties once a controller has been assigned to the vertex.
Controllers can be assigned to vertices using the animateVertex() method described in Scripting Vertex and Control Point Animation.
For example, if a circle object is collapsed to a SplineShape, and some of its vertices are animated, the properties for the vertices and tangents would be similar to:
$Circle01.Spline_1___InVec_1 Point3 value: [-75,33,0] -- animatable $Circle01.Spline_1___Vertex_1 Point3 value: [-75,33,0] -- animatable $Circle01.Spline_1___OutVec_1 Point3 value: [-50,0,0] -- animatable $Circle01.Spline_1___InVec_2 Point3 value: [-20,-33,0] -- animatable $Circle01.Spline_1___Vertex_2 Point3 value: [7,-66,0] -- animatable $Circle01.Spline_1___OutVec_2 Point3 value: [32,-95,0] -- animatable
Controls the Interpolation Steps in the Interpolation rollout.
Controls the state of the Optimize checkbox in the Interpolation rollout.
Controls the state of the Adaptive checkbox in the Interpolation rollout.
Enters "Create Line" command mode - valid in all Sub-Object levels, and when not in Sub-Object mode.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Break" command mode - valid in Vertex and Segment Sub-Object levels.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Attach" command mode - valid in all Sub-Object levels, and when not in Sub-Object mode.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Displays Attach Multiple dialog allowing the user to select multiple shapes to attach. Valid in all Sub-Object levels, and when not in Sub-Object mode.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Refine" command mode - valid in Vertex and Segment Sub-Object levels. This method does not turn off the Connect checkbox, so it is effectively the same as the startRefineConnect() method.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Refine" command mode - valid in Vertex and Segment Sub-Object levels. This method does not turn on the Connect checkbox, so it is effectively the same as the startRefine() method.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Welds the selected vertices - valid in Vertex Sub-Object level.
See also related methods in ShapeMethods-Weld
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Connect" command mode - valid in Vertex Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Insert" command mode - valid in all Sub-Object levels, and when not in Sub-Object mode.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Makes the selected vertices the first vertex in the spline- valid in Vertex Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Fuses the selected vertices. Valid in Vertex Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Reverses the order of vertices in the selected splines - valid in Spline Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Cycles through the vertices of the spline, selecting each vertex.
At least one vertex must be selected before calling this method, or no vertex is selected.
If more than one vertex is selected when this method is called, the first vertex of the first shape is selected.
Valid in Vertex Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "CrossInsert" command mode - valid in Vertex Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Fillet" command mode - valid in Vertex Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Chamfer" command mode - valid in Vertex Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Outline" command mode - valid in Spline Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Boolean Union" command mode - valid in Spline Sub-Object level.
Only 1 closed spline must be selected to enter this command mode.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Boolean Subtract" command mode - valid in Spline Sub-Object level.
Only 1 closed spline must be selected to enter this command mode.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Boolean Intersect" command mode - valid in Spline Sub-Object level.
Only 1 closed spline must be selected to enter this command mode.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Mirrors the selected splines horizontally - valid in Spline Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Mirrors the selected splines vertically - valid in Spline Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Mirrors the selected splines horizontally and vertically - valid in Spline Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Trim" command mode - valid in Spline Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Extend" command mode - valid in Spline Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Copy Tangent" command mode - valid in Vertex Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Paste Tangent" command mode - valid in Vertex Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Hides the selected sub-objects - valid in all Sub-Object levels.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Unhides all hidden sub-objects -valid in all Sub-Object levels, and when not in Sub-Object mode.
See also related methods in Shape Methods -Hide,Unhide
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Enters "Bind" command mode - valid in Vertex Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Unbinds the selected vertices - valid in Vertex Sub-Object level.
See also related methods in ShapeMethods-Bind,Unbind
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Deletes the selected sub-objects - valid in all Sub-Object levels.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Closes the selected splines - valid in Spline Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Divides the selected segments - valid in Segment Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Displays Detach dialog allowing the user to specify an object name. Valid in all Sub-Object levels.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Explodes the each segment in the selected splines into separate splines or objects. Valid in Spline Sub-Object level.
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
See also related method in ShapeMethods-MaterialID
See Editable Spline Modify Panel Command Modes and Operations for full list of UI-related methods.
Updates the shape's internal caches and viewport display to account for all the changes made by other functions in this kit. This update must be done before 3ds Max or any other code tries to work with a modified shape object.
The updateShape() function makes any scripted changes to a base object spline shape propagate into the bottom of any modifier stack that is present.
Note that there is no check to warn you that modifications such as topology changes might invalidate modifiers already in the stack.
This is equivalent to opening and modifying the base object in a Modify panel, ignoring its warnings about invalidating the object.
Clears all the spline curves out of a shape.
Returns the number of spline curves in the shape as an integer.
Equivalent to <shape>.numSplines .
Rolls the order of the splines in a shape around so that the numbered spline is the first spline in the shape.
This is useful when working with multi-spline shapes in the Lofter and some other modifiers such as Surface Tools which are sensitive to spline order.
Add the splines from one spline shape to the specified bezier shape.
The weld threshold will weld the endpoints of the new splines onto endpoints of existing ones if they are within the distance specified.
Binds the first or end knot of a spline to the midpoint of the specified segment.
A bind acts as a constraint, it constrains the first point or the end point of a spline to the mid point of a segment.
If <isEnd_boolean> is true the end knot of the spline is bound, otherwise the first knot is bound.
<splineId_integer> specifies the index of the spline the first/end knot to bind belongs to, <segIndex_integer> specifies the index of the segment to bind to, and <splineSegId_integer> specifies the index of the spline the bind to segment belongs to.
Unbinds the specified end/first knot of the given spline.
Called when the topology changes to update the bind list, for example when knots are deleted from bound spline or the spline bound to.
Hides the selected splines in the shape.
Hides the selected segments in the shape.
Hides the segments attached to the selected knots in the shape.
Applies controllers to the specified vertices and tangents of the splineshape, where <vertex_spec> is one of:
By assigning controllers to the vertices and tangents, the vertices and tangents are added to the Master subAnim and appear as animatables in the Track View, allowing further scripting of the vertices and tangents.
The vertices to be animated are specified by index number or with the keyword #all to animate all vertices.
See also Class and Object Inspector Functions and Scripting Vertex and Control Point Animation for details on accessing the splineshape vertices and tangents. The controller values assigned to the vertices and tangent handles is in object space. See Using Node Transform Properties for information on converting between world space to object space.
For examples of creating and modifying spline shapes, see also
MAXScript FAQ: How do I create a line between two points?
Adds a new spline curve to the spline shape and returns an integer reflecting the spline index of the newly added spline curve.
Individual spline curves are given index numbers starting at 1.
The addNewSpline() function adds new spline curves to the end of the list of curves in a shape.
Returns the indices of the selected splines in the shape as an array of integers.
Selects the splines specified by <spline_index_array> in the specified shape.
<spline_index_array> is an array of integers specifying the spline indices.
Splines already selected are de-selected unless keep:true is specified.
Deletes the indexed spline curve from the shape.
The remaining curves are renumbered to account for the deletion.
Returns the number of line segments in the indexed spline as an integer.
This is the same as the number of knots for closed splines and 1 less for open splines.
Returns the number of knots (also known vertices or control points) in the indexed spline as an integer.
If the spline index is not specified, returns the number of knots in the entire shape.
Returns true if the indexed spline is closed, false if it is open.
Opens the indexed spline between its last and first knots.
Reverses the order of the knots in the indexed spline.
Rolls the order of the knots in the indexed spline around so that the specified knot becomes the first knot in the spline.
Welds the selected knots in the specified splineShape that are within the specified tolerance.
Available in 3ds Max 2008 and higher.
Previously available in the Avguard Extensions .
getSegLengths <splineShape> <spline_index> [cum:<boolean>] \ [byVertex:<boolean>] [numArcSteps:<integer>]
Returns array of segment lengths or vertex distances by spline fraction and length, and total spline length.
Double precision calculations, very accurate.
If cum:true, results are cumulative, otherwise they are relative.
If byVertex:true results are per vertex, otherwise per segment.
Defaults: cum:false byVertex:false numArcSteps:100
Divides the segment into the specified number of divisions.
Double precision calculations, very accurate.
Returns a <point3> coordinate on the indexed curve.
If pathParam:false, param_float is the fraction of the spline length, otherwise it is a segment-based (path) fraction.
Returns a <point3> tangent on the indexed curve.
If pathParam:false, param_float is the fraction of the spline length, otherwise it is a segment-based (path) fraction.
Returns a point2 value containing the segment and segment fraction for the specified vertex-interpolated spline parameter.
The first and second arguments specify the shape and the spline within the shape to interpolate, the third argument is the parameter to interpolate.
Passing a parameter of 0.5 with a 10 segments spline for example will always return a point2 value containing either [6,0.0] (or very close to 0) or [5,1.0] because the middle of a 10 segments spline using vertex interpolation is always the vertex between the 5 th and the 6 th segment.
See notes below for discussion of interpolation methods.
Available in 3ds Max 2008 and higher. Previously available in the Avguard Extensions.
Returns a point2 value containing the segment and segment fraction for the specified length-interpolated spline parameter.
The first and second arguments specify the shape and the spline within the shape to interpolate, the third argument is the parameter to interpolate.
In contrast to findPathSegAndParam() , this method takes the actual length of the segments into account, normalizing the complete length between 0.0 and 1.0 and then interpolating along the length, so a parameter of 0.5 with a 10 segments spline will always return the segment and parameter within the segment that lies in the exact middle of the spline's length, varying based on the actual segment lengths / vertex distribution within the spline.
Available in 3ds Max 2008 and higher. Previously available in the Avguard Extensions.
VERTEX AND LENGTH INTERPOLATION METHODS: |
There are two methods to interpolate a position along the spline - vertex interpolation and length interpolation. When using vertex interpolation (a.k.a. path interpolation), the spline is seen as a number of segments where each segment between two vertices is as a normalized space from 0.0 to 1.0. The distance between the two vertices of a segment is ignored during the interpolation, which means that if the lengths of the segments are different, interpolating linearly along the spline would result in varying speed. You can visualize this on a Path Constraint with Constant Velocity unchecked where the object is moving faster between two vertices when the segment between them is longer. (see image below) When using length interpolation, the whole spline length is normalized, so a parameter of 0.5 will be exactly in the middle of the spline regardless of the segments' lengths. The speed of a point interpolated along the spline using a parameter that changes linearly between 0.0 and 1.0 will remain constant along the whole spline even if the vertex placement is irregular. This can be demonstrated when checking the Constant Velocity checkbox in the Path Constraint which enables length interpolation: |
On this screenshot, the top object is a SplineShape with varying segment length and ten segments. The middle object is a copy of the same shape used as a path by a Point Helper. The Constant Velocity checkbox was unchecked in the Path Constraint, causing it to use vertex interpolation. For 100 frames, it divided the shape in ten segments and placed ten samples on each segment, resulting in varying speed dependent on the length of the segment. The bottom object is a copy of the same shape used as a path by another Point Helper, but this time Constant Velocity is turned on, causing it to use length interpolation. You can see clearly that the samples are evenly spaces along the full length of the shape, disregarding the distances between the vertices defining the segments. The time slider was set of frame 50 - the length interpolation at the bottom places the point helper exactly at the middle of the path shape, while the vertex interpolation places it exactly on the vertex between the 5 th and the 6 th segment. |
Returns a point3 coordinate for the segment and segment fraction on the indexed curve.
If pathParam:false, param_float is the fraction of the segment length, otherwise it is a segment-based (path) fraction.
Available in 3ds Max 2008 and higher.
Previously available in the Avguard Extensions.
Returns a point3 tangent for the segment and segment fraction on the indexed curve.
If pathParam:false, param_float is the fraction of the segment length, otherwise it is a segment-based (path) fraction.
Available in 3ds Max 2008 and higher.
Previously available in the Avguard Extensions.
For examples of creating and modifying spline shapes, see also
MAXScript FAQ:How do I create a line between two points?
Gets the segment type of the indexed segment in the indexed spline.
Sets the segment type of the indexed segment in the indexed spline.
Adds a new knot to the indexed segment of the indexed curve at a place along the indexed segment corresponding to the given segment interpolation parameter.
This value is a float in the range 0.0 to 1.0 , specifying a proportion along the segment.
The new knot coordinates and in-vector and out-vector are automatically computed to maintain the segment's existing curvature.
This is the primitive used by the refine() function in the Edit Spline modifier.
You can use the MAXScript spline path interpolation functions to derive segment parameters given that a curve's path interpolation parameter is divided evenly among the segments in a curve.
Given a path interpolation parameter u in a spline of m segments, the target segment is:
which can be refactored to the following which will reduce roundoff error in the calculation:
The refineSegment() function returns the index of the newly inserted knot.
Returns the indices of the selected segments in the specified shape spline as an array of integers.
Selects the segments specified by <segment_index_array> in the specified shape spline.
<segment_index_array> is an array of integers specifying the segment indices.
Segments already selected are de-selected unless keep:true is specified.
Sets the material ID of the specified spline segment.
Gets the material ID of the specified spline segment.
For examples of creating and modifying spline shapes, see also
MAXScript FAQ:How do I create a line between two points?
addKnot <shape> <spline_index_integer> \ (#smooth | #corner | #bezier | #bezierCorner) \ (#curve | #line) <position_point3> \ [invec_point3 outvec_point3] \ [where_integer]
Adds a new knot (control point) to the indexed spline and returns an integer reflecting the index of the newly added knot.
The 3 rd argument specifies the type of the knot, the 4 th specifies the type of the segment leaving the knot.
The 5 th specifies the coordinates for the new point (given in the current working coordinate system).
If the knot type is #bezier or #bezierCorner , you must give the in-vector and out-vector handle coordinates as the 6 th and 7 th arguments. In the same way as splines are indexed in a shape, knots are indexed in a spline.
The optional last argument lets you specify where in the knot order the new knot is to be inserted, defaulting to the end of the spline if you leave this argument off.
Deletes the indexed knot in the indexed spline.
The remaining knots are renumbered to account for the deletion.
Returns the knot type of the indexed knot in the indexed spline.
The value is one of the names #smooth , #corner , #bezier , or #bezierCorner .
setKnotType <shape> <spline_index_integer> <knot_index_integer> (#smooth | #corner | #bezier | #bezierCorner)
Sets the knot type of the indexed knot in the indexed spline.
This is equivalent to the right-mouse-button change you can make to spline control-points using the Edit Spline modifier in 3ds Max.
Retrieves the coordinates of the indexed knot as a point3 in the current working coordinate system.
Sets the coordinates of the indexed knot in the indexed spline.
Coordinates are given in the current working coordinate system.
Retrieves the coordinates of the in-vector handle for the indexed knot as a point3 in the current working coordinate system.
Sets the coordinates of the in-vector handle of the indexed knot.
Coordinates are given in the current working coordinate system.
Retrieves the coordinates of the out-vector handle for the indexed knot as a point3 in the current working coordinate system.
Sets the coordinates of the out-vector handle of the indexed knot.
Coordinates are given in the current working coordinate system.
Returns the indices of the selected knots in the specified shape spline as an array of integers.
Selects the knots specified by <knot_index_array> in the specified shape spline. <knot_index_array> is an array of integers specifying the knot indices.
Knots already selected are de-selected unless keep:true is specified.
For examples of creating and modifying spline shapes, see also
MAXScript FAQ:How do I create a line between two points?