Great! This thread looks very complicated so let me reformulate.
What I need is to let the user operate with my entities as document objects. Real world objects not only have geometry and metadata, they also have programmable behaviour. That’s why there are so many plugins. With Rhinocommon is hard and incomplete to manipulate custom objects from the viewport. Custom objects like an arrow that you can drag on its axis, or a custom spline, or a rail of profiles that forms a pipe with known/named sides, or a chair whose backrest can only be rotated on discrete values…
Consider I want to create a custom curve type, a rail entity. This rail is like a curve but it allows you to control its normal and bi-normal functions so that you can define how to extract perpendicular planes of it, for example, to force its Y axis always perpendicular or parallel to other geometry. For other side, the build function of a wire entity would be: extract perp. planes on a rail, put profiles on them and create a sweep surface with caps, so the wire is algorithmically aligned to other geometry thanks to the rail behaviour, and its wire methods can be call and its wire properties are updated after any rail change. I want the user to modify the control points of the rail curve for example then rebuild the wire using the new plane profiles and in between update all neccesary entities.
Would be awesome if:
- From a command, create an entity and add it to a document as a custom object, modify the entity from the viewport or parameters (like in the project provided in the thread), save it and load the entity/custom object in the state it was saved.
- Any user operation (such as transforming, modifying control points, deleting because it was purged or trimmed, when it is duplicated and for what reason, or when is selected, undo/redo…) can change the state of the custom object and therefore must update the state of the entity.
- Perform a transformation constrain, for example, prevent to move the custom object in an arbitrary axis.
- Create an entity that has multiple geometry types on the same plane reference, so when one is transformed, the custom object must update the other with that transformation.
- Get all documents objects that inherits a custom object type.
- A RhinoGet< T> where T is a custom object.
- Have the Rhino.DocObjects.Custom.CustomGenericObject class.
- Have a hierarchy of custom objects (objects that contain other objects) or some kind of linking.
- Notify with event or a OnUserDataChanged method when UserData is modified.
- Synchronise state changes from the entity to the custom object and from the custom object to the entity.