Grasshopper

algorithmic modeling for Rhino

Masking and Adding Expression to Parameter Components

Can someone please explain the string syntax when using a Mask expression for a path compare component in grasshopper? Also, what is the sytax when adding an expression as an argument to a parameter component such as a point parameter?

 

thanks

 

Views: 5167

Attachments:

Replies to This Discussion

Here's a few examples. Question marks can be used to match a single digit, asterisks can be used to match any number of digits.


--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks David, I presume the same syntax applies to the point parameter component? It would be nice if we can add lrange constructors in the mask. For example filter points with X <= 10.
If you want ranges, use square brackets with hyphen separated extremes:

{0;0;[0-10];0}

If you want a custom set, use square brackets with comma separated indices:

{0;0;[0,2,4,6];0}

--
David Rutten
david@mcneel.com
Poprad, Slovakia
And you can use exclamation marks in front of elements to invert the mask. Thus:

{0;0;!7;0}

means anything but 7 in the third index. And:

{0;0;![0;1;9];0}

means anything but zero, one or nine in the third index. And:

{0;0;![3-8];0}

means anything outside of the 3-8 range in the third index.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Is a Grasshopper Primer update in the pipeline to explain & include examples for this?
Hi Astro,

not from me. My plan is to vastly improve the Component help file system.

I'd like to have a flexible system where any object running inside Grasshopper can register any number of Helpfile pages, pages can have links to other pages, help file topics can contain images and example files etc. etc.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
are you using regex ? and would most of the regex rules work
No. I wrote my own interpreter.

To be blunt, I don't understand RegEx. Never have, and I suspect I never will. Every time I try to learn how it works I'm just baffled by the utter unreadability of the example patterns. Like this one:

^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$

If there are features you'd like to see implemented in the Path Mask interpreter, let me know. If you want a regex component, I'll try and write one.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
i hear you, it is a little like hieroglyphics but the simple rules are simple like

\d = find all numbers
\D = find anything but numbers
[0-5] = find a range

and so on

anyway this page helps me out

http://www.zytrax.com/tech/web/regex.htm
One of the things which I found very difficult with regex (indeed, it may well be impossible for all I know) is to use multi-character digits as integers.

It's easy enough to match numbers between 0 and 4, but how does one match a string number between 32 and 99?

--
David Rutten
david@mcneel.com
Poprad, Slovakia

David

Maskign doenst appear to work if we use real numbers instead of integers in the mask construct

It's easy enough to match numbers between 0 and 4, but how does one match a string number between 32 and 99?

I am sure that your question was merely rhetorical, so I hope that my response isn't irritating. Here's a regex that answers this question though.

^(3[2-9])|([4-9][0-9])$

I say this hoping that you'll appreciate knowing that regexes can handle ranges such as this and can add really interesting functionality for number manipulation. I should add that it does certainly get trickier with larger numbers (e.g. 3-digits or more). I also know that this post is 5 years old, so I presume you may be aware of this by now... Anyways, thought it wouldn't hurt.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service