Grasshopper

algorithmic modeling for Rhino

A = New Grasshopper.Kernel.Expressions.GH_ExpressionParser(True).Evaluate("4<=3")._Bool

error: Invalid expression: Unexpected symbol encountered (=) (line: 1161)

Which is the right way to do this operation? It seems that the second Boolean operators are taken as strangers.

Thanks in advance.

Views: 332

Replies to This Discussion

The expression language cannot handle operators of more than one character. You need to use the GH_ExpressionSyntaxWriter type to convert strings that people like to type into strings that the parser understands.

This, basically:

string exp = Grasshopper.Kernel.Expressions.GH_ExpressionSyntaxWriter.RewriteAll("4<=3");

A = New Grasshopper.Kernel.Expressions.GH_ExpressionParser(True).Evaluate(exp)._Bool

Incidentally if you just use GH_Convert.ParseExpression this is all done for you.

Great, thanks David :)

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service