Jump to content
Sign in to follow this  

VOP SOP: how do I get the number of primitives in

Recommended Posts

It is my first VOP SOP and I need to get the number of primitives in input 0. I have seen a function "int nprimitives( string filename )" and it seems to work only with a filename. Is there an equivalent with an input that I have not seen? And moreover, I'd like not to go into coding already, so if there is such an equivalent, is it accesible within VOP? or only with VEX functions?

and actually I am still not clear with the differences between VOP and VEX. are all VEX functions wrapped into VOP? when do I need to go into coding instead of making a visual graph?

thanks in advance for a few hints about this

Share this post

Link to post
Share on other sites

-about the number of primitives.

There's a useful function in expressions (not in VEX) which is nprims("path"):

take a look at the help about Expressions

Create a parameter B into the VOP SOP where to put the expression

(To avoid re-typing all the path: copy any parameter A of the input (right-click\copy parameter )

paste it into the B parameter (right-click\paste copied reference) , and change ch(" ") into nprims(" ").)

-about VEX/VOP

Not all the VEX functions are wrapped into VOP

There's almost no need to use VEX for simple things.

I ALMOST NEVER use VEX, except for complex things with loops, and when there's no tweaking (but that's very rare)

VOP gives more control and flexibility. it's something unique to Houdini like many other things :) :)

I always use VOP instead of VEX in shaders. (Shaders always require feedback) :rolleyes:

Share this post

Link to post
Share on other sites

I also responded prims and your answer is the better one for sure. Less memory for constants but both have a place. See mine for a way to auto fetch the prim count from any input SOP by using

nprims("../"+opinput(".", 0))


Constant expressions are fine for feeding in to VOPs but remember that you can't feed in variable expressions like $PT. Has to be an attribute.

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