algorithmic modeling for Rhino
I am trying to use the equivalent of VB script Rhino.SetObjectData in C#. Does anyone know how i can do this?
For example:
Rhino.SetObjectData arrObj(0) ,"behavior", "type","L"
http://4.rhino3d.com/5/ironpython/functions/setobjectdata.htm
Tags:
I think the equivalent would be something like this:
RhinoObject obj = RhinoDocument.Objects.Find(x);
obj.Geometry.SetUserString("key", "value");
obj.CommitChanges();
'x' is the GUID of the object. If you are on a scripting component you can reference the geometry to a parameter, connect the parameter to the x input and set the type hint of the input as Guid.
Hi Vicente,
Thanks very much for your response. The Rhino.SetObjectData method takes an additional parameter which is the name of the application. The obj.Geometry.SetUserString("key", "value"); does not take this parameter so I don't know how it can work.
Rhino.SetObjectData (strObject, strSection, strEntry, strValue)
strObject |
Required. String. The object's identifier. |
strSection |
Required. String. The application name. |
strEntry |
Required. String. The key name. |
strValue |
Required. String. The string value. |
This is the most basic way of quickly adding user data to objects. It's the same as the Rhino commands _SetUserData and _GetUserData. If you want to add more customized user data you will have to derive a class from Rhino.DocObjects.Custom.UserData. There's a good example on this page: http://wiki.mcneel.com/developer/rhinocommonsamples/userdata.
If you prefer to keep it simple and stick to the user strings, you could add subcategories by merging them in the key field separated by a character (for example "Program Name;Category one;Category two").
When you want to retrieve them, after reading the key string, split it using the separator character to get the different subcategories as an array of strings.
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