Jump to content

Import array with wrangle


Recommended Posts

There are some problems in your build_array. Here is code as I would correct it to remove syntax and type casting errors.
 

float @near_array[];
float search_rad  = ch("max_rad");
int max_points  = int(ch("max_points"));
int success;        // Used as a flag to determine if the function returned a valid value.
 
int handle = pcopen(1, "P", @P, search_rad, max_points);
int i = 0;
while( pciterate(handle) ) {
    float result = pcimport(handle, "point.number", success);
    if (success) {
        @near_array[i] = result;
        i += 1;
    }
}

Once you have created the attribute it will exist downstream in the network (middle click on node to check). There is nothing special to do to import it. Simply reference the attribute in another wrangle downstream.

printf("%s\n",@near_array);
Edited by Atom
Link to comment
Share on other sites

you should refer to it as:

i[]@near_array

so for accessing existing one from first input you will use:

printf("%s\n",i[]@near_array);

to create one that just contains point numbers as in your file, you can use pcfind() function directly

float search_rad  = chf("max_rad");
int max_points  = chi("max_points");
i[]@near_array = pcfind(1, "P", @P, search_rad, max_points);
Edited by anim
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...