filter expression

   7492   3   1
User Avatar
Member
523 posts
Joined: July 2005
Offline
Hello,


I'm using a group node with filter expression.
Does anyone know an expression to select only the ‘even’ primitive numbers of my input grid ?


thanks,



bern
User Avatar
Member
1921 posts
Joined: Nov. 2006
Online
Try

$PR % 2 == 0
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
194 posts
Joined:
Offline
Yep, what Graham suggested is what you need.
Basically, you need to know what variable carries information about primitive number. It's $PR - see Local Variables under hdox/houdini/content/helpcards/sop/primitive.html

Then you need to find whether the primitive number is divisible by 2 or not.
For that you need the modulus function (%) - which gives you the remainder
of dividing one number by another number. If the remainder of division by 2 is 0, you know you're dealing with an even number.

Hence, the expression is $PR%2==0 (== checks whether a condition is true, = is the assignment operator, so make sure to use =
User Avatar
Member
319 posts
Joined:
Offline
modulus is so useful…really good expression to know..
  • Quick Links