Hi @devang, thanks! Thats so nice of you to say - appreciate it. I’m embarrassed to say I still default to excel for charts like that one. Don’t tell anyone though.
And thats a great Human tool, I’d never noticed that object reader part of it before. Super useful. As far as the simplified code here @andrea.botti, it should work with Meshes I think? It should be able to read any object’s UserText or object name from the Rhino scene. I have a new version attached here that does, as @Erikbeeren points out, use the Attribute UserText now available in Rhino 6 along with the name. Maybe try that and see if it works better for you?
The code to do this is very simple: you just switch over to the Rhino doc, grab the data using rs.ObjectName() and rs.GetUserTetxt(), then switch back to the GH doc. Can be added to any component you might be building I’d think:
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
from System import Object
from Grasshopper import DataTree
from Grasshopper.Kernel.Data import GH_Path
import Grasshopper.Kernel as ghK
sc.doc = Rhino.RhinoDoc.ActiveDoc # Switch over to the Rhino Doc
if len(_obj)>0:
names_ = DataTree[Object]()
params_ = DataTree[Object]()
for i in range(len(_obj)):
# Get the Object Name
try:
names_.Add(rs.ObjectName(_obj[i]) , GH_Path(i))
except:
msg = 'Something went wrong getting the Name'
ghenv.Component.AddRuntimeMessage(ghK.GH_RuntimeMessageLevel.Warning, msg)
names_.Add('Error', GH_Path(i))
# Get the Object Attributes
windowDataFromRhino = {} # Temp dict to store the data
try:
if rs.IsUserText(_obj[i]):
for eachKey in rs.GetUserText(_obj[i]):
windowDataFromRhino[eachKey] = rs.GetUserText(_obj[i], eachKey)
except:
msg = 'Something went wrong getting the Object Params (UserText)'
ghenv.Component.AddRuntimeMessage(ghK.GH_RuntimeMessageLevel.Warning, msg)
# Add the Object Params to an output list
params_.AddRange(list(windowDataFromRhino.items()), GH_Path(i))
sc.doc = ghdoc # Switch back to the Grasshopper Doc
The component can either be set up to take in a GUID directly (set the input’s type-hint to GUID - only available in Rhino 6 though I think…) or just use an ‘ID’ component to input the GUID of the objects in your Rhino scene and set the type-hint to ‘none’ on the component’s input.
For whatever its worth, we’ve been building this functionality into a lot of our custom components/workflows in order to host more and more data back in the Rhino objects rather that in the GH doc. I know you can’t then easily modify it in GH for things like variant analysis, but for lots of the types of things we’re up to it just makes the GH doc a lot cleaner and seems easier for us to manage all the data that way. Certainly not the best answer for everything, but I think it is a useful tool to have available. You can build in all sorts of param assigners to auto-populate and create standardized attributes:
anyway, hope that is useful. Give me a holler if its still giving you errors though? Happy to take a look.
best,
-Ed
GetName.3dm (57.2 KB) GetName.gh (15.5 KB)