tagosaku Posted June 23, 2017 Share Posted June 23, 2017 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?? Quote Link to comment Share on other sites More sharing options...
f1480187 Posted June 23, 2017 Share Posted June 23, 2017 (edited) 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 June 24, 2017 by f1480187 correct prims syntax Quote Link to comment Share on other sites More sharing options...
tagosaku Posted June 24, 2017 Author Share Posted June 24, 2017 (edited) 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 June 24, 2017 by tagosaku Quote Link to comment Share on other sites More sharing options...
f1480187 Posted June 24, 2017 Share Posted June 24, 2017 (edited) My mistake, prims usage syntax should be prims(somepath, 0, "name"). Sorry for misdirection. Fixed my post and added a scene with working expressions. Edited June 24, 2017 by f1480187 Quote Link to comment Share on other sites More sharing options...
tagosaku Posted June 24, 2017 Author Share Posted June 24, 2017 Oh, I am sorry too that I just knew there are TWO expressions, "prim" and "prims" !! I completely misunderstood them. Thank you, f1, so much for providing a sample file. I am checking it out right now! Quote Link to comment Share on other sites More sharing options...
f1480187 Posted June 24, 2017 Share Posted June 24, 2017 (edited) 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 June 24, 2017 by f1480187 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.