User Data

The Rhino SDK allows plug-in developers to store custom data inside of Rhino's 3DM file.  This data is referred to as User Data.  There are two types of user data:

  1. Document user data - custom data that is stored at the document level of the 3DM file.

  2. Object user data - custom data that is attached to either an object's geometry or an object's attributes.

Important: When storing custom data on an object, the data can be stored on either the object's geometry (e.g. curve, surfaces, etc), or on the object's attributes. An object's attributes maintain it's layer, color and other non-geometric properties. The difference between the two storage methods is that adding or modifying user data that is located on an object's geometry will cause Rhino to place a copy of the object on the Undo stack. Thus, if you are working with large geometric object or lots of user data, it is more efficient to store object user data on an object's attributes.

User Text

Rhino provides a standardized mechanism for users, script writers, and plug-in developers to store and retrieve simple text information on an object and in the document. This mechanism called User Text.  Rhino stores User Text key/value pairs.

User text can be set and retrieved on both objects, and their attributes, and the document using:

Note, user text works on both Rhino for Windows and Rhino for Mac. So it is ideal for cross platform development.

User Text Methods

RhinoScript supports this mechanism with the GetUserText, SetUserText, GetDocumentUserText, and SetDocumentUserText methods.

User text can be stored on layers by using the GetLayerUserText and SetLayerUserText methods.

 User text can be stored on groups using the GetGroupUserText and SetGroupUserText methods.

Runtime User Data

When you declare a variable within a procedure, the variable can only be accessed within that procedure. When the procedure exits, the variable is destroyed. These variables are called local variables.

If you declare a variable outside a procedure, all procedures can access it. These variables are called global variables. The lifetime of these variables starts when they are declared, and ends when Rhino is closed. Note, if the Reinitialize script engine when opening new models option is enabled, all variables and procedures are destroyed when a new model is opened.

RhinoScript maintains a runtime data dictionary that you can use to store data. Runtime data is similar to global variables in that it can be accessed from all procedures. But unlike global variables, the runtime data will not be destroyed if the script engine is re-initialized. Runtime data persists until Rhino is closed.

Runtime data can be stored and retrieved using the GetRuntimeData and SetRuntimeData methods.

Legacy User Data

RhinoScript has it's own, legacy, user data format. This feature is considered obsolete because the only technology that can read and write this type of data is RhinoScript. It is provided only for backwards compatibility with older scripts.

User Data Methods

Method

Description

AttributeDataCount

(Obsolete) Returns the number of RhinoScript user data items stored on an object's attributes.

DeleteAttributeData

(Obsolete) Removes RhinoScript user data stored on an object's attributes.

DeleteDocumentData

(Obsolete) Removes RhinoScript user data stored in the current document.

DeleteObjectData

(Obsolete) Removes RhinoScript user data stored on an object's geometry.

DocumentDataCount

(Obsolete) Returns the number of RhinoScript user data items stored in the current document.

GetAttributeData

(Obsolete) Returns a RhinoScript user data item stored on an object's attributes.

GetDocumentData

(Obsolete) Returns a RhinoScript user data item stored in the current document.

GetDocumentUserText

Returns user text that is stored in the document.

GetGroupUserText

Returns user text that is stored on a group.

GetLayerUserText

Returns user text that is stored on a layer.

GetObjectData

(Obsolete) Returns a RhinoScript user data item stored on an object's geometry.

GetRuntimeData

Returns data from RhinoScript's runtime data dictionary.

GetUserText

Returns user text that is stored on an object.

IsAttributeData

(Obsolete) Verifies that an object's attributes contains RhinoScript user data.

IsDocumentData

(Obsolete) Verifies that the current document contains RhinoScript user data.

IsDocumentUserText

Verifies that the document contains user text.

IsObjectData

(Obsolete) Verifies that an object's geometry contains RhinoScript user data.

IsUserText

Verifies that an object contains user text.

ObjectDataCount

(Obsolete) Returns the number of RhinoScript user data items stored on an object's geometry.

RuntimeDataCount

Returns the number of key/value pairs in RhinoScript's runtime data dictionary.

SetAttributeData

(Obsolete) Sets or removes a RhinoScript user data item stored on an object's attributes.

SetDocumentData

(Obsolete) Sets or removes a RhinoScript user data item stored in the current document.

SetDocumentUserText

Sets or removes user text stored in the document.

SetGroupUserText

Sets or removes user text stored on a group.

SetLayerUserText

Sets or removes user text stored on a layer.

SetObjectData

(Obsolete) Sets or removes a RhinoScript user data item stored on an object's geometry.

SetRuntimeData

Sets or removes data from RhinoScript's runtime data dictionary.

SetUserText

Sets or removes user text stored on an object.