I have given the CRhinoGripObject::GRIP_TYPE::surface_cv_grip in the constructor, and I can verify that the grips have this type.
I have assigned the weights with pGrip->SetWeight(w);
The second step returns false and pGrip->Weight() returns ON_UNSET_VALUE
The weight command does work, but shows the ON_UNSET_VALUE as expected, because SetWeight did not work.
Ok, I failed to notice that this is a virtual. When I provide my own implementation by overriding Weight() and SetWeight() on the custom grip object it works.
It would be nice if the comments in the header reflected the fact that CRhinoGripObject does not provide an implementation.
My suggestion:
/*
Returns:
The weight of a NURBS control point grip or ON_UNSET_VALUE
if the grip is not a NURBS control point. By default, CRhinoGripObject will always
return ON_UNSET_VALUE.
You need to override this with your own implementation to make it work.
*/
virtual
double Weight() const;
/*
Description:
Set the weight of a NURBS control point grip.
double
weight - [in] NURBS control point weight (>= 0 )
Returns:
True if weight was changed. By default, CRhinoGripObject does not provide an implementation and will always return false.
You need to override this with your own implementation to make it work.
*/
virtual
bool SetWeight(
double weight
);