TextPlus : GeometryClass

TextPlus – superclass: GeometryClass; super-superclass:node – classID: #(1815478437, 291720888)

Constructor

TextPlus()

TextPlus : GeometryClass

Properties

Interpolation Properties

<TextPlus>.interpolationsteps     Integer    default: 5   --  integer

The number of interpolation steps for font smoothing.

<TextPlus>.optimize     Integer    default: 1   --  integer

The interpolation optimization setting. 1=on, 0=off.

<TextPlus>.adaptive     Integer    default: 0   --  integer

The interpolation adaptive setting. 1=on, 0=off.

Layout Properties

<TextPlus>.layouttype     Integer    default: 0   --  integer

The layout type. 0=Point, 1=Region

<TextPlus>.plane     Integer    default: 0   --  integer

The layout plane, when layouttype is Point. 0=Auto, 1=XY, 2=XZ, 3=YZ

<TextPlus>.length     Float    default: 100.0   --  animatable; float

The layout region length.

<TextPlus>.width     Float    default: 100.0   --  animatable; float

The layout region width.

Font Properties

<TextPlus>.alignment     Integer    default: 1   --  integer

The font alignment, where:

<TextPlus>.size     Float    default: 25.0   --  animatable; float

The font size.

<TextPlus>.tracking     Float    default: 0.0   --  animatable; float

The font tracking value.

<TextPlus>.leading     Float    default: 0.0   --  animatable; float

The font leading value.

<TextPlus>.vscale     Float    default: 100.0   --  animatable; float

The font Vertical Scale value, as a percent.

<TextPlus>.hscale     Float    default: 100.0   --  animatable; float

The font Horizontal Scale value, as a percent.

Character Settings

<TextPlus>.elementType     Integer    default: 0   --  integer

The type of elements that the text will be split into for animation presets, where:

<TextPlus>.charKerningOffset     ArrayParameter    default: #()   --  float array; SubAnim

An array of kerning offset values for each character in the text string.

<TextPlus>.charBaselineOffset     ArrayParameter    default: #()   --  float array; SubAnim

An array of baseline offset values for each character in the text string.

<TextPlus>.charXScale     ArrayParameter    default: #()   --  float array; SubAnim

An array of X scale values for each character in the text string.

<TextPlus>.charYScale     ArrayParameter    default: #()   --  float array; SubAnim

An array of Y scale values for each character in the text string.

Geometry Settings

<TextPlus>.generateGeometry     Integer    default: 1   --  integer

The Generate Geometry setting, 0=off, 1=on.

<TextPlus>.extrudeamount     Float    default: 0.0   --  animatable; float

The extrude amount, which can be positive or negative. The default is 0.

<TextPlus>.extrudesegments     Integer    default: 1   --  animatable; integer

The number of segments making up the extrusion. From front to back, the extruded characters will be divided by this number of segments.

<TextPlus>.applybevel     BooleanClass    default: false   --  boolean

Indicates whether a bevel is applied to the text.

<TextPlus>.beveldepth     Float    default: 0.5   --  animatable; float

The depth of the bevel.

<TextPlus>.usebevelwidth     BooleanClass    default: false   --  boolean; UseBevelDepth

Indicates whether the .bevelwidth setting is applied.

<TextPlus>.bevelwidth     Float    default: 0.5   --  animatable; float

The bevel width – only applied if .usebevelwidth is true.

<TextPlus>.bevelsteps     Integer    default: 5   --  animatable; integer

The number of steps in the bevel. This determines the number of subdivisions per Bezier segment of the bevel profile curve.

<TextPlus>.bevelpush     Float    default: 1.0   --  animatable; float

The Bevel Push value. This is a scaling factor applied to the bevel profile curve, perpendicular to the bevel. A value of 1.0 gives the original bevel curve. A value of -1.0 gives an inverted bevel curve. A value of 0 always results in a straight bevel.

<TextPlus>.beveloptimize     BooleanClass    default: true   --  boolean

Indicates whether the bevel is optimized. When optimized, linear segments in the bevel profile curve will be reduced to a single edge, disregarding the .bevelsteps parameter.

<TextPlus>.beveloffset     Float    default: 0.0   --  animatable; float

The Outline Offset setting. May be a positive or negative value.

Bevel Cap Settings

<TextPlus>.capstart     Integer    default: 2   --  integer
<TextPlus>.capend     Integer    default: 0   --  integer

The capping setting for the start (top) and end (bottom) of the beveled text:

