pusat
Is it a secret how the replacement feature will work? Possibly using @attributeName in parameter fields? I always found attrib variables cumbersome and it's not propagated everywhere in the software.
That is an idea that I think may be the solution, but I'm not going to commit to anything until we see what works.
jlait
My test with addattribute:: vs bind export and 25MPoints suggests at least a 3x faster for the bind export.
I am using a hotkey for Bind VOP and other common VOPs. I set the Export parameter to When the Input Is Connected. I use this for both getting and setting attributes. Would this be slower than using Bind and Bind Export separately which sets Export parameter to Never for Bind?
I do this so that I can only use 1 hotkey instead of 2.
Bind Export puts down a Bind VOP and sets that to When Input Connected. So your workflow will create the same set of nodes as doing a Bind Export, so there is no difference in behaviour.
jlait
Do note that the value for the add attribute is the default for the attribute, not the per-point value.
What's the best way to set a default attribute value in Attrib VOP and AttribWrangle?
There were 2 issues I always encountered in H13:
1. Having to set up default attribute values using AttribCreate before using an AttribWrangle.
2. Having to create a new attribute using AttribCreate before using an AttribWrangle to set attribute values using setpointattrib, etc (Detail mode).
What are the best practices to do these in H14?
Did the attribute exist before?
With AttribWrangle, if you don't need to change the default of an existing attribute, but just want to ensure the attribute gets your default if it is created, you can use the prototyping to define your @ binding. This is possible in 13.0 as well.
float @mass = 1;
int @id = -1;
The prototype isn't to be confused with an assignment (which it sadly looks like); this in an attribwrangle will not change the mass value or id of the incoming particles. It will just ensure that if the attribute did not exist, its default will be set to 1 and -1 respectively, and that will then be the default you get.
As an added bonus, if you prototype variables you can just refer to them as @mass and @id without worrying about the f or i prefixes, since you have expressly determined the type.
The AttribWrangle in 14.0 has an option for “Enforce Prototypes”. This requires all @ bindings to have a prototype (even implicit ones!) which is very useful if you are making very long pieces of code and are afraid you'll type @nunpt by accident and not be able to find your typo.
If the attribute already exists and you want to change its prototype, in 14.0 you can use addattrib()
addattrib(0, ‘point’, ‘mass’, 1.0f);
addattrib(0, ‘point’, ‘id’, -1);
Note that the type is inferred by the default value, so you must do 1.0, not 1, or it might decide on making mass an integer attribute.
As for VOPs in 14? The Add Attribute VOP is the way to go and invokes the above addattrib() code. Attached is an example of changing the default and how it affects newly merged points.