Jump to content
Sign in to follow this  
logix1390

simple if statement not working

Recommended Posts

Hello,

I am trying to do a very simple if statement where I delete a point after a certain frame. I have a point, i put down a timeshift to get the frame I want to delete after, and then put a wrangle like this:

 if(@Frame<chi("FrameNumber")){
    removepoint(0,@ptnum);
}

 

What I thought this was  saying was "if the current frame number is greater than this value then delete the points coming from the first input ??

But this does not work . Can I anyone explain whats going on here?

I will attach my scene file for anyone that wants to take a look.

Thank you.

simple_if_statement_deleting.hip

Share this post


Link to post
Share on other sites

Not sure what you need the Timeshift node for, but if you dont reference it and instead type 21 in the FrameNumber parm on the wrangle, then all you have to do is reverse the comparison for it to work:

if(@Frame>chi("FrameNumber")){
    removepoint(0,@ptnum);
}

-b

Share this post


Link to post
Share on other sites

Hi Mike,

Change chi("FrameNumber") to chi("Frame_Number") or chi("frame_number") or chi("framenumber"). I presume that Houdini don't like when capital letter is in the middle of an attribute's name.

P.S.

Don't forget press button "Create spare parameter" when change the name of attribute

Edited by vicvvsh

Share this post


Link to post
Share on other sites

Camel case works...ie. FrameNumber is fine.

But your logic is screwed.

First, you have  

if(@Frame<chi("FrameNumber")){
    removepoint(0,@ptnum);
}

and you said "if the current frame number is greater than this value then delete the points coming from the first input ?? Well, no...if LESS than, then remove...so are you sure whatever logic is right here ?

Second, the timeshift is a moving target...ie. $F+20....so it's ALWAYS moving...you'll never hit it....(ie. whether you use greater than or less than, it'll always be true or false....but never hit a tipping point where it CHANGES true to false or false to true)

If you explicitly set in timeshift frame to say 20, then the tipping point will be at frame 20.

Share this post


Link to post
Share on other sites

your absolutely right. can't believe I forgot to break the expression on the time shift. It was always moving..thanks guys.

Share this post


Link to post
Share on other sites

Yes, may mistake. I have overlooked that in parameter "FrameNumber" there is an expression that refer to frameshift. In my case I just typed number manually when I examined your scene.  I'm sorry if I misled you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×