<TextPlus>.capendconstrain     BooleanClass    default: false   --  boolean
<TextPlus>.capstartconstrain     BooleanClass    default: false   --  boolean

The cap constrain setting for the start (top) and end (bottom) of the beveled text.

<TextPlus>.captype     Integer    default: 0   --  integer

The Cap Type setting:

<TextPlus>.startcapmaterial     Integer    default: 1   --  animatable; integer
<TextPlus>.startbevelmaterial     Integer    default: 3   --  animatable; integer
<TextPlus>.sidematerial     Integer    default: 2   --  animatable; integer
<TextPlus>.endbevelmaterial     Integer    default: 3   --  animatable; integer
<TextPlus>.endcapmaterial     Integer    default: 1   --  animatable; integer

The ID of the material associated with the Start Cap, Start Bevel, Sides, End Bevel, and End Cap, respectively.

<TextPlus>.upaxis     Integer    default: 1   --  integer

The "Up" axis setting, where:

<TextPlus>.axisflip     BooleanClass    default: false   --  boolean

Indicates whether the axis is flipped.

TextPlus.BevelProfileCurve - superclass: ReferenceMaker; 
    super-superclass:MAXWrapper - 0:0 - classID: #(1062418346L, 781088409L); creatable: false

The bevel profile curve, an object of type ReferenceTarget:BevelProfileCurve. Note that this type is not currently exposed in MaxScript.

Value As Text Properties

TextPlus.macroname : string array 

Gets or sets the names of macros (expression or script controllers) in the text string. This value is an array of macro names, in the order they appear in the text string.

TextPlus.macrovalue : float array 

Gets or sets the macro value at the specified index (or all values if no index is specified). For number macros, this provides direct access to the macro value. For Script and Expression controllers, you can use this property to access the underlying controller object to manipulate its script, expression, or other properties. For example:

ctrl = myTextPlus.macroValue[2].controller
--> Controller:Float_Script

Miscellaneous Properties

TextPlus.nodeElements : node array           
TextPlus.nodeElementsCenters : point3 array           

Methods

Methods are exposed via Interface: textObject2

TextPlus : GeometryClass

TextPlus : GeometryClass

TextPlus : GeometryClass

TextPlus : GeometryClass

TextPlus : GeometryClass

TextPlus : GeometryClass

String Content Methods

<void>GetRTFString <&string>rtfstring
       rtfstring is Out parameter

Returns the object string in RTF format.

<boolean>SetRTFString <string>string

Sets the object string as an RTF formatted string. This method clears all formatting settings, equivalent to calling ResetStyle().

<void>GetPlaintextString <&string>textstring
       textstring is Out parameter

Gets the object string as a plain text string without formatting.

<boolean>SetPlaintextString <string>string

Sets the object string as a plain text string without formatting. This method clears all formatting settings, equivalent to calling ResetStyle().

<void>ResetString()

Resets the object string to an empty string.

Formatting methods

These methods affect the current text formatting settings. Calling them does not affect the formatting of text already in the TextPlus object’s text string, they affect text added subsequently using AppendString(). Calling SetPlaintextString() or SetRTFString() resets all formatting settings.

See the Code Sample section below for an illustration of these methods being used to create and format a string.

<boolean>SetFont <string>fontName <integer>charset          

Sets the current font selection and character set index.

<void>SetBold <boolean>sw          
<void>SetItalic <boolean>sw
<void>SetUnderline <boolean>sw
<void>SetStrikethrough <boolean>sw
<void>SetSubscript <boolean>sw
<void>SetSuperscript <boolean>sw
<void>SetAllCaps <boolean>sw
<void>SetSmallCaps <boolean>sw                              

These methods all set text formatting options, where true=on and false=off.

<void>ResetStyle()           

Resets all text formatting settings to their defaults.

<void>AppendString <string>string          

Appends the specified string to the TextPlus object’s string. The appended string takes the current text formatting.

<void>AppendChar <integer>character          

Appends the character, specified by ASCII code, to the TextPlus object’s string. Note that this method will add a newline when the string source is RTF.

Animation Methods

<boolean>SetCharBaseline <index>index <time>time <worldUnits>value
<boolean>SetCharKerning <index>index <time>time <worldUnits>value
<boolean>SetCharXScale <index>index <time>time <float>value
<boolean>SetCharYScale <index>index <time>time <float>value

These methods set animatable values for the character specified by index to the specified value, at the specified time. Note that you must set Animate to On before using these methods.

