Jump to content

Recommended Posts

hi,

 

a simpleton question... I am importing particles from Real Flow, and want to group then delete every 10th particle or so, with Group By Range select 1 of 6 etc works fine except it uses PT, and this gets very chaotic as this order changes every frame.

 

So i have been trying Attrib Rename,  which technically works, i see the data is renamed to PT, but the Group is still picking by the original PT, i am not sure how to force the use of 'id' on group by expression....or if i need some extra tweaking somewhere else?

 

 

thanks in advance

 

 

Octavio

 

 

 

Share this post


Link to post
Share on other sites

well i am not sure i have understand 100%, but basically :

- you have a RF sim with n particle and you want to get the same sim but with less point for ex n*0.1 (10%)

- you can't isolate particle cause you have id that aren't constant

 

so to fix this you have to find a way to build a constant id for each particle of your sim if you want to avoid flickering ,

i think one way would be to use sop solver to do that.

 

if you post a hip it will be easier to help you ,

Edited by sebkaine

Share this post


Link to post
Share on other sites

thanks! it does the trick, but i would like to know why i cant access or change id to PT or group by id directly.

Share this post


Link to post
Share on other sites

hi Sebkaine,

 

yes i got a sim from RF, each particle comes out with an id, that is constant, but houdini uses PT, which is not constant, so i tired to rename id to PT, with no luck

Share this post


Link to post
Share on other sites

i modified ChristopherC wrangle a bit

 

if (rand(@id) < 0.95) {
    removepoint(geoself(), @ptnum);
}
 
so i can delete as a percent, a good result but still curious on the renaming of attributes.

Share this post


Link to post
Share on other sites

You can group by id if you want! See the `method_2` from attached scene. I only mentioned the previous solution because I found it simpler.

 

As with renaming the `id` attribute to `PT`, this won't work. When you say `PT`, you're actually referring to the variable `$PT` which points to an internal attribute holding the point number. Creating an attribute `PT` won't override the point number attribute, nor will it change what the variable `$PT`  is pointing to. Also, as far as I know, the point number is read-only so you can't change its value.

 

delete_by_id.hipnc

Share this post


Link to post
Share on other sites

well if you can load a RF .bin and access to a constant attribute then i think it will be far more easy than having to rebuild a constant id.

 

plug a point wrangle after you reader

 

@Cd    = {1,1,1};

@rand = rand(@reaflowID);

if (@rand < 0.1) {

       @Cd = {0,0,0};

}

 

then after the point wrangle you delete by expression $CR == 0;

 

and it should work or maybe i am missing something strategic here ! :)

Edited by sebkaine

Share this post


Link to post
Share on other sites

 

 removepoint(geoself(), @ptnum);

 

 

Actually i didn't know that you can delete geometry with VEX ! Thanks for this ! :)

Share this post


Link to post
Share on other sites

For information, it's also possible to directly modify groups in VEX by using functions such as `setpointgroup`—this can become handy when a group membership depends on slightly more involved conditions.

Share this post


Link to post
Share on other sites

I can't get this to work...

 

the @realflowId is called @id but even with that i wont get random colors.....doh! one second...

 

@Cd    = {1,1,1};
@rand = rand(@id);
if (@rand < 0.5) {
       @Cd = {0,0,0};
}
 
boomshakalaka!    B)
 
thanks guys!!

Share this post


Link to post
Share on other sites

Even though this code is working, it is a bit suboptimal since `@rand` will create an attribute named `rand`, and that's probably not what you want but if you plan on reusing it later on? Just define a simple float variable instead or put `rand(@id)` directly within the `if` statement.

 
@Cd = {1, 1, 1};
float rand = rand(@id);
if (rand < ch("prob")) {
    @Cd = {0, 0, 0};
}
 

 

Just trying to share good coding practices here, but whatever works for you! :)

Edited by ChristopherC
  • Like 1

Share this post


Link to post
Share on other sites

muchas gracias guys...

 

I am having now issues with the deleting side of things....using a group SOP by expression  $CR == 0, works, but the the Blast, kind of wont refresh the selection

Share this post


Link to post
Share on other sites

well you don't need a group Octavio.

 

you create your wrangle that modify @Cd

you plug a delete node just after => delete by expression $CR == 0

Share this post


Link to post
Share on other sites

As long as you are using a wrangle it's much better to do the deletion inside the wrangle too, way more efficient. 

You can use an if statement to check your condition and then use removepoint(0,@ptnum). 

  • Like 1

Share this post


Link to post
Share on other sites

cool, will try that ! 

 

 

...one laaaast thing, I am now copying spheres to the particles, and i am again having to deal with the PT changing each frame and using Stamp fit01(rand($PT),0.02,0.05) , i get the spheres changing size each frame as they get assigned a new particle each time..not very nice bubbles!

 

So i am again trying to find out why the real flow particle ID can't be accessed by more vanilla sop's.

 

I don't mind getting to point wrangle but if there was an 'easier' or less code-y way of doing that? even if it is at the expense of performance,,as i am only dealing with a few thousand particles.

 

thanks,

 

O/.

Share this post


Link to post
Share on other sites

[...] Also, as far as I know, the point number is read-only so you can't change its value.

 

sort node, by attribute, id - doesn't this work ?

Share this post


Link to post
Share on other sites

What I meant is that you can't manually assign it like you would do with others attributes by doing something like `@ptnum = 123;`. But yes, sorting the points does the trick, thanks for mentioning it!

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×