Could anyone explain to me what is the difference?
taken from here:
https://developer.rhino3d.com/api/RhinoScriptSyntax/#collapse-IsUserText
Could anyone explain to me what is the difference?
taken from here:
https://developer.rhino3d.com/api/RhinoScriptSyntax/#collapse-IsUserText
Attribute User Text is stored on the attributes of an rhinoObject
https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_DocObjects_ObjectAttributes.htm
Geometry user text is stored on the geometry of an rhinoObject
https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_Geometry_GeometryBase.htm
It is generally advised to store user data on the attributes as geometry is more fragile meaning certain commands can destroy or create new geometry for an object effectively deleting your user data stored on it.
when I use rhinoscriptsyntax.SetUserText which one is used? Attribute or Geometry?
This is weird / confusing. Can I have different user texts in Attributes and Geometry?
Nevermind, I see it’s the attributues:
def SetUserText(object_id, key, value=None, attach_to_geometry=False):
"""Sets or removes user text stored on an object.
Parameters:
object_id (str): the object's identifier
key (str): the key name to set
value (str, optional) the string value to set. If omitted, the key/value pair
specified by key will be deleted
attach_to_geometry (bool, optional): location on the object to store the user text
Returns:
bool: True or False indicating success or failure
Example:
import rhinoscriptsyntax as rs
obj = rs.GetObject("Select object")
if obj:
rs.SetUserText( obj, "PartNo", "KM40-4960" )
rs.SetUserText( obj, "Price", "1.25" )
See Also:
GetUserText
IsUserText
"""
obj = rhutil.coercerhinoobject(object_id, True, True)
if type(key) is not str: key = str(key)
if value and type(value) is not str: value = str(value)
if attach_to_geometry: return obj.Geometry.SetUserString(key, value)
return obj.Attributes.SetUserString(key, value)
I wonder, though, when is using the Geometry user text applicable, useful, advisable?
Hi @ivelin.peychev,
Geometry user text is useful if you do not intend to add geometry to Rhino’s document.
But not all types support it.
Those that do, have the “SetUserString” method.
It is attributes, and optionally on geometry too.