Jump to content

vex function to read all the attributes of a point?


pelos

Recommended Posts

string pointattribs[] = detailintrinsic(0,"pointattributes");

this gives you a list of pointattribs that allready exist, the problem is to create the attributes on your new point. The problem is that you dont know the attribtype (float,string,vector). You can somehow use attribsize combined with pointattribtype to check what it is. It becomes alot of if statements if you want it to be rock solid. Personaly i have ignored some types to make it simpler.

void transferPoint(int input;int fromPoint ;int toPoint){ 
    string pointattribs[] = detailintrinsic(input,"pointattributes");
    foreach(string name;pointattribs){    
        int found = 0;
        int size = attribsize(input,"point",name);
        int type = pointattribtype(input,name);
        
        if(type == 0){
            int attrib = pointattrib(input,name,fromPoint,found);
            setpointattrib(0,name,toPoint,attrib,"set");
            }  
            
        if(type == 1 && size == 1){
            float attrib = pointattrib(input,name,fromPoint,found);
            setpointattrib(0,name,toPoint,attrib,"set");
            }    
        
        if(type == 2){
            string attrib = pointattrib(input,name,fromPoint,found);
            setpointattrib(0,name,toPoint,attrib,"set");
            }       
                
        if(type == 1 && size >= 2){
            if(size == 4){
                vector4 attrib = pointattrib(input,name,fromPoint,found);
                setpointattrib(0,name,toPoint,attrib,"set");
                }
            else{
                vector attrib = pointattrib(input,name,fromPoint,found);
                setpointattrib(0,name,toPoint,attrib,"set");
                }
            }            
        }
}

 

  • Thanks 1
Link to comment
Share on other sites

mmm  sometimes i think the vex datatypes are very limited, i was expecting to get a list of classes such

[

pointclass1,

pointclass2,

]

that later on with .notation i could get properties like the size, type, name etc..


(something i like a to work with python more than vex)

thanks for sharing the snippet, i appreciate it =)

Link to comment
Share on other sites

If you want to transfer just from 1 point you can provide that point as a reference for addpoint() function

To get interpolated attributes between 2 or more points you can also just use Attribute Interpolate SOP after your wrangle to do the job based on arrays of point numbers and weights that you provide

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