Jump to content

It seems that point wrangle doesn't execute codes line by line, right?


Recommended Posts

Hi Guys;

In point wrangle SOP, when I select some points (in group tab) to apply the codes, the last selected point always overwrite the other ones. It seems that point wrangle doesn't execute codes line by line, right?

When I apply codes to points, one by one  (I mean a point wrangle for each selected point) it works fine.

Please take a look at my files (to visualize it, I applied my attribute to P.y ) :

A.jpg

B.jpg

Attribute Ramp_02.hip

Link to comment
Share on other sites

The point wrangle runs once for every point, in order. So, your foreach is redundant.

The current point number is i@ptnum (an integer), the current points position is v@P (a vector), the current points floating point attribute named blahblah is f@blahblah.

If you want to set the y value in the P you can
 

float var = rand(i@ptnum);
v@P = set(v@P.x, var, v@P.z);

 

Edited by kleer001
clarity
Link to comment
Share on other sites

functions that write to not current point like setpointattrib() or create new geometry like addpoint() etc. Are queued in point order and executed on a single thread after all multithreaded code 

However that doesn't really matter in your case as much as the fact that in the single wrangle point() function will never read the updated "y" attribute, it will always read it from the input from so that's why 2 wrangles work for you

You can always flip your code to be other way around and therefore more multithread friendly

Like make all points look within the certain radius for points 17 and 306 and in the loop of found points they will change @y accordingly,  as each point will only change its own value it'll be able to read it back using @y within the for look as expected 

  • Thanks 1
Link to comment
Share on other sites

something like this:

vector P = @P;
string ptgrp = "17 306";
float radius = chf("MaxDist");
int pts[] = nearpoints(0, ptgrp, P, radius);

foreach(int pt; pts)
{
    vector ptP = point(0, "P", pt);
    float dist = distance(ptP, P);
    float invdist = fit( dist , 0, radius, 2, f@y);  
    f@y = invdist;
}

Attribute Ramp_03_fix.hip

  • Thanks 1
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...