Text fields

Text fields are a feature for text and leaders. Text fields are formulas that are evaluated while Rhino is running and the result is displayed in the text. All text fields are in the syntax of %<field and options>%. When a formula cannot be evaluated an error string of #### is displayed.

Math Support

All text field functions that evaluate to numbers (e.g., Area, BlockInstanceCount, CurveLength, NumPages, PageNumber, Volume) can be combined in math formulas.

For example:

%<2*3>% evaluates to 6.

%<NumPages()-1>% evaluates to 3 if there are 4 layout pages in the model.

String Formatting

Python and .NET string formatting functions are supported.

Examples:
Add leading zeros to a number

%<'{:03}'.format(NumPages())>% converts 2 to 002 if there are 2 layout pages in the model.

Convert letter cases

%<ModelUnits().upper()>% converts model units, e.g., from millimeters to MILLIMETERS.

Case conversion functions in Python and .NET

Python:

upper(), lower(), and capitalize()

.NET:

ToUpper() and ToLower()

There is no direct capitalize function in .NET.

Functions

Area

Calculates the area of a closed curve (must be planar), hatch, surface, polysurface, mesh, or SubD.

Syntax:

Use annotation style unit.

%<Area("ObjectID")>%

Specify a unit.

%<Area("ObjectID","Unit")>%

AttributeUserText

Usertext for a given object / key combination.

Syntax:

%<UserText("ObjectID","Key")>%

Key of the UserText to retrieve the value.

Select Object

Select the object to retrieve Attribute User Text keys.

  • This page provides the same functionalities found in Object Properties > Attribute User Text.

  • Annotation can be self-referenced by "(null)". How to...

  • UserText() returns a string that cannot be used in calculations unless you convert it to a number. How to...

BlockAttributeText

Defines Attribute User Text to be included in a block instance.

Syntax:

%<UserText("block","Key","Prompt","Value")>%

  • Key and value will be the Attribute User Text stored in the block instance.
  • Prompt will display in the dialog box while inserting the block.
  • Value and prompt are optional.

How it works:

  1. Use the Text command to create a text object.

  2. Click the fx button in the Text dialog box.

  3. Select BlockAttributeText on the left.

  4. Enter text strings for Key, Prompt, and Value.

  5. Create a block definition including the Block Attribute Text.

  6. Use the Insert command to add the block into the viewport.

  7. When prompted, enter the value or click the fx button to use another TextField.

In this example, a "Data Table" block definition is created from the table containing block attribute text strings for the name, age, and gender.

The block is then inserted into the viewport below the other two people. The Insert command prompts for entering their information.

Download the sample model...

BlockInstanceCount

Display the number of blocks of the specified name.

Syntax:

%<BlockInstanceCount("BlockName")>%

BlockInstanceName

Retrieves the name of a block definition by selecting its block instance in viewports.

Syntax:

%<BlockInstanceName("Block Instance ID")>%

CurveLength

Length of a curve.

Syntax:

Use annotation style unit.

%<CurveLength("ObjectID")>%

Specify a unit.

%<CurveLength("ObjectID","Unit")>%

Date

The current date and time.

Date format:

Select a date and time format from the list.

Region:

Select a region from the list. An appropriate language will be selected for the date.

Syntax:

%<Date("Format", "Region")>%

Examples:

%<Date("M/d/yyyy", "en-US")>% = 12/17/2020

%<Date("M/d/yyyy h:mm tt", "en-US")>% = 12/17/2020 4:48 PM

%<Date("dddd, MMMM dd, yyyy", "en-US")>% = Thursday, December 17, 2020

DateModified

The date and time this file was last saved.

Date format:

Select a date and time format from the list.

Region:

Select a region from the list. An appropriate language will be selected for the date.

Syntax:

%<DateModified("Format", "Region")>%

Examples:

%<DateModified("M/d/yyyy", "en-US")>% = 12/17/2020

%<DateModified("M/d/yyyy h:mm tt", "en-US")>% = 12/17/2020 4:48 PM

%<DateModified("dddd, MMMM dd, yyyy", "en-US")>% = Thursday, December 17, 2020

DetailScale (For parallel detail views only)

Display a formatted scale value for the selected detail view.

Syntax:

%<DetailScale("DetailID","Format")>%

Format examples

Noformatting = 0.1

#:1 = 0.1:1

1:# = 1:10

1=# = 1" = 10'

#=1 = 1/8" = 1'

#=1-0 = 1/8" = 1'-0"

Use detail attribute name

References a detail view using the name set in its Object Properties instead of its GUID.

DocumentUserText

Document user text in the model.

Syntax:

%<DocumentText("Key")>%

Key of the Document User Text to retrieve the value.

FileName

Path to the file.

Syntax:

%<FileName>%

%<FileName>% - creates the full path to the model

%<FileName("0")>% - creates the full path to the model

%<FileName("1")>% - short file name (includes file extension)

%<FileName("2")>% - full path to model without file extension

%<FileName("3")>% - short file name without extension

The number parameter is a mask to turn on certain features:

1 = short file name

2 = no extension

1+2 = 3 = short file name + no extension

LayerName

Returns the name of a selected layer.

Syntax:

%<LayerName("LayerID")>%

LayoutUserText

Returns a value of a User Text key stored in a layout.

Syntax:

A value of a Layout User Text key in the current layout.

%<LayoutUserText("Key")>%

A value of a Layout User Text key in a specified layout.

%<LayoutUserText("LayoutID","Key")>%

  • This page provides the same functionalities found in Layout Properties > Layout User Text.
ModelUnits

Current model unit.

Syntax:

%<ModelUnits()>%

Notes

Contents of the Notes.

Syntax:

%<Notes()>%

NumPages

Number of layout pages in the document.

Syntax:

%<NumPages()>%

ObjectLayer

Return the layer name of a selected object.

Syntax:

%<ObjectLayer("ObjectID")>%

ObjectName

Display the object or block name if there is one.

Syntax:

%<ObjectName("ObjectID")>%

PageHeight

Height of the layout page that this Text field exists on.

Syntax:

%<PageHeight()>%

PageName

Current or selected layout page name.

Selected page

Display the name of the selected layout page.

Syntax:

Current layout page name.

%<PageName()>%

Selected layout page name.

%<PageName("PageID")>%

PageNumber

Current layout number.

  • The page number can be offset. The offset value can be positive or negative.
Syntax:

%<PageNumber()>%

%<PageNumber() + OffsetNumber>%

PageWidth

Width of the layout page that this Text field exists on.

Syntax:

%<PageWidth()>%

PaperName

Name of the selected paper size.

Syntax:

%<PaperName()>%

PointCoordinate

Displays the World XYZ coordinates of a selected point object.

The XYZ axes can be enabled respectively.

Syntax:

%<PointCoordinate("ObjectID","Axes")>%

Volume

Retrieves the volume of an extrusion, surface, polysurface, mesh, or SubD.

Allow open objects

Enable to return the volume from an open object.

Syntax:

Use annotation style unit.

%<Volume("ObjectID")>%

Specify a unit.

%<Volume("ObjectID","Unit")>%

Allow open objects.

%<Volume("ObjectID","True")>%

  • True (or 1) returns the volume from an open object. False (or 0) returns 0 if an open object is selected.