I have plugin objects which are grouped for some functionality of plugin. I want to update my object by using ReplaceRhinoObject when user move this object via gumball and Move command. The problem that I encounteer here, I cannot reach guids of subobjects of group. Guids coming like {00000000-0000-0000-0000-000000000000}. How can I handle this problem?
Sample psuedocode;
private void RhinoDoc_ReplaceRhinoObject(object sender, RhinoReplaceObjectEventArgs e)
{
// I have grouped plugin objects in Rhino
RhinoObject rhinoObject = e.NewRhinoObject;
// When I get sub objects in the group, their guids come {00000000-0000-0000-0000-000000000000}
List<RhinoObject> rhinoObjects2 = rhinoObject.GetSubObjects().ToList();
// There is a helper method which is working with guid of sub objects.
UpdatePluginObjectAfterReplacing();
// Deleting old one
RhinoDoc.ActiveDoc.Objects.Delete(e.OldRhinoObject.Id, true);
}
RhinoObject.GetSubObjects, is used to explode a Rhino object into subobjects. The returned objects have not been added to the document, which is why their id’s are Guid.Empty.
That said, what are you trying to do? Please be specific - thanks.
What I want to achive;
I have nested plugin objects (grouped in Rhino) which are inherit some features from floor to top. When user change something on the this object via UserInterface, I need to recreate this object to update, of course. But when I move the object and change values from UI, the object updates itself at the old location (It come back old location). So, I need to count in transformations (move, rotate, scale) to protect locations after user changes.
What I tried to achieve
Because of the reasons that I mentioned above, I am updating the objects using with Guid of subobjects. So I have a method which is ReadGeometry in order to take values from geometry to update my plugin object. That’s why I am trying to get Guids from in the event of RhinoDoc_ReplaceRhinoObject ;
List<RhinoObject> rhinoObjects = e.NewRhinoObject.GetSubObjects().ToList();
// empty list to collect guids
List<Guid> guidsOfSubObjects = new List<Guid>();
foreach(RhinoObject item in rhinoObjects)
{
guidsOfSubObjects.Add(item.Id);
}
// Method for read values that plugin needs to recreate the plugin object after changes or transformations
ReadGeometry(guidsOfSubObjects);
I hope it is clear what I want to achieve.
Thanks
-Oğuzhan
RhinoObject.GetSubObjects , is used to explode a Rhino object into subobjects. For example if you have a Brep object that looked like a box, this method would return it’s 6 surfaces a Rhino objects (e.g. explode).
Because of the structure of grouped PluginObject, it need to update just one time. When it is replacing for each subplugin object, this calculated properties becoming problematic.
Grouping objects allows selecting multiple objects by picking one of the group components. Object grouping can also be ignored when picking if you press Ctrl+Shift and then click.
Grouped object are modified individually. That is, if you pick a group and move it, each object in the group is transformed individually. I believe this is the undesired behavior you are describing. There isn’t anything I can about this.
Anyway, if you want to use groups to track objects, then have a look at the following example code, as it demonstrates one way of tracking grouped object changes. Note, I have not tested this.