Jump to content

foreach -setpointattrib


logix1390

Recommended Posts

hello. I am trying to set color to the points in the array that the nearpoints function found. I am trying to set it in a foreach loop. However, it is not working for some strange reason. I'm sure im going wrong somewhere. Here it is:

i[]@ptarray =  nearpoints(1, v@P, chf("maxDist"), 133);

foreach(int pt; @ptarray){
    setpointattrib(0, "Cd", pt, {1,0,0});
}

 

foreachloop_setpointattrib.hipnc

Link to comment
Share on other sites

The logic doesn't work:
nearpoints() will give you point numbers from the second input, they have nothing to do with the first input point numbers.
Here are 2 simple ways of doing what you want, just testing if you get at least one point within a search radius.
 

// 1) nearpoint 
int pt = nearpoint(1,@P,chf("maxDist"));
if(pt!=-1)@Cd={1,0,0};

// 2) pointcloud
if(pcnumfound(pcopen(1,"P",@P,chf("maxDist"),1))>0)@Cd={1,0,0};

 

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