My question about Point Wrangle array...

   3555   6   1
User Avatar
Member
407 posts
Joined: Aug. 2015
Offline
Hi;

I would like to get the @ptnum attribute from a geometry's points and put them in an array, using point wrangle.
Here is my codes but it doesn't works:
i[]@pts = point(0,"ptnum",@ptnum);

Here is output :
Edited by Masoud - Jan. 26, 2018 15:34:49

Attachments:
1.JPG (11.0 KB)

Masoud Saadatmand (MSDVFX)
User Avatar
Member
7863 posts
Joined: Sept. 2011
Offline
That doesn't work for multiple reasons. point() is for getting a point attribute value, but you have specified ‘ptnum’ as the name of the attribute, which wouldn't normally exist, unless you had created it beforehand. point() returns a type based on the type of the left hand side, which in this case is int[]. Since point found no matching attribute, it returns the null value, which for arrays, is an empty array.

If you want an array containing all of the points, you would need to construct a loop, bounded by the number of points in the input, and each iteration append the iterator value to the array.

int @pts[];

for(int i=0; i<@numelem; i++) {
    append(@pts,i);
}

Edit:

or if you are lazy:
i[]@pts = expandpointgroup(0,"");
Edited by jsmack - Jan. 26, 2018 17:19:52
User Avatar
Member
407 posts
Joined: Aug. 2015
Offline
Hi jsmack;
When I use your code (I mean "i@pts = expandpointgroup(0,“”);") the result is like this image, and this is not what I want:
Edited by Masoud - Jan. 27, 2018 05:27:40

Attachments:
11.JPG (73.2 KB)

Masoud Saadatmand (MSDVFX)
User Avatar
Member
407 posts
Joined: Aug. 2015
Offline
I know that I can put an “attribute create” before “Point Wrangle” to create a new point attribute and fill it with @ptnum.
How could I do same thing in “Point Wrangle”?

I tried to use this code:
addpointattrib(0,"pts",@ptnum);
But it doesn't work…
Masoud Saadatmand (MSDVFX)
User Avatar
Member
480 posts
Joined: July 2005
Offline
Hi,

Is one of these examples coming close to what you want to achieve?

Attachments:
ArrayAttr.hipnc (71.2 KB)

User Avatar
Member
407 posts
Joined: Aug. 2015
Offline
Thank you Aizatulin;

I found these codes in your post that helped me:
setpointattrib(0, 'pts', @ptnum, @ptnum);
Masoud Saadatmand (MSDVFX)
User Avatar
Member
8647 posts
Joined: July 2007
Online
if storing the @ptnum value in an attribute is all you need you can just use
i@pts = @ptnum;
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links