algorithmic modeling for Rhino
Is there a method to script user text attached to a Grasshopper document which is retrievable by a key value? I'm basically looking for something like that which can currently be done within a Rhino document:
Tags:
Hi Brian,
What do you mean by writing the data to Grasshopper file?
In case you want to change settings, they are get<>set which means you can simply set the value. Give Grasshopper.CentralSettings a try. Something like this:
import Grasshopper.CentralSettings as settings
settings.AuthorAddress = "Brooklyn"
settings.AuthorName = "Brian"
Depending on the data type (i.e. strings) you could use the GH_Document.Properties property for persistent metadata. Not sure if that is what it is meant for, but it seems to work. See attached definition. Also, credits to Mostapha for figuring out how to get the Grasshopper document using Python a while back :)
Added a version where the "metadata" is converted to a dictionary (Pythons key/value data type).
Thanks Mostapha and Anders!
I'm pretty familiar with reading metadata but it seems like I could append multiple strings together representing difference document property fields, write them to an existing property field such as description, and then call them individually using Anders' dictionary method.
So here's the catch: I don't want to overwrite any existing property fields so writing to any available fields in Grasshopper.CentralSettings is hypothetically off limits. I want to define my own custom fields (which of course do not need to display in the Grasshopper Settings GUI but I should be able to call nonetheless). I didn't think it would be possible to create something like Grasshopper.CentralSettings.BriansEsotericDataNeeds which is why I was wondering if Grasshopper had any place to store generic metadata (all strings in my case) like Rhino's "SetDocumentUserText" command.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by