How to switch via expression

   2554   3   0
User Avatar
Member
50 posts
Joined: April 2017
Offline
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: Nov. 2013
Offline
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: April 2017
Offline
Hi,Nima

Thanks very much! It is working nice!
User Avatar
Member
10 posts
Joined: Jan. 2006
Offline
or even

if(npoints(“../object_merge1/”), 0, 1)
  • Quick Links