So I’m making a little Framework for my Rhino/Grasshopper development, and for this I’m wrapping some simple types (double, int, bool etc) into my own “CoAttributeMember” classes, with names like Co_double, Co_int, Co_bool etc.
These classes have some fancy features like Observer pattern, Derived values, Lazy evaluation, etc. So far so good.
Then I also wrapped some Rhino geometry, like Point3d, Vector3d, Brep, Curve and Line (into Co_point3d, Co_Brep, Co_Curve, Co_Line etc), and then suddenly any class field values or property values in those wrapper classes can’t be modified (I can assign a value, but the Filed value doesn’t actually change(!)).
Say I have these two classes, a Co_int and a Co_Line class. If I try to modify the state property IsValueChanged in these (like, from false to true), then the value chanages (as expected) in the Co_int class, but not in the Co_Point3d class. < scratching head >
Thus it seems this is a consistent problem with any Co-class which wraps any Rhino Geometry, but not the C# simple types! Why would that be the case?
Using VS2022, RhinoCommon R7 and .NET Framework 4.8.
Any ideas about why this is happening?
//Rolf
Code examples:
So these two CoAttributeMember classes are “identical” except for the wrapped types (Point3d & int), but trying to modify the property IsValueChanged fails on the Co_Point3d (and on all other classes wrapping a Rhino geometry type) but not on the Co_int class!.
public class Co_Point3d : CoAttributeMember
{
public Co_Point3d()
{
this.SetObject(Point3d.Unset);
}
public bool IsValueChanged;
private Point3d _Point; //cache
public Point3d Value
{
get {
if (!this.IsValueChanged) return this._Point;
this._Point = (Point3d)GetObject();
this.UnsetValueChanged();
return this._Point; // <-- cached
}
set => SetObject(value);
}
}
public class Co_int : CoAttributeMember
{
public Co_int()
{
this.SetObject(int.MinValue);
}
public bool IsValueChanged;
private int _Value; //cache
public int Value
{
get {
if (!this.IsValueChanged) return this._Value;
this._Value = (int)GetValue();
this.UnsetValueChanged();
return this._Value; // <-- cached
}
set => SetValue(value);
}
}