Jump to content

"if" statement or "if" node


Recommended Posts

Hello,

Its been a while since I have been to the forums. I am a Maya guy trying to learn Houdini.

I am currently running a network within a "for each" node. I would like to make groups of every iteration that meets the condition: nprims() <= 1

or create somewhat of a reverse switch node, where I can put in an if condition to drive if it continues to output 1 or output 2.

This is probably an easy solution, but I am just not that familiar with Houdini.

Thanks for the help.

~Ilan

Link to comment
Share on other sites

This should be what you're looking for.

I created an attribute, if the number of primitives <= 1 then the attribute is given a value of 1, else its given a value of 0.

Then I group based on this attribute. You could probably do this inside one large statement but it makes it simpler if its broken up.

Michael, Thanks so much for your reply.

Unfortunately, I don't think that it has solved my problem.

I have tried this earlier but saw that it did not work.

I still get groups with 0 prims in them.

I am posting a scene with your solution included where I am trying to place it. (in the 'for each' node).

Hopefully you or someone could say... that I am going about this the wrong way.

Thanks,

~Ilan

Link to comment
Share on other sites

Are you trying to only create groups when there are polygons? I'm a bit confused by your goals since your expression says if there are 0 or 1 primitives then group it, but then you say you don't want groups with no geometry in them.

Using an expression in the Filter expression isn't the right way to go about this. The expression is run on a per prim basis, and so you will always get the same result, which is kind of wrong anyway. You want to either control the Enable toggle with an expression, or use a Switch to switch between a Group SOP with no expression, or the input before it.

In the attached file I'm assuming you wanted to only create groups with prims in them.

I have it set up both ways. They both use the expression nprims(opinputpath(".", 0)) > 0. This checks the first input geometry to see if there's geometry. If there is the group is created either by toggling the Enable on the Group SOP, or by switching to the always grouped input chain.

odforceIfProblem.hipnc

Link to comment
Share on other sites

Are you trying to only create groups when there are polygons? I'm a bit confused by your goals since your expression says if there are 0 or 1 primitives then group it, but then you say you don't want groups with no geometry in them.

Using an expression in the Filter expression isn't the right way to go about this. The expression is run on a per prim basis, and so you will always get the same result, which is kind of wrong anyway. You want to either control the Enable toggle with an expression, or use a Switch to switch between a Group SOP with no expression, or the input before it.

In the attached file I'm assuming you wanted to only create groups with prims in them.

I have it set up both ways. They both use the expression nprims(opinputpath(".", 0)) > 0. This checks the first input geometry to see if there's geometry. If there is the group is created either by toggling the Enable on the Group SOP, or by switching to the always grouped input chain.

Thank you so much Graham!

That was exactly what I was looking for.

Thank you for taking the time to explain what was wrong with my approach.

I ended up solving it a different way, which probably isn't the smartest way; but it got the job done. That being said I learned a lot from your scene, Thanks!

~Ilan

odforceIfFixed.hipnc

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...