Jump to content

nPoints Function


Arthur Spooner

Recommended Posts

number of points of first input geo

int npt = npoints(0);

or

int npt = npoints(geoself());

number of points of a geometry in the file /temp/geometry.bgeo

int npt = npoints("/temp/geometry.bgeo");

number of points of a geometry of the sop operator at path /obj/box1/box1

int npt = npoints("op:/obj/box1/box1");
Edited by anim
  • Like 1
Link to comment
Share on other sites

to recap

npoints() gives you number of points of geometry connected to first input of your wrangle node

npoints(1) gives you number of points of geometry connected to second input

npoints(2) third input

etc.

npoints("/temp/geometry.bgeo") gives you number of points of geometry from file regardless of whether any inputs are connected to wrangle or not

npoints("op:/obj/box1/box1") gives you number of points of geometry of specified operator regardless of whether any inputs are connected to wrangle or not

  • Like 1
Link to comment
Share on other sites

In other words.  I have a torus in the scene, the torus is connected to the first input of the pointWrangler node, I enter the VEXpression;

 

int nOfp = npoints(0);

 

In GeoSpreadSheet (points) for the pointWrangler node I will be seeing all the points for the torus ?

int nOfp = npoints(0);

will just store number of points of the torus into a temporary variable nOfp, which you can use within the wrangle, but is not stored anywhere on the output geometry

if you havever do:

i@nOfp = npoints(0);

it will create attribute on the output geometry called nOfp, which will contain number of points of your input geometry (torus)

if you do it in Point Wrangle (which is Attribute Wrangle run over Points) then you will see in Geometry Spreadsheet (points) attribute called nOfp and for each point it will have value that equals to number of points of the input geometry (torus)

  • Like 1
Link to comment
Share on other sites

like this

int nOfp = npoints(0);
if (nOfp > 0) {
    i@haspoints = 1;
}

first line stores number of points to temporary variable nOfp

then you can use that variable just by typing its name

so if (nOfp > 0)  will check if that variable is bigger than 0, so if number of points of first input is > 0, if it is, it will set integer attribute haspoints to 1

  • Like 1
Link to comment
Share on other sites

...

 

How can I extrude some faces with VEX, what are the commands use to say, take some polygons and extrude them proceduraly ?

 

that's a bit advanced topic, simple answer would be you'd have make your own polyextrude() function, using addpoint() addprimitive(), ... etc. functions to build all the extruded faces and maybe set their attributes 

I'd stick with PolyExtrude SOP for now, it's still allows for procedural control, what are you trying to do?

Link to comment
Share on other sites

that's a bit advanced topic, simple answer would be you'd have make your own polyextrude() function, using addpoint() addprimitive(), ... etc. functions to build all the extruded faces and maybe set their attributes 

I'd stick with PolyExtrude SOP for now, it's still allows for procedural control, what are you trying to do?

 

Instead of manually extruding faces on a sphere, or torus.  I want to do them procedurally. All faces have vertices count.  How can I, as a starting point, extrude particular faces on a torus, or sphere via SOP nodes ? 

 

simple answer would be you'd have make your own polyextrude() function, using addpoint() addprimitive()

 

 

Hrm, how would I start out; nothing extravagant :)

 

it s not a variable but an attribute he creates.

 

whatever name has "@" is an attribute

 

 

int nOfp, creates a temporary variable, is there such thing as a permanent variable or are attributes the equivalent ? 

Link to comment
Share on other sites

Instead of manually extruding faces on a sphere, or torus.  I want to do them procedurally. All faces have vertices count.  How can I, as a starting point, extrude particular faces on a torus, or sphere via SOP nodes ?

look at example file

...

int nOfp, creates a temporary variable, is there such thing as a permanent variable or are attributes the equivalent ?

well, "temporary" variable was just an expression in contrast to attributes which actually store the data in the geometry

but in other words, int nOfp... defines proper VEX variable, which is valid within the scope that is defined, whether it is within a function, loop or operator definition, but it certainly isn't valid outside of the wrangle or CVEX operator, hence "temporary"

so yes, if you want your data to live longer, store it in the geometry as attribute

procedural_polyextrude_example.hip

  • Like 1
Link to comment
Share on other sites

but in other words, int nOfp... defines proper VEX variable, which is valid within the scope that is defined, whether it is within a function, loop or operator definition, but it certainly isn't valid outside of the wrangle or CVEX operator, hence "temporary"

 

 

What is outside of the wrangler of CVEX operator ?

 

The example scene file; I understand you created an integer attribute called group_extrudegrp but I couldn't find @numvtx, is this another attribute ?

Then you created another attribute f@dist and assigned the command fit01, shouldn't it just be called "fit" ?

 

Those attributes (numvtx, numpt) are within the VOP node, must I always add a VOP node just for certain attributes ?

Edited by Arthur Spooner
Link to comment
Share on other sites

What is outside of the wrangler of CVEX operator ?...

for now you can think of it as outside of the Wrangle node that you are typing the code into

so if you define the variable in the code of a Wrangle node, you can access it only within the same code and not in the code of other Wrangle nodes

 

The example scene file; I understand you created an integer attribute called group_extrudegrp but I couldn't find @numvtx, is this another attribute ?

Then you created another attribute f@dist and assigned the command fit01, shouldn't it just be called "fit" ?

Those attributes (numvtx, numpt) are within the VOP node, must I always add a VOP node just for certain attributes ?

@numvtx, @numpt, @numprim, @vtxnum, @ptnum, @primnum and many others are automatically bound to the first input geometry information, without the need for them to be attributes

so in wrangle you use for example @ptnum, in the same situations as in Point VOP you use ptnum output from Global Parameters, none of them require an attribute

i@group_extrudegrp defines membership to a group called extrudegrp not an attribute

you can read about all that here:

http://www.sidefx.com/docs/houdini15.0/vex/snippets

fit01() is a simplified function to fit()

it assumes the input range to be 0-1

to learn more about what functions are available and what they do:

http://www.sidefx.com/docs/houdini15.0/vex/functions/

Edited by anim
Link to comment
Share on other sites

not sure what you mean, it's either Windows/Shell

or from outside of houdini you can run it either from start menu, in Side Effects Software/Houdini X.Y.Z/Utilities/Command Line Tools

or from disk in your Houdini folder/bin/hcmd.exe

Edited by anim
Link to comment
Share on other sites

not sure what you mean, it's either Windows/Shell

or from outside of houdini you can run it either from start menu, in Side Effects Software/Houdini X.Y.Z/Utilities/Command Line Tools

or from disk in your Houdini folder/bin/hcmd.exe

I thought it was textport.  It's hcmd.  Where can I find a list of commands to use in hcmd ? :)

Link to comment
Share on other sites

what are you trying to do?

shell launched by hcmd or Windows/Shell is command line shell initialized with houdini environment variables so you can access all houdini stand-alone utilities

http://www.sidefx.com/docs/houdini15.0/ref/utils

if you however wanted texport and therefore hscript commands, then refer to this:

http://www.sidefx.com/docs/houdini15.0/commands

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.

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