logix1390 Posted October 20, 2018 Share Posted October 20, 2018 Hello, I am trying to group points procedurally 3 at a time. I have a simple line and I am trying to apply if statement logic to it. It works but it is not fully procedural since I would have to keep copy and pasting the if statement in order to group more points. Is there a more procedural way to do this using vex or perhaps another way ? Any input would be appreciated. I will attach a photo and a scene file to show you what I am talking about. Thank you! group_by_3_procedurally.hipnc Quote Link to comment Share on other sites More sharing options...
3dome Posted October 20, 2018 Share Posted October 20, 2018 (edited) use this in a pointwrangle i@grp = @ptnum/3; and then use a partition SOP, entity set to points with the following rule group_`@grp` Edited October 20, 2018 by 3dome Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted October 20, 2018 Share Posted October 20, 2018 In a point wrangle: int points = chi('points'); string name = chs('name'); string segment = itoa(@ptnum / points); string group_name = concat(name, segment); setpointgroup(0, group_name, @ptnum, 1, 'set'); Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted October 20, 2018 Share Posted October 20, 2018 (edited) Same thing in a python node: node = hou.pwd() geo = node.geometry() name = node.evalParm('name') points = node.evalParm('points') for point in geo.points(): segment = point.number() / points group_name = name + str(segment) groups = [g.name() for g in geo.pointGroups()] if group_name not in groups: grp = geo.createPointGroup(group_name) grp.add(point) Edited October 20, 2018 by konstantin magnus Quote Link to comment Share on other sites More sharing options...
logix1390 Posted October 20, 2018 Author Share Posted October 20, 2018 @3dome Thank you 3dome this works !! @konstantin magnus Amazing stuff konstantin, thank you for both methods. works perfectly!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.