algorithmic modeling for Rhino
I don't get it, what's the logic behind the change?
--
David Rutten
david@mcneel.com
Yes quiet, but actually to change numbers with last place-value of 6 (456,876,216..etc).
Where can i learn the usage of the comand "expression" ?
Here and now is as good a time and place as any.
Expression is an instruction to do something that will return a value.
They crop up in GH in a few places as components [Expression] and [Evaluate] and also as an I/O Modifier.
If we take yours as an example. You want to see if a number ends with "6" and return 1 in its place if it does.
If we focus on the bold type in that statement you will see that already our expression is taking shape.
[IF] .... [NUMBER] ... [ENDS WITH "6"] ... [RETURN "1"]
as the correct syntax for the Expression Component is:
If(Endswith(x,"6"),1, x)
To break this down to more of an understandable level we have
an expression within an expression
The If Expression is If(TEST,A,B) which means that if TEST is TRUE return A, otherwise return B
and the Endswith expression is Endswith(s,a) which means that if the string s ends with "a" then be TRUE otherwise be FALSE
So our Endswith is our TEST condition in the If expression, the A is 1 and the B is our original value*
All the expressions available in GH can be found using the Button in the top right hand corner of the Expression Editor which looks like f:N=>R
* you should be aware that our original value has been converted to Text in order to work within this expression. If you need to keep the original number you may need to create a Boolean List of 1s and 0s to manipulate the original values elsewhere
It was really helpful, thank you !
I tried this but somehow every number are shown in my list exept the numbers with place value 6 at the end ? Why is this happening ?
You're going to have to give me a little more than a statement of "it's not working".
Screenshot?
Definition?
Here is a screenshot...
Ah, why didn't you ask for that in the first place?
See if this is what you want (I'm using a regex expression (.*6$) on the numbers (as text/string)):
the MatchText component can be found under Sets>Text.
If you open the Expression Editor/Designer, click on the last icon in the top row : f:N->R for the function list.
Edit: Danny's aprroach is much simpler, but if I recall correctly somebody already handed you that solution, so I tried sth different:)
Well Danny's approach is also new for me as yours, so nothing is simple right know for me.
I must analyse them, hopefuly it will get "simplier" for me too. :)
Thank you !
I think that particular answer was in relation to culling everything except the Endswith 6 numbers and is only part of the puzzle.
This is more about embedding an expression within an expression in order to return a specified value for the Endswith numbers.
The issue here is that it's more of a wasgij than a jigsaw puzzle :)
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by