<integer>GetNumChars()

Returns the number of characters in the TextPlus string.

<boolean>GetCharacter <index>index <&integer>character <&string>fontName <&integer>charSet <&integer>style
       character is Out parameter
       fontName is Out parameter
       charSet is Out parameter
       style is Out parameter

Gets formatting information for the character at the specified index.

<boolean>SetCharacter <index>index <integer>character <string>fontName <integer>charSet \
  <integer>style

Sets the character (specified by ASCII code), font, character set, and style for the character at the specified index.

Style is a bitflag and can be:

<index>GetSeparationType()
<boolean>SetSeparationType <index>type

Gets or sets the Animation Separate setting:

<boolean>SetSeparationUpAxis <index>axis <boolean>flip
<void>GetSeparationUpAxis <&index>axis <&boolean>flip
       axis is In and Out parameter
       flip is In and Out parameter

Gets or sets the Animation "Up" Axis and Flip Axis settings:

Character Setting Animation Methods

<boolean>GetCharBaseline <index>index <time>time <&worldUnits>value <&interval>valid 
<boolean>GetCharKerning <index>index <time>time <&worldUnits>value <&interval>valid
<boolean>GetCharXScale <index>index <time>time <&float>value <&interval>valid
<boolean>GetCharYScale <index>index <time>time <&float>value <&interval>valid
       value is Out parameter
       valid is In and Out parameter

These methods get baseline, kerning, X and Y scale values for the character at the specified index and time. These methods also return a validity interval for the value.

Character Mesh Methods

<boolean>GetCharGlyphMesh <index>index <time>time <&mesh>mesh <&interval>valid
<boolean>GetCharExtrasMesh <index>index <time>time <&mesh>mesh <&interval>valid
<boolean>GetCharTotalMesh <index>index <time>time <&mesh>mesh <&interval>valid
       mesh is In and Out parameter
       valid is In and Out parameter

These methods get the Mesh objects associated with the character at the specified index and time. These methods return the mesh (as a trimesh object) and validity interval.

These methods expose the Set Value As Text functionality of the TextPlus UI, which allows you to create macros (script or expression controllers) that insert calculated values into your TextPlus string. Macros are formatted as %\[macro_name\] in the string.

