splineShape - superclass: Shape; super-superclass:Node - classID: #(10, 0)
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, adding individual curves and controls points or you can modify an existing shape by converting it to a SplineShape and using the methods listed below.
See also
Shape Common Properties, Operators, and Methods
Spline Shape Common Properties, Operators, and Methods
Node Common Properties, Operators, and Methods
MAXWrapper Common Properties, Operators, and Methods
Value Common Properties, Operators, and Methods
Class and Object Inspector Functions
Scripting Vertex and Control Point Animation
Notes
You must convert existing shapes to SplineShapes in order to operate on them with the these methods. 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.
Properties
<splineshape>.steps Integer default: 6 -- integer
Controls the Interpolation Steps in the Interpolation rollout.
<splineshape>.optimize Boolean default: true -- boolean
Controls the state of the Optimize checkbox in the Interpolation rollout.
<splineshape>.adaptive Boolean default: false -- boolean
Controls the state of the Adaptive checkbox in the Interpolation rollout.
<SplineShape>.render_renderable BooleanClass default: false -- boolean; renderable
Toggles the "Enable in Renderer" checkbox on and off. Available in 3ds Max 8 and higher.
Replaces the previously available .renderable property which used to collide with the node-level .renderable property. While the alias is still available for compatibility reasons, it is advisable to use the new name in new scripts.
<SplineShape>.render_displayRenderMesh BooleanClass default: false -- boolean; displayRenderMesh
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.
Replaces the previously available .displayRenderMesh property, provides an alias for backwards compatibility.
<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.
Replaces the previously available .useViewportSettings property, provides an alias for backwards compatibility.
<SplineShape>.render_mapcoords BooleanClass default: false -- boolean; mapcoords
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.
Replaces the previously available .mapcoords property, provides an alias for backwards compatibility.
<SplineShape>.realWorldMapSize BooleanClass default: false -- boolean
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.
Replaces the previously available .displayRenderSettings property, provides an alias for backwards compatibility.
<SplineShape>.render_rectangular BooleanClass default: false -- boolean
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.
<SplineShape>.render_viewport_rectangular BooleanClass default: false -- boolean
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.
<SplineShape>.render_thickness Float default: 1.0 -- animatable; thickness
Get/Set the diameter of the Radial renderable spline mesh. Available in 3ds Max 8 and higher.
Replaces the previously available .thickness property, provides an alias for backwards compatibility.
<SplineShape>.render_sides Integer default: 12 -- animatable; sides
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.
Replaces the previously available .sides property, provides an alias for backwards compatibility.
<SplineShape>.render_angle Float default: 0.0 -- animatable; angle
Get/Set the rotational position of the Radial cross-section in the renderer. Available in 3ds Max 8 and higher.
Replaces the previously available .angle property, provides an alias for backwards compatibility.
<SplineShape>.render_length Float default: 6.0 -- animatable
Get/Set the length of the Rectangular renderable spline mesh. Available in 3ds Max 8 and higher.
<SplineShape>.render_width Float default: 2.0 -- animatable
Get/Set the width of the Rectangular renderable spline mesh. Available in 3ds Max 8 and higher.
<SplineShape>.render_angle2 Float default: 0.0 -- animatable
Get/Set rotational position of the Radial cross-section in the renderer. Available in 3ds Max 8 and higher.
<SplineShape>.render_aspect_locked BooleanClass default: false -- boolean
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. Available in 3ds Max 8 and higher.
<SplineShape>.render_viewport_thickness Float default: 1.0 -- float; viewport_thickness
Get/Set the diameter of the Radial renderable spline mesh in the viewport. Available in 3ds Max 8 and higher.
Replaces the previously available .viewport_thickness property, provides an alias for backwards compatibility.
<SplineShape>.render_viewport_sides Integer default: 12 -- integer; viewport_sides
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.
Replaces the previously available .viewport_sides property, provides an alias for backwards compatibility.
<SplineShape>.render_viewport_angle Float default: 0.0 -- float; viewport_angle
Gets/Sets the rotational position of the cross-section in the viewports. Available in 3ds Max 8 and higher.
Replaces the previously available .viewport_angle property, provides an alias for backwards compatibility.
<SplineShape>.render_viewport_length Float default: 6.0 -- float
Get/Set the length of the Rectangular spline mesh in the viewports. Available in 3ds Max 8 and higher.
<SplineShape>.render_viewport_width Float default: 2.0 -- float
Get/Set the width of the Rectangular spline mesh in the viewports. Available in 3ds Max 8 and higher.
<SplineShape>.render_viewport_angle2 Float default: 0.0 -- float
Get/Set rotational position of the Rectangular cross-section in the viewports. Available in 3ds Max 8 and higher.
<SplineShape>.render_viewport_aspect_locked BooleanClass default: false -- boolean
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. Available in 3ds Max 8 and higher.
<SplineShape>.render_auto_smooth BooleanClass default: true -- boolean
Controls the state of the Auto Smooth checkbox. When set to true, auto smoothing will be enabled. Available in 3ds Max 8 and higher.
<SplineShape>.render_threshold Float default: 40.0 -- animatable;
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
Methods
updateShape <shape>
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.
resetShape <shape>
Clears all the spline curves out of a shape
numSplines <shape>
Returns the number of spline curves in the shape as an integer. Equivalent to <shape>.numSplines.
setFirstSpline <shape> <spline_index_integer>
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.
hideselectedsplines <shape>
Hides the selected splines in the shape.
hideselectedsegments <shape>
Hides the selected segments in the shape.
hideselectedverts <shape>
Hides the segments attached to the selected knots in the shape.
unhidesegments <shape>
Unhides all segments in the shape.
addAndWeld <to_shape> <from_shape> <weldthreshold_float>
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.
bindKnot <shape> <isEnd_boolean> <splineId_integer> \
<segIndex_integer> <splineSegId_integer>
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.
unBindKnot <shape> <spline_index_integer> <isEnd_boolean>
Unbinds the specified end/first knot of the given spline
updateBindList <shape>
Called when the topology changes to update the bind list, for example when knots are deleted from bound spline or the spline bound to.
materialID <shape> <spline_index_integer> <segment_index_integer>
Returns the material id for the given segment of the given shape object.
animateVertex <shape> <vertex_spec>
Applies controllers to the specified vertices and tangents of the splineshape, where <vertex_spec> is one of:
<integer_index>
<integer_index_array>
#all
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.
For example,
animateVertex $Circle01 #all
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.
addNewSpline <shape>
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.
getSplineSelection <shape>
Returns the indices of the selected splines in the shape as an array of integers.
setSplineSelection <shape> <spline_index_array> [ keep:<boolean> ]
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.
deleteSpline <shape> <spline_index_integer>
Deletes the indexed spline curve from the shape. The remaining curves are renumbered to account for the deletion.
numSegments <shape> <spline_index_integer>
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.
numKnots <shape> [ <spline_index_integer> ]
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.
isClosed <shape> <spline_index_integer>
returns true if the indexed spline is closed, false if it is open.
close <shape> <spline_index_integer>
closes the indexed spline.
open <shape> <spline_index_integer>
opens the indexed spline between its last and first knots.
reverse <shape> <spline_index_integer>
reverses the order of the knots in the indexed spline.
setFirstKnot <shape> <spline_index_integer> <knot_index_integer>
rolls the order of the knots in the indexed spline around so that the specified knot becomes the first knot in the spline.
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
subdivideSegment <splineShape> <spline_index> <seg_index> <divisions>
Divides the segment into the specified number of divisions. Double precision calculations, very accurate.
interpCurve3D <splineShape> <spline_index> <param_float> [pathParam:<boolean>]
Returns a <point3> coordinate on the indexed curve. If pathParam:false, param is the fraction of the spline length, otherwise it is a segment-based (path) fraction. Default is pathParam:false
tangentCurve3D <splineShape> <spline_index> <param_float> [pathParam:<boolean>]
Returns a <point3> tangent on the indexed curve. If pathParam:false, param is the fraction of the spline length, otherwise it is a segment-based (path) fraction. Default is pathParam:false
getSegmentType <shape> <spline_index_integer> <seg_index_integer>
Gets the segment type of the indexed segment in the indexed spline
setSegmentType <shape> <spline_index_integer> \
<seg_index_integer> \
( #curve | #line )
Sets the segment type of the indexed segment in the indexed spline
refineSegment <shape> <spline_index_integer> \
<seg_index_integer> \
<seg_interp_param_float>
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:
n = (m*u) as integer + 1
and the segment parameter is:
f = (u-(n-1)/m)*m
which can be refactored to the following which will reduce roundoff error in the calculation:
f = u*m-n+1
The refineSegment() function returns the index of the newly inserted knot.
getSegSelection <shape> <spline_index_integer>
Returns the indices of the selected segments in the specified shape spline as an array of integers.
setSegSelection <shape> <spline_index_integer> \
<segment_index_array> \
[ keep: <boolean> ]
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.
setMaterialID <splineShape> <spline_index> <seg_index> <matID>
Sets the material ID of the specified spline segment.
getMaterialID <splineShape> <spline_index> <seg_index>
Gets the material ID of the specified spline segment.
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.
deleteKnot <shape> <spline_index_integer> <knot_index_integer>
Deletes the indexed knot in the indexed spline. The remaining knots are renumbered to account for the deletion.
getKnotType <shape> <spline_index_integer> <knot_index_integer>
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.
getKnotPoint <shape> <spline_index_integer> <knot_index_integer>
Retrieves the coordinates of the indexed knot as a point3 in the current working coordinate system.
setKnotPoint <shape> <spline_index_integer> <knot_index_integer> <point3>
Sets the coordinates of the indexed knot in the indexed spline. Coordinates are given in the current working coordinate system.
getInVec <shape> <spline_index_integer> <knot_index_integer>
Retrieves the coordinates of the in-vector handle for the indexed knot as a point3 in the current working coordinate system.
setInVec <shape> <spline_index_integer> <knot_index_integer> <point3>
Sets the coordinates of the in-vector handle of the indexed knot. Coordinates are given in the current working coordinate system.
getOutVec <shape> <spline_index_integer> <knot_index_integer>
Retrieves the coordinates of the out-vector handle for the indexed knot as a point3 in the current working coordinate system.
setOutVec <shape> <spline_index_integer> <knot_index_integer> <point3>
Sets the coordinates of the out-vector handle of the indexed knot. Coordinates are given in the current working coordinate system.
getKnotSelection <shape> <spline_index_integer>
Returns the indices of the selected knots in the specified shape spline as an array of integers.
setKnotSelection <shape> <spline_index_integer> <knot_index_array> [keep: <boolean> ]
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.
See also
Editable Spline Modify Panel Command Modes and Operations
How To ... Flatten a SplineShape
How To ... Draw a Freehand Spline