Jump to content

prim expression for source volume activation


tagosaku

Recommended Posts

Hi, I am looking for expression to automatically activate source volume node in DOP by input object(VDB, houdiniSDF). This is because sim is broken, if the sourceVolume set to collision but there is no SDF primitive.
 
my idea is that the inside of the node, sourcevolume > SOP solver(source_density)>objectMerge(fetch_density). After this node, I add primitiveWrangle:

if(@name == "density" || @name == "surface")
f@activeSwitch =1;
 
then I made float parameter(activation), and paste expression.
prim(".", "activeSwitch", 0)
 
After that, I plan to paste the parameter value to sourcevolume>activation. Then it should automatically set activation ON/OFF.

The wrangleVEX is working but prim's expression is not working. How can I fix it??

activation.JPG

Link to comment
Share on other sites

You didn't specify primitive number argument. VEX and HScript Expressions syntax are different.

Another options:

1. Use this expression in-place with dot replaced by the path to the Wrangle, without creating an extra-parameter on the Wrangle.

2. Don't create Wrangle. Check for the string "name" attribute in-place using prims() function.

You can't use "foo" == "foo", it only works for numbers in HScript Expressions. You need to use strcmp(). It returns zero if strings are equal and non-zero if not:

(strcmp(prims("/path/to/operator", 0, "name"), "density") == 0)  ||  (strcmp(prims("/path/to/operator", 0, "name"), "surface") == 0)

Sometimes, you can encounter an elegant uses:

  • "!strcmp(x, y)" instead of "strcmp(x, y) == 0" for true check;
  • "!!strcmp(x, y)" instead of "strcmp(x, y) != 0" for false check.

prims_and_strcmp.hipnc

Edited by f1480187
correct prims syntax
Link to comment
Share on other sites

actually code should be :

(strcmp(prim("/path/to/operator", 0, "name", 0), "density") == 0)  ||  (strcmp(prim("/path/to/operator", 0, "name", 0), "surface") == 0)

However, this method won't work because prim does not return density name but will return actual density value. I need to figure out different way.

Edited by tagosaku
Link to comment
Share on other sites

VEX allows to define two functions with same name returning different types, but HScript Expressions not. There is a string-returning alternative ended with s for functions where string result can be expected alongside with floats:

Common: chs, ifs, stamps
Attributes: points, prims, vertexs, details
Other: pythonexprs, evals, propertys, copmetas, dopfields, dopoptions, iprquerys

Edited by f1480187
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...