Is there an example for Userdata for VB.net.
I would like to be able to apply data to an object, select the object based on that data, and export the data with the object to a new file.
Thanks,
Don
Is there an example for Userdata for VB.net.
I would like to be able to apply data to an object, select the object based on that data, and export the data with the object to a new file.
Thanks,
Don
I recommend not to go down the UserData road, but use the UserDictionary. The UserDictionary is automatically saved when the document is saved; for UserData you must provide your own read/write code.
I’m afraid I don’t know how to write an example for UserDictionary in VB.NET, but in C# it looks like this:
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
ObjRef oRef;
Result res = RhinoGet.GetOneObject("Select an object to add data to", false, ObjectType.AnyObject, out oRef);
RhinoObject obj = oRef.Object();
obj.Geometry.UserDictionary.Set("MY_KEY", "MY_DATA");
obj.CommitChanges();
Guid id = obj.Id;
foreach (RhinoObject o in doc.Objects)
{
if (o.Geometry.UserDictionary.ContainsKey("MY_KEY"))
{
Guid found = o.Id;
RhinoApp.WriteLine("Set on {0} - Found {1}", id, found);
}
}
return Result.Success;
}
By the way, if you do want to use the UserData, check this out (also in C#)
https://github.com/dalefugier/SampleCsUserData
Thanks menno, I will look this over and see what I can come up with.
Don