Jump to content

Vex: for loop on point attributes and promote groups


Recommended Posts

I'm trying to turn this into a for loop in Vex, for each point attribute:

Step 1: to take all the points that have >0 and group them, name of the group is the name of the point attribute.

if(@pointattribute1 > 0) @group_pointattribute1 = 1;

if(@pointattribute2 > 0) @group_pointattribute2 = 1;

if(@pointattribute3 > 0) @group_pointattribute3 = 1;

...

Step 2: Promote each of these created point groups to primitive groups

 

Link to comment
Share on other sites

string ptattribs[] = detailintrinsic(0, "pointattributes");
foreach (string ptattrib; ptattribs){
    int size = pointattribsize(0, ptattrib);
    int type = pointattribtype(0, ptattrib);
    if (size == 1 && type < 2){
        float value = point(0, ptattrib, @ptnum);
        if (value > 0){
            setpointgroup(0, ptattrib, @ptnum, 1);
        }
    }
}

or if you want to be able to specify which attributes  :

string attribmask = chs("attribmask"); 
string ptattribs[] = detailintrinsic(0, "pointattributes");
foreach (string ptattrib; ptattribs){
    if (match(attribmask, ptattrib) ){
        int size = pointattribsize(0, ptattrib);
        int type = pointattribtype(0, ptattrib);
        if (size == 1 && type < 2){
            float value = point(0, ptattrib, @ptnum);
            if (value > 0){
                setpointgroup(0, ptattrib, @ptnum, 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...