I am constructing a plugin where we have a UserData defined and these objects should be specific, imagine a brep. If changed, I need to check if the brep is still valid, for example if the user uses the Explode command on it, it does influence some other things in my code, hence i wanne then do some adjustments or fixes or prevent the explode for example, or just remove it from my internal structure.
What is the best way to approach this? I prefereably want to know via an event, the specific object that changed, and maybe how it changed in order to compare it and check the validity based on my standards.
Hey, we have been great at work implementing a system. However we stumpled upon one issue you might be able to help me with.
The system works this way: I have all the event watchers active, and they add all objects to a combined list of editedObjects (if the list does not yet contain them).
Then on RhinoIdle I process these objects, checking if they have any of our plugins UserData, if that is the case, we do some checks.
Now, during one of these processes, for example when I explode a polysurface, this would lead to 6 objects being added to our editedObjects List, each having the same userdata objects from the previous polysurface, which is not a problem, since i can now do a check and see that the resulting surfaces, are not valid for the UserData, which is perfect. However, in order to visually show that these spaces dont have userdata anymore, we want to reset them, since we do based on the metadata, face.PerFaceColor. However, as soon as I adjust the the geometry (for example via PerFaceColor = empty), and i undo the explode, it causes a duplication: the surfaces persist, and the polysurface is being readded as it was before. Why are the Surface not being removed?
During the OnRhinoIdle, Event Watchers are disabled.
Am i missing something?
Best Ben
This is the coloring code
public static void ResetObjectColors(RhinoObject rhObj)
{
var doc = RhinoDoc.ActiveDoc;
if (rhObj == null) return;
var brep = rhObj.Geometry as Brep;
if (brep == null) return;
foreach (var face in brep.Faces)
{
face.PerFaceColor = System.Drawing.Color.Empty;
}
rhObj.Attributes.ColorSource = ObjectColorSource.ColorFromLayer;
rhObj.CommitChanges();
}