<boolean>SetValueAsText <index>pos <string>name <enum>type <enum>format <integer>whole \
    <integer>decimal <boolean>uniform
       type enums: {#Script|#Expression|#Number}
       format enums: {#Whole|#Real|#Percent|#DisplayUnits|#Time}

Creates a new macro and inserts it at the current cursor position in the TextPlus text, corresponding to the Set Value As Text button on the TextPlus UI. Available in 3ds Max 2020.2 Update and higher.

The pos argument is a cursor index for the string, from 0 to len(string). -1 is a special index that inserts at the end of the string.

The name argument specifies the name of the new macro.

The type argument specifies the macro type (script, expression, or number).

The format argument specifies the macro format.

The whole argument sets the number of whole number digits displayed, corresponding to the Whole setting on the Edit Value As Text dialog.

The decimal argument sets the number of decimal digits displayed, corresponding to the Decimals setting on the Edit Value As Text dialog.

The uniform argument specifies whether to use a uniform digit width, corresponding to the Use Uniform Digit Width setting on the Edit Value As Text dialog.

<index>GetCursorPos()          

Gets the current cursor position in the text string, where 1 is the start of the string, and 0 indicates there is a text selection. This is indicated by the caret position in the text edit field in TextPlus UI (both the small Text field and the larger Enter Text dialog). Available in 3ds Max 2020.2 Update and higher.

<boolean>SetCursorPos <index>pos          

Sets the current cursor position in the text string to the specified index, where -1 indicates the end of the string. Available in 3ds Max 2020.2 Update and higher.

<void>GetFinalString <time>time <&string>textstring
           textstring is Out parameter          

Evaluates the displayed TextPlus string from its text input by converting all macros to values, for the specified time, and returns the result in the passed by reference textstring parameter. Available in 3ds Max 2020.2 Update and higher.

<index>GetMacroIndex <string>name          

Gets the position (as an index) of the macro specified by name in the TextPlus text string, or -1 if the named macro does not exist. This corresponds to the macro entry index in the TextPlus.macroname property. Available in 3ds Max 2020.2 Update and higher.

<enum>GetMacroFormat <string>name
           GetMacroFormat enums: {#Whole|#Real|#Percent|#DisplayUnits|#Time
<boolean>SetMacroFormat <string>name <enum>format
           format enums: {#Whole|#Real|#Percent|#DisplayUnits|#Time}

Gets or sets the format setting for the specified macro value, or -1 if the macro does not exist. This corresponds to the settings available in the Display As dropdown. Available in 3ds Max 2020.2 Update and higher.

<integer>GetMacroNumWhole <string>name          
<boolean>SetMacroNumWhole <string>name <integer>whole          

Gets or sets the Whole display setting for the specified macro. Available in 3ds Max 2020.2 Update and higher.

<integer>GetMacroNumDecimal <string>name        
<boolean>SetMacroNumDecimal <string>name <integer>decimal        

Gets or sets the Decimal display setting for the specified macro. Available in 3ds Max 2020.2 Update and higher.

<boolean>GetMacroUniformWidth <string>name          
<boolean>SetMacroUniformWidth <string>name <boolean>uniform         

Gets or sets the Use Uniform Digit Width setting for the specified macro. Available in 3ds Max 2020.2 Update and higher.

Examples

The following code sample constructs a TextPlus object, creates a formatted string, and animates individual characters.

--Simple text construction and Animation with TextPlus


actionMan.executeAction 0 "40005" -- Reset

TextPlus layouttype:0  Plane:0 transform:(matrix3 [1,0,0] [0,0,1] [0,-1,0] [0,0,0]) isSelected:on
$.ResetString()
-- Default font is Arial but you can set whatever
$.SetFont "Arial" 0
$.ResetStyle()
$.AppendString "My "
$.SetBold true
$.SetItalic true
$.AppendString "Text "
$.ResetStyle()
$.SetFont "Tahoma" 0
$.SetUnderline true
$.AppendString "String"
$.SetUnderline false
$.AppendChar 32    -- space
$.AppendChar 33 -- Exclamation

-- Now let's do some simple animation

set animate on

--M
$.SetCharBaseline 1 10 -40
$.SetCharBaseline 1 20 40
$.SetCharBaseline 1 30 -40
$.SetCharBaseline 1 40 0

--y
$.SetCharBaseline 2 10 40
$.SetCharBaseline 2 20 -40
$.SetCharBaseline 2 30 40
$.SetCharBaseline 2 40 0

--T
$.SetCharBaseline 4 10 0
$.SetCharBaseline 4 20 40
$.SetCharBaseline 4 30 -40
$.SetCharBaseline 4 40 40
$.SetCharBaseline 4 50 0

--e
$.SetCharBaseline 5 10 0
$.SetCharBaseline 5 20 -40
$.SetCharBaseline 5 30 40
$.SetCharBaseline 5 40 -40
$.SetCharBaseline 5 50 0

--!
$.SetCharYScale 16 10 1
$.SetCharYScale 16 20 3
$.SetCharYScale 16 30 -3
$.SetCharYScale 16 40 3
$.SetCharYScale 16 50 1

set animate off

This example creates a new TextPlus object, and sets some macros (equivalent to using the Set Value As Text functionality in the UI):

resetMaxFile #noprompt

myTextPlus = TextPlus layouttype:0 plane:1 extrudeAmount:1.3
myTextPlus.SetPlainTextString "Number Macro: "

-- create a new number macro and animate it
myTextPlus.SetValueAsText -1 "myNumber" #Number #percent 2 0 false
idx = myTextPlus.getMacroIndex "myNumber"
set animate on
    at time 0
        myTextPlus.macroValue[idx]=100
    at time 100
        myTextPlus.macroValue[idx]=1
set animate off

-- create a new script macro
myTextPlus.GetPlaintextString &curstr
myTextPlus.SetPlainTextString (curstr + "\nScript Macro: ")
myTextPlus.SetValueAsText -1 "script1" #Script #whole 2 2 false
macroIndex = myTextPlus.getMacroIndex "script1"
controller = myTextPlus.macroValue[macroIndex].controller
controller.script = "T*F"

-- create a new expression macro    
myTextPlus.GetPlaintextString &curstr
myTextPlus.SetPlainTextString (curstr + "\nExpression Macro: ")
myTextPlus.SetValueAsText -1 "expr1" #Expression #real 2 2 false
macroIndex = myTextPlus.getMacroIndex "expr1"
controller = myTextPlus.macroValue[macroIndex].controller
controller.SetExpression "S*pi"
myTextPlus.SetMacroNumDecimal "expr1" 2