I was wondering if it is possible to have classes derived of e.g. CustomMeshObject where joining into an aggregate exploding the aggregate into its constituents is supported?
For example, if I join two meshes I can later explode them back into their constituents. What I would like to have, conceptually, is this:
public MyCustomMeshObject : CustomMeshObject
{
public MyAggregateCustomMeshObject OnJoin(IEnumerable<CustomMeshObject> others)
{
var othersArr = others.ToArray();
var all = new MyCustomMeshObject[othersArr.Length+1];
Array.Copy(othersArr, all, 0, othersArr.Length);
all[othersArr.Length] = this;
return new MyAggregateCustomMeshObject(all);
}
// special drawing routines, etc. implemented here
}
public MyAggregateCustomMeshObject : CustomMeshObject, IEnumerable<MyCustomMesh>
{
private IEnumerable<CustomMeshObject> _constituents;
public MyAggregateCustomMeshObject(IEnumerable<MyCustomMeshObject> meshes)
{
_constituents = meshes;
}
public IEnumerable<CustomMeshObject> OnExplode()
{
return _constituents;
}
// special drawing routines for aggregate mesh implemnted here
}
Of course, I could write my own Join and Explode equivalents for these classes, but it would be nice if they responded to the native Rhino Join and Explode commands.