Jump to content

forloop in detail


andmotion

Recommended Posts

Hi there!!!!!

It must not be that much complicated but I dont know how to sort it out atm:(

I have a grid which I scattered with bunch of points and then add the color to them (1,0,0).

Then I put detail wrangler and wrote this in it:

int nbrs[] = nearpoints(0,@P,chf("radius"),10);

//i[]@a = nbrs;

foreach(int nb;nbrs){
   
       //v@c = point(0,"Cd",nb);
    }

How can I get access to the Cd inside the loop so I can change the Cd just for the nb points?

Thanks for any clues:)

Link to comment
Share on other sites

why Detail Wrangle?

there is no @P in Detail Wrangle, so you are just searching points around 0,0,0

v@c would assign the value to detail attribute c so you probably ant to use setpointattrib() 

but it seems that what you are doing would be more efficient in Point Wrangle, can you describe what are you actually trying to do?

Link to comment
Share on other sites

Actualy there is a @P in the detail wrangle, its the centroid of your geometry. Can be useful in a foreach sop for example. But i dont think it allways have been like that. 

so as Anim says, use setpointattrib.

vector color = point(0,"Cd",nb);
vector new_color = ??;
setpointattrib(0,"Cd",nb,new_color,"set");

 

Link to comment
Share on other sites

16 hours ago, anim said:

why Detail Wrangle?

there is no @P in Detail Wrangle, so you are just searching points around 0,0,0

v@c would assign the value to detail attribute c so you probably ant to use setpointattrib() 

but it seems that what you are doing would be more efficient in Point Wrangle, can you describe what are you actually trying to do?

Hey Anim,

You are absolutely right that I could run something like this in Point wrangle and I would get the result :

int sample = nearpoint(1,@P);
vector pos = point(1,"P",sample);

float dist = distance(@P,pos);

if(dist<chf("treshold")){
    @Cd = set(0,1,0);
}

In this example I added single point in to 1 wrangle input and scattered grid into input 0.

 

Thanks

Link to comment
Share on other sites

14 hours ago, ThomasPara said:

Actualy there is a @P in the detail wrangle, its the centroid of your geometry. Can be useful in a foreach sop for example. But i dont think it allways have been like that. 

so as Anim says, use setpointattrib.


vector color = point(0,"Cd",nb);
vector new_color = ??;
setpointattrib(0,"Cd",nb,new_color,"set");

 

Hey,

Having this code :

 

int nbrs[] = nearpoints(0,@P,chf("radius"),200);

i[]@a = nbrs;
int w = @a[1];
//printf("%g",w);
foreach(int nb;nbrs){
   
       vector color = point(0,"Cd",nb);
       vector new_col = set(0,1,0);
       setpointattrib(0,"Cd",nb,new_col,"set");
       
    }

It's doing what I was aiming for. The only concern I have now about pointattributes[Cd] and pointattributes[P] in detail wrangle.....

You know when we set the groups before going into wrnagle we can access these group arrays in detail wrangle by having detailintrinsic and expandprimgroup.

How can we get access to the pointattribute[Cd] or pointattribute[P] ? They seems to me (I am most likely wrong:)) as a arrays keeping the numbers but I could not find the way how to access them and modify....

 

Thanks

Link to comment
Share on other sites

1 hour ago, ThomasPara said:

in the nearpoints function you can set a group to search through.


nearpoints(0,"group",@P,maxdist,maxpoints);

And as of now you make a vector "color" and dont use it, so its redundant, you can remove that line.

Hey Thomas:)

Thanks for you advice.

I thought but might be wrong obviously :) that I will need to get the Cd v first from the points in [] and then set new @ on them?

I cant really see the reason why to use "group" in my scenario.

My main concern is How to get access to the pointattribute[Cd] or pointattribute[P]  in the detail wrangler???

 

Thanks

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...