# Grasshopper2 Fields

**URL:** <https://discourse.mcneel.com/t/grasshopper2-fields/171054>\
**Category:** Grasshopper2\
**Tags:** windows, rhino8\
**Created:** [December 8, 2023, 2:41pm UTC](https://discourse.mcneel.com/t/grasshopper2-fields/171054 "2023-12-08T14:41:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahdiyar](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/mahdiyar/32/472862_2.png) [@Mahdiyar](https://discourse.mcneel.com/u/Mahdiyar)\
**Post date:** [December 8, 2023, 2:41pm UTC](https://discourse.mcneel.com/t/grasshopper2-fields/171054/1 "2023-12-08T14:41:14Z")

</div>

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.  
 ![[video-to-gif output image]](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/7/d/5/7d5a0fba37ea73e5888016fdfb2731ce8051bfd0.gif)

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.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/a/8/1/a810ae29100738df88b306b96f559167b8b8699b.png)

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.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/6/9/b/69b6e195d4716ed0e0de0265e3d04b02cf056a8f.jpeg)

But just as an experiment, I tried creating an _ExpressionField_ that only generates _Scalar Field_.

```cs
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;
}

```

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/9/a/6/9a6a2903b8235c7366d74b45def3c3920950f7b2.jpeg)

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [December 8, 2023, 8:14pm UTC](https://discourse.mcneel.com/t/grasshopper2-fields/171054/2 "2023-12-08T20:14:55Z")

</div>

Never to early to report stuff like that. I can repeat that simplex field bug, looking into it now.

Edit: fixed.

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [December 8, 2023, 8:29pm UTC](https://discourse.mcneel.com/t/grasshopper2-fields/171054/3 "2023-12-08T20:29:10Z")

</div>

> [@Mahdiyar](#):
>
> I’ve got another issue with the Field From Expressions component. It seems like the _Ey_ and _Ez_ inputs on this component are optional.

Looking at the code trying to figure out what I was thinking. It definitely always outputs a vector field, but why on Earth did I make y and z optional?

Edit: I figured it out. The underlying field type can be both scalar or vector, but the component only makes vector fields. I should make another component which creates a scalar version out of expressions.

But I probably changed my mind in the middle of writing that and only half fixed it.

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [December 8, 2023, 9:04pm UTC](https://discourse.mcneel.com/t/grasshopper2-fields/171054/4 "2023-12-08T21:04:20Z")

</div>

I made all three inputs optional. If you do not specify an expression for a coordinate it just ends up being zero.

 ![Screenshot 2023-12-08 at 22.03.27](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/b/8/9/b897407d3420144f4d9da931932879b417c89d03.jpeg)

---

<div class="post-metadata">

**Author:** ![Mahdiyar](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/mahdiyar/32/472862_2.png) [@Mahdiyar](https://discourse.mcneel.com/u/Mahdiyar)\
**Post date:** [December 8, 2023, 9:11pm UTC](https://discourse.mcneel.com/t/grasshopper2-fields/171054/5 "2023-12-08T21:11:08Z")

</div>

> [@DavidRutten](#):
>
> I should make another component which creates a scalar version out of expressions.

That’s awesome! It’s gonna be one of the most useful fields components for me.
