Jump to content

setpointattrib after addpoint in detail wrangle


AntoineSfx

Recommended Posts

Given two points in input, why doesn't this work:

in point wrangle / detail :

setpointattrib(0, "order", 0, 0 , "set");
setpointattrib(0, "order", 1, 10 , "set");
for(int i=1;i<10;i++) {
float f= (float)i / 10;
int a=addpoint(0, lerp(point(0,"P",0), point(0,"P",1), f));
setpointattrib(0, "order", a, f, "set");
}

 

I'm trying to add points, and keep track of when it was added in the loop

The setpointattrib in the loop has no effect.

I assume that I can't setpointattrib until after the whole node is cooked ?

 

Link to comment
Share on other sites

If I understand correctly, this should give you the behavior you want. (file attached)

setpointattrib(0, "order", 0, 0 , "set");
setpointattrib(0, "order", 1, 10 , "set");

for(int i = 1; i < 10; i++) {
    int order = i;
    float pos = (float)i/10;
    int newPoint = addpoint(0, lerp(point(0,"P",0), point(0,"P",1), pos));
    setpointattrib(0, "order", newPoint, order, "set");
}

 

setpointattrib.hip

setpointattrib.PNG

Link to comment
Share on other sites

So I got this working:

here is the fix:

setpointattrib(0, "order", 0, 0. , "set");

The type of the order attribute is determined  by the type of the fourth argument, when called first on order (creation of the attribute)

Here I added a point after the 0 to force the parser to see it as a float.

After that the attribute is created as a float, and everything makes sense.

Alternatively, passing a float variable as the fourth argument will work too.

 

Edit..

 

float f=0;
setpointattrib(0, "order", 0, f , "set");
setpointattrib(0, "order", 1, 1.0, "set");  <<<--- 1.0
 

works as expected

 

float f=0;
setpointattrib(0, "order", 0, f , "set");
setpointattrib(0, "order", 1, 1, "set");   <<< --- 1
 

point #1 has order set to 0  when the argument is an int, any integer really..

Edited by AntoineSfx
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...