Jump to content
Sign in to follow this  
logix1390

npoints function not working

Recommended Posts

hello,

I am just trying to understand how this npoints function works.

I want to store the maximum amount of points of another object in a variable called myID

so i say:

i@myId= 1;
@myId = npoints("../PTS");

it should return 1000 points but it returns 0.

The help file say this

npoints:

Returns the number of points in a geometry

npoints(surface_node)

 

What am I doing wrong here? I will attach my scene file for anyone who wants to take a look.


Thank you

 

npoints_question.hip

Share this post


Link to post
Share on other sites

you could just wire the PTS into the 2nd input of the wrangle and use npoints(1) i guess...

Share this post


Link to post
Share on other sites

or as orig setup use:

i@myId = npoints("op:../PTS");

Also, be very careful when you use the help...there's VEX function and then there's expression function

They have slightly different syntax, when I first started I lost a bit of hair over this. Since you are in a wrangle...you should look up VEX function and not expression function (usually quickie one-liners)

 

So the help you posted....that's for an expression function (tho in this case the syntax is the same...but note it says surface node and that's it). If you use the help for VEX function...read further, it says:

<geometry>

When running in the context of a node (such as a wrangle SOP), this argument can be an integer representing the input number (starting at 0) to read the geometry from.

Alternatively, the argument can be a string specifying a geometry file (for example, a .bgeo) to read from. When running inside Houdini, this can be an op:/path/to/sop reference.

and hence, that's where I got the op: from...

Edited by Noobini

Share this post


Link to post
Share on other sites

Thanks noobini. Both methods work perfect !

But i'm a little confused on  why my method doesn't work ?

Share this post


Link to post
Share on other sites

In VEX specifically, anytime you're trying to load data from something (SOP geometry, COP pixel data, etc) instead of just grabbing a node name or channels from that node, you need to preface the path with op: in order to tell Houdini that you actually intend to cook that operator and retrieve the data. 

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  

×