Expression for reading group indexes individually?

   5131   13   0
User Avatar
Member
210 posts
Joined: Jan. 2014
Offline
I'll try to explain what I mean:
I'm finding myself needing the distance between two points over and over again so I want to create myself a DA for this.
So I would like to store the two points I want to meassure in a gruop and append an AttribCreate SOP. The value for that AttribCreate is supposed to be the distance() expression. This expression needs the x,y,z values of both points so it would be fine if there would be some expression that lets me read out the vector for each component of the group, something like group1.P, group1.P, … and so on. Is that possible or am I thinking in a completely wrong direction?
User Avatar
Member
387 posts
Joined: Nov. 2008
Offline
Use attrib wrangle, add Blast sop before it and into Blast's Group parameter fetch two selected points (e.g. via Group SOP or directly by their numbers) and in wrangle just compute distance between them like this:

vector p0 = point(0, “P”, 0);
vector p1 = point(0, “P”, 1);
@dist = length(p0 - p1);

This code computes distance between point with index 0 and point with index 1. So if you don't want to use Blast you had to specify point indices directly.

(Or it is possible to iterate over all points, check if they are in group and if do then use them - but ingroup() vex function works in PointWrangel not in AttribWrangle))

Edited to be more specific.
Edited by - April 12, 2014 18:15:25
User Avatar
Member
210 posts
Joined: Jan. 2014
Offline
Ok, thanks so far that looks a little more straight forward then my attempt. The attribute dist gets created but no matter how far appart these points are, the details view shows me that the returned value is always 1. Is there anything else I have to take care of?

Since this is VEX shouldn't this then also be able in a VOP SOP? Just because I would like to have some practice in VOPs too.
User Avatar
Member
387 posts
Joined: Nov. 2008
Offline
Sorry, I forgot that point function takes point exactly by indicies, so in the example above it always calculates distance between points with indices 0 and 1.
So change the indices directly in vex code (third parameter in point function) or keep the code as it is and put Blast SOP before attribwrangle and set your Group parameter there. That way you isolate points.

I added example file

Attachments:
distance_between_points.hipnc (91.5 KB)

User Avatar
Member
210 posts
Joined: Jan. 2014
Offline
I'm so confused right now. I have the exact same code in my AttribWrangle SOP I prepended a group and reference that group in the AttribWrangle SOP, just like in your .hip file and now I get an even stranger result. Point 0 and 1 have a dis value of 0 all other have 1.

Attachments:
distNotWorking.hipnc (101.9 KB)

User Avatar
Member
387 posts
Joined: Nov. 2008
Offline
Sorry for confusion.
Please look at the example scene I attached.

In your scene, you need to set the Group SOP type to Points (not Primitives) and then you need to put Blast SOP with that group and Delete Nonselected before AttribWrangle so you will feed only 2 points in AttribWrangle.
User Avatar
Member
210 posts
Joined: Jan. 2014
Offline
Ah ok, I missed that my group SOP was set to prims it's working now, I appreciate
This trick with deleting the rest of the geometry and just feed in the two necessary points should work with VOP SOPs as well, shouldn't it? So I have a geometry with just two points in my VOP SOP and there is a distance VOP that takes two inputs for the two points, of course. But how do I use the two points in a VOP SOP individually? I would just like to get a bit more familiar with VOP SOPs or VOPs in general.
User Avatar
Member
387 posts
Joined: Nov. 2008
Offline
You can use Import Attribute and specify point number.
User Avatar
Member
210 posts
Joined: Jan. 2014
Offline
Well, I can specify to import an attribute, let's say P but how do I specify the P attribute of an individual point?
User Avatar
Member
606 posts
Joined: May 2007
Offline
The Import Attribute node has a “ptnum” input, which works as expected
User Avatar
Member
210 posts
Joined: Jan. 2014
Offline
WORKS!
I didn't see that input, thanks. My first working VOP SOP.
User Avatar
Member
606 posts
Joined: May 2007
Offline
Congrats

Now just drag it to the shelf and you can just press a button to insert it in any scene.
User Avatar
Member
99 posts
Joined: July 2007
Offline
eetu
Now just drag it to the shelf and you can just press a button to insert it in any scene.

that's a nice one somehow I've missed it
thanks, eetu!
User Avatar
Member
210 posts
Joined: Jan. 2014
Offline
eetu
Now just drag it to the shelf and you can just press a button to insert it in any scene.

Creating DAs is something I have to look up again. There are many things you can set up and since is my first one I'm not quite familiar with this process. Especially in regards of where to save it to. But that's probably the least problem.
  • Quick Links