Jump to content

Primpoints problem? Getting a list of points in a point wrangle


tanzola

Recommended Posts

Hey everybody,

I'm trying to make a simple setup that starts out with one point from an add node. Then in a solver, a point wrangle gets the position of the last point on the incoming geometry and creates a new point with the position of the last point, plus an offset. The problem is that points are always being created at the position of the first point plus the offset. 

Here is the code in the point wrangle (running over Detail). The "num" attrib will always has a value of zero, so it looks like the primpoints function is giving me an empty list, but I don't know why.

int pts[] = primpoints(0, (@primnum));
vector endpos = point(0, "P", pts[-1]);

vector off = {0,1,0};

int npt = addpoint(0, endpos+off);
setpointattrib(0, "num", npt, len(pts));

Thanks for taking a look!

pointCreate_01.hipnc

Link to comment
Share on other sites

because there is no prim in your geo

- in Add SOP/Polygons/By Pattern/Polygons0 type 0, that will create 1 primitive attached to your point 0

- switch your wrangle to Run Over: Primitive, this will not only make @primnum be valid, but also later your wrangle will work correctly if you have multiple prims coming in an you want each of them to grow independently

- in your code make sure you append the new point to the primitive, so after your line with addpoint() insert this:

addvertex(0, @primnum, npt);

 

pointCreate_01_fix.hipnc

Link to comment
Share on other sites

however if you don't care for the setup to work for multiple lines/primitives

and just aim for very simple setup always starting from one point and always just appending one point after the very last point in the whole geo as you described, you can just keep your original setup (no prim created, and run over Detail), just change your code to :

vector endpos = point(0, "P", npoints(0)-1);
vector off = {0,1,0};
int npt = addpoint(0, endpos+off);

which will instead of last point of the prim use last point of the geo
 

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