Numbers stored in User Text are strings that cannot be calculated as numbers unless they are converted to real numbers by the float() function.
To calculate the weight of an object from its volume and material density, you can:
Use the Volume function to retrieve the volume of the object, like:
%<Volume("ObjectID")>%
Add a "Density" key to the object's Attribute User Text to define the material density that can be retrieved by the AttributeUserText function, like:
%<UserText("ObjectID","Density")>%
Multiply Volume() by UserText().
%<Volume("ObjectID") * UserText("ObjectID", "Density")>%✘
This formula will fail because UserText() returns a string, not a number. To make it work, use float() to convert UserText() from a string to a number, like:
%<Volume("ObjectID") * float(UserText("ObjectID", "Density"))>%✔
Rhinoceros 7 © 2010-2021 Robert McNeel & Associates. 13-juil.-2021