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.
All text field functions that evaluate to numbers (e.g., Area, BlockInstanceCount, CurveLength, NumPages, PageNumber, Volume) can be combined in math formulas.
%<2*3>% evaluates to 6.
%<NumPages()-1>% evaluates to 3 if there are 4 layout pages in the model.
Python and .NET string formatting functions are supported.
%<'{:03}'.format(NumPages())>% converts 2 to 002 if there are 2 layout pages in the model.
%<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.
Calculates the area of a closed curve (must be planar), hatch, surface, polysurface, mesh, or SubD.
Use annotation style unit.
%<Area("ObjectID")>%
Specify a unit.
%<Area("ObjectID","Unit")>%
Usertext for a given object / key combination.
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...
Defines Attribute User Text to be included in a block instance.
%<UserText("block","Key","Prompt","Value")>%
Use the Text command to create a text object.
Click the fx button in the Text dialog box.
Select BlockAttributeText on the left.
Enter text strings for Key, Prompt, and Value.
Create a block definition including the Block Attribute Text.
Use the Insert command to add the block into the viewport.
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.
Display the number of blocks of the specified name.
%<BlockInstanceCount("BlockName")>%
Retrieves the name of a block definition by selecting its block instance in viewports.
%<BlockInstanceName("Block Instance ID")>%
Length of a curve.
Use annotation style unit.
%<CurveLength("ObjectID")>%
Specify a unit.
%<CurveLength("ObjectID","Unit")>%
The current date and time.
Select a date and time format from the list.
Select a region from the list. An appropriate language will be selected for the date.
%<Date("Format", "Region")>%
%<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
The date and time this file was last saved.
Select a date and time format from the list.
Select a region from the list. An appropriate language will be selected for the date.
%<DateModified("Format", "Region")>%
%<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
Display a formatted scale value for the selected detail view.
%<DetailScale("DetailID","Format")>%
Noformatting = 0.1
#:1 = 0.1:1
1:# = 1:10
1=# = 1" = 10'
#=1 = 1/8" = 1'
#=1-0 = 1/8" = 1'-0"
References a detail view using the name set in its Object Properties instead of its GUID.
Document user text in the model.
%<DocumentText("Key")>%
Key of the Document User Text to retrieve the value.
Path to the file.
%<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
Returns the name of a selected layer.
%<LayerName("LayerID")>%
Returns a value of a User Text key stored in a layout.
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")>%
Current model unit.
%<ModelUnits()>%
Contents of the Notes.
%<Notes()>%
Number of layout pages in the document.
%<NumPages()>%
Return the layer name of a selected object.
%<ObjectLayer("ObjectID")>%
Display the object or block name if there is one.
%<ObjectName("ObjectID")>%
Height of the layout page that this Text field exists on.
%<PageHeight()>%
Current or selected layout page name.
Display the name of the selected layout page.
Current layout page name.
%<PageName()>%
Selected layout page name.
%<PageName("PageID")>%
Current layout number.
%<PageNumber()>%
%<PageNumber() + OffsetNumber>%
Width of the layout page that this Text field exists on.
%<PageWidth()>%
Name of the selected paper size.
%<PaperName()>%
Displays the World XYZ coordinates of a selected point object.
The XYZ axes can be enabled respectively.
%<PointCoordinate("ObjectID","Axes")>%
Retrieves the volume of an extrusion, surface, polysurface, mesh, or SubD.
Enable to return the volume from an open object.
Use annotation style unit.
%<Volume("ObjectID")>%
Specify a unit.
%<Volume("ObjectID","Unit")>%
Allow open objects.
%<Volume("ObjectID","True")>%
Rhinoceros 7 © 2010-2023 Robert McNeel & Associates. 09-Mar-2023