Jump to content

Need some help with a 'Do nothing' expression


Recommended Posts

I'm using an expression in my node net work to drive some object copies based on the rotation value of a tube. What I want is the copy SOP to add 1 to the number of copies every 60 degrees. So at 60 its 1 at 120 its 2 at 180 its 3 etc...

Here is what I got:

if(ch("../xform1/rz") % 60,0,++1)

But this resets my channel to 0 if rz is not divisible by 60, so the result is always 1. How do I say 'Do nothing' as opposed to 'Do Zero' in my expression?

Link to comment
Share on other sites

I'm using an expression in my node net work to drive some object copies based on the rotation value of a tube. What I want is the copy SOP to add 1 to the number of copies every 60 degrees. So at 60 its 1 at 120 its 2 at 180 its 3 etc...

Here is what I got:

if(ch("../xform1/rz") % 60,0,++1)

But this resets my channel to 0 if rz is not divisible by 60, so the result is always 1. How do I say 'Do nothing' as opposed to 'Do Zero' in my expression?

Will this work? The trun() expression converts your number to an integer rounding down.

trunc(ch("../xform1/rz")/60)

Link to comment
Share on other sites

Thanks! that's got it. :)

Might want to use floor() instead of trunc() -- trunc() truncates, removing the portion to the right of the decimal point, whereas floor() uses the largest integer that is less than or equal to the floating point value. Using trunc() instead of floor() will hiccup between 0 and -60 (resulting in the same answer (0) as 0 to +60 when what you probably want is -1).

-- Antoine

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...