statuskwoh Posted November 27, 2016 Share Posted November 27, 2016 Note: fairly new to houdini and vex, so if this is super obvious I apologize. google-fu has been failing me. Also, I haven't scripted/coded for awhile, so I may also be making obvious mistakes there. I am trying to setup a primitive wrangle that goes over geo I'm setting up for a constraint network. I'm trying to make sure I only have 1 constraint per any set of 2 objects. The object names are on the point as name attributes. I'm able to go through, grab the point names just fine. My intention was to add the point names together to create two strings pointAname+pointBname and pointBname+pointAname. See if either of those combinations existed in an array. If no, add them to the array, if yes delete theprimitive. What I have so far is: int points[] = primpoints(0,@primnum); int successVar; string curValues[]; string names = pointattrib(0,"name", points[0], successVar)+pointattrib(0,"name", points[1], successVar); string rnames = pointattrib(0,"name", points[1], successVar)+pointattrib(0,"name", points[0], successVar); int moveOn = 0; foreach(string checkName; curValues){ if (moveOn == 1) break; if (checkName == names || checkName == rnames) { removeprim(0,@primnum,1); moveOn = 1; } } if (moveOn == 1){ append(curValues, names); append(curValues, rnames); moveOn = 0; } else moveOn = 0; However, it doesn't seem like the array persists as it runs over the primitives. I tried using an attribute on another created piece of geo to store it, but it looks like VEX doesn't set attributes until the full wrangle is run. Is there a way to have an array persist throughout a wrangle? Should I be approaching this another way? Am I making a dumb mistake? Quote Link to comment Share on other sites More sharing options...
f1480187 Posted November 27, 2016 Share Posted November 27, 2016 Are you trying to accomplish something like this? constraint_name.hipnc Quote Link to comment Share on other sites More sharing options...
statuskwoh Posted November 28, 2016 Author Share Posted November 28, 2016 Not exactly... I'm trying to take a collection of lines and remove them if their two point names are the same as another line's two point names. So in your example if there were 3 lines that were p1_p3, I'd want to run a wrangle that makes it so I only have 1. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted November 28, 2016 Share Posted November 28, 2016 (edited) Try to add Fuse and then PolyDoctor with Pair Overlaps turned on. fix_duplicates.hipnc Edited November 28, 2016 by f1480187 Quote Link to comment Share on other sites More sharing options...
statuskwoh Posted November 28, 2016 Author Share Posted November 28, 2016 Tried your suggestion. It really reduces the # of constraints in the use case I'm thinking of. I've attached a file that should hopefully demonstrate better what I'm trying to do. example consstraints.hipnc Quote Link to comment Share on other sites More sharing options...
f1480187 Posted November 28, 2016 Share Posted November 28, 2016 (edited) Oh, now I see what you mean. You don't have overlaps at all and just want to leave single constraint between pieces. You need to sort names in wrangle to avoid two possible variants of same constraint name. Then use for-each per name and blast everything except single prim. I would prefer to set point position to it's corresponding piece center. In this case you will get many overlaps and can use Fuse and PolyDoctor technique. Constraints will be placed better. constraint_from_scatter.hipnc Edited November 28, 2016 by f1480187 Quote Link to comment Share on other sites More sharing options...
statuskwoh Posted November 28, 2016 Author Share Posted November 28, 2016 Awesome, the sort and for-each-name blast is perfect for what I was looking for. Out of curiousity, the fuse-polydoctor technique looks like it ends up with a similar result from a connect-adjacent-pieces using adjacent points from surface applied to the original geometry merge. Is there and advantage to the fuse/polydoctor technique? or just different ways to get to the same spot. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted November 28, 2016 Share Posted November 28, 2016 You may input for-each result into Attribute Copy and delete fuse-doctor stuff. Same ways of getting similar result. CAP will give you even better result, if you know how to distinguish inner and outer constraints. Using inside surface may help, I like to manage cluster attribute, since it is useful anyway. conadj_constraints.hipnc 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.