How to switch via expression

   12416   6   2
User Avatar
Member
50 posts
Joined: 4月 2017
オフライン
Hi,

I want to switch two object with “switch node”,for example,there is a sphere object node,an object merge node and a switch node in the scene,if there is no object in the merge node,the switch input is 0,else is 1,how to achieve this goal?I tried to write a expression code(as in the screenshot),but doesn't work,could you help me?Thanks in advanced!

Attachments:
Capture.PNG (59.9 KB)

User Avatar
Member
471 posts
Joined: 11月 2013
オフライン
Greeting.
You can use npoints function to get number of points in your object merge if it would be zero then it goes with sphere.
Documentation page for npoints:
http://www.sidefx.com/docs/houdini/expressions/npoints [www.sidefx.com]

for your file do this in switch1:
if(npoints(“../object_merge1/”) != 0, 1, 0)
User Avatar
Member
50 posts
Joined: 4月 2017
オフライン
Hi,Nima

Thanks very much! It is working nice!
User Avatar
Member
11 posts
Joined: 1月 2006
オフライン
or even

if(npoints(“../object_merge1/”), 0, 1)
User Avatar
Member
8 posts
Joined: 8月 2015
オフライン
Of course the you have to use " not “ or ”.
Cheers, D
User Avatar
Member
5200 posts
Joined: 2月 2012
オンライン
Hi,

You can also just do something like this:

npoints("../object_merge1/") > 0
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
User Avatar
Member
776 posts
Joined: 8月 2013
オフライン
Hi

I just found this thread.

There is also a new node to 18.0 called switchif.

https://www.sidefx.com/docs/houdini/nodes/sop/switchif.html [www.sidefx.com]

Best

Mark
  • Quick Links