reference active self in VEX

   2787   4   1
User Avatar
Member
143 posts
Joined: Sept. 2017
Offline
Hi,

when working with VEX, the first variable for most of the functions is a geo handle to reference geometry for the function to run on, which can also be substituted for a integer that references an input of the node.
What I'm wondering is, if I have added or edited the input geometry in some way during my wrangling, can I reference the changed geometry in that same wrangle node?

for example:
I have a point at {0, 0, 0} and I want to add new points, that move 0.1 units in X direction, as long as the points stay inside a bounding box.
I know, this could example could be done by generating a list of X coordinates and then use a foreach loop to generate a point for every coordinate, or even just using a for loop.
What I'd like to know, could it be done using a While loop, somehow accessing the points, that have been created in that same Wrangle node and just adding the transform vector to the last created point, while at the same checking, if the point being created is still inside the bounding box?

Thanks in advance.
Cheers,
Ivan
User Avatar
Member
2658 posts
Joined: June 2008
Offline
No, the wrangle presents the current data in a kind of sampled from input state. The state is then updated when the wrangle is exited. So you can mark data in one wrangle for alteration in another. But massive modifications inside a single wrangle don't always work.

Use two wrangles.
Using Houdini Indie 20.5
Windows 11 64GB Ryzen 16 core.
nVidia 3060RTX 12BG RAM.
User Avatar
Member
143 posts
Joined: Sept. 2017
Offline
Enivob
No, the wrangle presents the current data in a kind of sampled from input state. The state is then updated when the wrangle is exited. So you can mark data in one wrangle for alteration in another. But massive modifications inside a single wrangle don't always work.

Use two wrangles.

Thanks, that's what I suspected, so I'll try to look for workarounds.
Still good to know I don't need to spend time researching this topic.
Cheers,
Ivan
User Avatar
Member
2164 posts
Joined: Sept. 2015
Offline
What I'm wondering is, if I have added or edited the input geometry in some way during my wrangling, can I reference the changed geometry in that same wrangle node?

You can, but not directly.

Working in detail mode of the wrangle get the point positions of the pre-existing points and put those values in a vector array.

Do this with a loop with the size you get from the function npoints().

Then do your operations on that array.

Then just create points from that new array.

Of course there are different versions of this approach, depending on whether you want to keep the original points or not, and the complexity of your operations.

But as a cursory glance of what your describing, yes in one wrangle is possible.

Remember: So long as you do ALL of your ‘viritual’ work first,
ie. data you created within the wrangle from your own defined variables.
Then you can do operations( with exceptions ) in that wrangle at the end that involve functions
which affect the scene, like addpoint(), setpointattrib() - of the new points, etc.

Of course there are different approaches to this depending on whether you want to keep the original points, a portion thereof, etc.
Edited by BabaJ - May 21, 2018 12:41:11
User Avatar
Member
143 posts
Joined: Sept. 2017
Offline
Thanks BabaJ, I ended up using a similar solution in the end.It's a bit more work, but gets the job done.
  • Quick Links