Creating custom groups in Python but its reordering my list

   1841   2   0
User Avatar
Member
16 posts
Joined: June 2017
Offline
Hi

I am creating 2 custom groups using python. They have to be a very specific order and so I am using a for loop to enter each list of points into these groups.

something like this

testA = geo.createPointGroup("groupA")
testB = geo.createPointGroup("groupB")

my_points_listA = [ 11, 14, 6, 4, 2, 1 ]
my_points_listB = [ 18, 6, 98, 12, 54, 65 ]

for eachpoint in my_points_listA:
    testA.add(node.geometry().point(eachpoint))

for eachpoint in my_points_listB:
    testB.add(node.geometry().point(eachpoint))

I am finding that when I look at the lists in the groups.
testA and testB, they are not in the same order i inputted the numbers in. I need them to be in the same order, that the loop went thru.

Does anybody know how to do this in python node (houdini)?

Thanks
Imran
Edited by im_a - June 27, 2019 16:11:50
User Avatar
Member
16 posts
Joined: June 2017
Offline
Hi

So I am trying something different now but need help in that too.

instead of changing it to points and grouping it, I am making it a int array using this command

test_num_A = [ 1, 3, 5, 6, 23, 4, 76 ]
geo.addArrayAttrib(hou.attribType.Global, 'arraytest', hou.attribData.Int, 1)
geo.setGlobalAttribValue("arraytest", test_num_A)

So this now shows up in my Geometry spreadsheet under detail. I tried using a Attribute Promote Node and then group the new points “testPoints” but that gives me this warning.

Warning: Bad pattern specified testPoints. Possible problems: Number out of range or a syntax error. Valid Syntax: [!]start[-end][:step][,increment] examples: !1-10:2,3 1-10:2 * 0-5 1
So i guess I am asking is there a way to make the int array from detail into a point group.

Thanks
Imran
Edited by im_a - June 27, 2019 16:13:44
User Avatar
Member
16 posts
Joined: June 2017
Offline
So i figured out how to use a Attribute wrangle

int ptarrayA[] =  detail(0, 'arraytest');

foreach(int pt;ptarrayA)
{
    setpointgroup(0, "grpA", pt, 1);
}

but the new group of points it created still looks like its reordering and I don't want that.

So I am going to try to just take the string (int array) and directly pasting into the “base group” field…not sure how to do this. if someone has a example in python or vex that would be great.

Thanks
Imran
Edited by im_a - June 27, 2019 17:37:44
  • Quick Links