I know Grasshopper2 is still in Alpha stage. I’m not sure if it’s okay to report these minor bugs.
By the way, I ran into a quirky glitch in the SimplexScalarField. Looks like it’s having a bit of a hiccup with saving its data the right way. If you want to see it yourself, try adding a Field Iso Display to the canvas, then make a copy of it.
This little bug seems to pop up for any field parameter containing internalised SimplexScalarField.
I’ve got another issue with the Field From Expressions component. It seems like the Ey and Ez inputs on this component are optional. I thought if you just put an expression in the Ex input, you’d get Scalar field. And if you fill in all three inputs, you’d get Vector Field, right? But, it looks like Field From Expressions always creates Vector Field no matter what.
I also tried creating an XyzExpressionField in the code. I noticed it has two constructors. I’m guessing the overload with just one argument is supposed to make a Scalar Field. But now I’m not sure if my guess is off or if there’s something else going on.
For a temporary fix, I’ve been using the Decompose Field component.
But just as an experiment, I tried creating an ExpressionField that only generates Scalar Field.
public class ExpressionField : ScalarField
{
public ExpressionField(Expression exp) => Ex = exp;
public ExpressionField(IReader reader) => Ex = reader.Storable<Expression>("Ex");
public override void Store(IWriter writer) => writer.Storable("Ex", Ex);
public override string Name => "Expression";
public Expression Ex { get; }
public override double ScalarAt(Point3d point) =>
NumberLikeData.ToDouble(
Ex.Evaluate(Resolver.Empty.Append("x", point.X).Append("y", point.Y).Append("z", point.Z)),
out var number) ? number : double.NaN;
}