Hello Scripters,
i am trying to access a components values with a python script which is not running in the GHPython component but from the Python Script editor. The component i try to access is a Guid component which is holding some Rhino Object Ids.
I can get the opened Grasshopper document and find the component using:
found_items = document.FindObjects(search_list, 1)
if found_items:
component_obj = found_items[0]
and i can read the object ids properly using this:
print "Assigned ObjectIds to '{}'".format(component_obj.NickName)
for obj_id in component_obj.VolatileData:
print obj_id
But how can i change the ids, or set my own to the component ? With some help from @djordje i’ve been able to perform this:
gh_path = Grasshopper.Kernel.Data.GH_Path(0)
gh_guids = [ Grasshopper.Kernel.Types.GH_Guid(obj_id) for obj_id in obj_ids]
success = component_obj.AddVolatileDataList(gh_path, gh_guids)
print "Success:", success
mydoc.NewSolution(True)
which prints True
, and i can also list that my object ids got assigned. But i do not see that in the Grasshopper GUI. What is the save way to do it right ?
thank you
c.