Jump to content

is it possible to acces points I create in a wrangle within the same wrangle.


arjanM

Recommended Posts

Hi, is it possible to access the points I create in a wrangle with the addpoint function in the same wrangle?
I have an attribute wrangle that only runs once. Within that wrangle I made a for loop where I create points. Then I want search for neigbouring points within the points I created so far in the same loop.
I could store the positions in array and loop through the array of the positions I stored so far within the loop, but that can get pretty slow. I hope I explained this well anough.
I there any way to do this or should I have another approach for this?

Link to comment
Share on other sites

In these situations, it might be better to just drop down another wrangle after the first one. Then run the loop again, essentially in a new context. You don't need to store the points again in an array because you just created them and now they exist down stream. The second wrangle can pick up on that.

Remember, when you run code in Detail mode (only once) you lose the multi-processing benefit of VEX, so you could just as effectively construct a python solution instead if you are more comfortable in that programming language.

Edited by Atom
  • Like 1
Link to comment
Share on other sites

Not possible in your concrete case, but possible in limited other situations, where you can use the new point number to set it's attribute or create vertices and primitives with it. All geometry created inside loop added at the end of the cook. When you access something like nearpoints you use input number, which is not the geometry being processed, but the upstream geometry:

int pt = addpoint(0, {1,0,0}); // An exact pt value will be lastpointnum+1.
@Cd = point(0, "P", pt);       // Cd will be zero, not red, since there is no such point number on input.

Technically, there is geoself() function, but it always outputs 0, I'll guess it's either not implemented in Houdini 15.5 or it was always meant to be the first input.

int pt = addpoint(geoself(), {1,0,0});
@Cd = point(geoself(), "P", pt); // Cd still will be zero, not red.

 

Link to comment
Share on other sites

Thanks for the quick answers. That is too bad something like this isn't supported.
I am trying to make something like a curve that grows on a surface, so the position of the new point is depended of the last point. I want to use the neighbors function to check if there are points nearby so the new point will move away from the other points.
Would it be possible to write the newly created point to a geometry file in the wrangle and then use that geometry file with the neighbors function?
I also could just add 1 new point in the wrangle and put that between for loop network nodes, but that isn't as easy as putting everything in one wrangle.

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