WLVL Posted May 10, 2016 Share Posted May 10, 2016 Hello Odforce, i have several curves made of 1 prim every 2 points. Each curve is identified by an id attribute. I'd like to have only one primitive per curve. I tried the join SOP for each id without success. Example hip attached. thanks for helping multiprim_reduce.hip Quote Link to comment Share on other sites More sharing options...
Maurits Posted May 10, 2016 Share Posted May 10, 2016 As I was not completly sure of what you wanted as result here are 2 things you can try. First you could change your first addvertex from addvertex(0, new_prim, @ptnum); to addvertex(0, new_prim, new_pt-1); and change the start value of i to 1. This will create a new primitive with the newly created point and the previous created point instead always using the same starting point. A second option is to change the order of your vex to this. int new_prim = addprim(0, "polyline"); addvertex(0, new_prim, 0); for(int i=1; i<5; i++){ vector newP = @P + {1,1,0}*i; int new_pt = addpoint(0, newP); addvertex(0, new_prim, new_pt); } This will create a single curve containing all points from 0 to 5. Hope one of these if what you're looking for. Quote Link to comment Share on other sites More sharing options...
mestela Posted May 10, 2016 Share Posted May 10, 2016 like this? attrib promote (demote I guess) @id from prim to points add sop, 'delete geometry but keep the points' add sop again, polygons tab, by group, by attribute, 'id' ( you can combine the add sop operations in one sop, I just did it in 2 steps to make it clear) multiprim_reduce_fix.hipnc Quote Link to comment Share on other sites More sharing options...
WLVL Posted May 10, 2016 Author Share Posted May 10, 2016 thanks for helping. Maybe i oversimplified the example hip. attached you will find the geometry i am working with. It's a geo created throught a space colonization algorithm, for no branched_structure.193.bgeo.sc Quote Link to comment Share on other sites More sharing options...
WLVL Posted May 10, 2016 Author Share Posted May 10, 2016 ... i can't modify the algorhitm at this time, i will need a "post" solution. so maurits's option are not an option unluckily. mestela's technique is nice but it doesn't support the branched structure, for what i experienced. i'd like to have one prim for each primchunk ( = my id attribute in the example file). Quote Link to comment Share on other sites More sharing options...
WLVL Posted May 10, 2016 Author Share Posted May 10, 2016 ps. sorry for the mistyping, editing the post doesn't seem to work for me. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted May 10, 2016 Share Posted May 10, 2016 I have a simple space colonization with post-solving setup. It may be a bit unclear what is going on inside loop without digging in it, but you may visualize attributes and see if they are what you need, then try to make your own version, or just grow a new tree with same look. spacecol.hipnc 2 Quote Link to comment Share on other sites More sharing options...
WLVL Posted May 10, 2016 Author Share Posted May 10, 2016 Thanks F1! Ill check it out! Quote Link to comment Share on other sites More sharing options...
WLVL Posted May 11, 2016 Author Share Posted May 11, 2016 I found the piece of code that i was looking for to modify the algorithm in the creation stage. I asked for a "post" solution at first because i knew some side fx would come along, but now i got everything under control. My code generates one prim at each iteration, the advantage of this approach is that i can separate the various branches in chunks after the creation stage. That's what i do using a FuseSOP set to Unique, acting only on a group of points ("primchunk_node" group). This primchunks are used later for the "flip/unfold effect". F1 code is much better optimized since it creates only one primitive per branch. But in this way i can't separate them afterwards, or at least not with the FuseSOP/Unique approach. I modified the code to create one prim also for each primchunk_node. The only downside is that while tweaking the unfold effect, if i want to change the primchunk distribution i have to re-run the solver. Thanks for helping once again! ///Original - Primchunk selection after solver int new_pt = addpoint(0, newP); int new_prim = addprim(0, "polyline"); addvertex(0, new_prim, @ptnum); addvertex(0, new_prim, new_pt); ///F1's - Primchunk selection in solver int new_pt = addpoint(0, newP); if (neighbourcount(0, @ptnum) == 1 && !@group_primchunk_node ) { // Add new point to existing polyline. int new_prim = pointprims(0, @ptnum)[0]; addvertex(0, new_prim, @ptnum);//addded addvertex(0, new_prim, new_pt); } else { // Create new generation. Seed case + branching nodes + primchunk nodes int new_prim = addprim(0, "polyline"); addvertex(0, new_prim, @ptnum); addvertex(0, new_prim, new_pt); int old_prim = pointprims(0, @ptnum)[0]; int new_branch = prim(0, "branch", old_prim) + 1; setprimattrib(0, "branch", new_prim, new_branch); Attached you find the project im working on, I started from a already done space colonization algorithm. I customized it and worked mainly on the post solver effects to randomize growth speed and other attributes, and on the unfold effect. I will publish a cleaner network, when ill be done! If you have any question feel free to ask space_colonizer_v11.hip 3 Quote Link to comment Share on other sites More sharing options...
f1480187 Posted May 11, 2016 Share Posted May 11, 2016 In case you will ever face the problem of splitting polylines onto segments, use a new Convert Line node created for such tasks. It is also possible with PolyCut and Carve. 1 Quote Link to comment Share on other sites More sharing options...
WLVL Posted May 15, 2016 Author Share Posted May 15, 2016 ok i found that using PolyCut instead of the Fuse/unique solved the problem. So F1 code + separation post solver. Convert line doesn't keep attributes, but is definitely useful in other situation. thanks again Quote Link to comment Share on other sites More sharing options...
WLVL Posted April 8, 2018 Author Share Posted April 8, 2018 Hi F1! I am back on this How should I modify the above code to create only one single primitive? At the moment is creating one new primitive each time there is a branching. Is it possible to just keep adding the points to the first created primitive? I have tried to modify the conditions, addprim or primpoint function but didn't find a solution. Thanks in advance Quote Link to comment Share on other sites More sharing options...
anim Posted April 8, 2018 Share Posted April 8, 2018 a poly primitive can't branch you can however try appending PolyPath SOP to minimize number of primitives your geo is composed of 1 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.