Jump to content

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

Link to comment
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:

Link to comment
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.

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.

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