Chris Wong

WongChunNga

About Me

Connect

LOCATION
Not Specified
WEBSITE

Houdini Skills

Availability

Not Specified

Recent Forum Posts

Merge Curve Prim if they have the same prim attributes April 7, 2022, 6:11 a.m.

//find Neightbors Prim
int prims[];
int pts[] = primpoints(0,@primnum);
foreach (int pt; pts)
{
    int pt_prims[] = pointprims(0,pt);
    if(len(pt_prims)>1)
    {
        foreach (int pt_prim; pt_prims)
        {
            if(pt_prim != @primnum)
                append(prims,pt_prim);
        }
    }
}

//Get Prim Attribute Names
string attrs[] = detailintrinsic(0,"primitiveattributes");

//Check Neighbors prim if they are Valid, Append to the "set"array
i[]@set;
append(@set,@primnum);

foreach (int prim; prims)
{
    int valid = 1;
    foreach (string attr; attrs)
    {
        int type = primattribtype(0,attr);
        if ( type == 0 ) 
        {
            //Ignore ID and Primnum, do not check
            if( attr == "prim_num" || attr == "id" )
                break;
            // Check if not the same attribute, make unvalid
            int val1 = prim(0,attr,@primnum);
            int val2 = prim(0,attr,prim);
            if ( val1 != val2 )
            {
                valid = 0;
                break;
            }
        }
    }
    if( valid == 1)
    {
        append(i@set,prim);
    }
}

foreach(int prim;i@set)
{
    string name = "G" + itoa(@primnum);
    setprimgroup(0,name,prim,1,"set");
}

the attachment is a test curve with serveral prims i need to merge if all the prim int attribute is the same(not included id and prim_num). i am almost there but dont know how to finish it....
thank you

PDG have attri promote node? add prim attri to each indx Feb. 22, 2022, 9:31 a.m.

I use multiparm to control how many prefab i would like to scatter and make a objpath to do it. it works fine. but I would like to do more, add more attribute to the mulitparm for each prefab and combine it into one input for my hda but i would not find the node able to add the prim attribute, i use geometry import to merge all the scatter prefabs to input one.i try to use add attribute option in the geometry import node, but it always add into detail attribute. if I would like to change it to import to prim attribute. all the prim got separated. and i cannot find the attribute promote nod at topnet... may I know how i can do what i want? thank you

their are only I attribute i can add when I merge all geometry to one output. Is add the merge attribute, but I would like to do it more. do anyone know python well can help me write a simple script to do attribute promote? thank youuuu