probiner Posted June 10, 2018 Share Posted June 10, 2018 (edited) One thing that I miss from Python(Try / Except) or XSI ICE (First Valid) is the ability to check if some code returns errors and if so, do something else that is safer. Is there a way to access the validity of something and if not do something else? Cheers Edited June 10, 2018 by probiner Quote Link to comment Share on other sites More sharing options...
Atom Posted June 10, 2018 Share Posted June 10, 2018 Interesting..divide by zero is just zero and not an error. float m = 100; f@n = m/0; Quote Link to comment Share on other sites More sharing options...
acey195 Posted June 11, 2018 Share Posted June 11, 2018 Vex is a highly multi threaded language, I think adding try-catch/except logic would seriously slow it down. most value errors at least, will just return 0, as VEX is strongly typed. (like Atom Mentioned) Rather than crashing the node, its probably better to compare your values to 0 in some cases (and if the expected value is non-0) Quote Link to comment Share on other sites More sharing options...
probiner Posted June 11, 2018 Author Share Posted June 11, 2018 (edited) I don't have issues with division by 0 and I get you remark about optimization- I was just wondering if there was some way of doing this that I was missing.. My main issue is with variable types and functions/nodes that might break due to have a bad evaluation. and as far I as know I can't do a check on the variable type, neither create a variable with auto, so I was just checking if I can assess it another way around, by letting it fail, but do something else when it fails. Take this example, float array[] = set(value) will work for all the non-array float composites, float, vector3, vector4, matrix3, matrix4. But... But... it doesn't work with Vector2 or Matrix2. Which is an alternative route already because something like matrix + 1 doesn't work (adding 1 to each component), so I decided to flatten all out into an array of floats and iterate over them. But even that doesn't work with all types :/ float floatval = 1.23 ; float floatarray[] = set(floatval) ; f[]@floatarray = floatarray ; vector vectorval = {4,5,6} ; float vectorarray[] = set(vectorval) ; f[]@vectorarray = vectorarray ; matrix3 matrix3val = matrix3(ident()) ; float matrix3array[] = set(matrix3val) ; f[]@matrix3array = matrix3array ; vector2 vector2val = set(7,8) ; float vector2array[] = set(vector2val) ; f[]@vector2array = vector2array ; matrix2 matrix2val = set({0,1}, {2,3}) ; float matrix2array[] = set(matrix2val) ; f[]@matrix2array = matrix2array ; If I could check for variable type I could do something else for vector2 and matrix2. This because I'm trying to build overload nodes. I also don't see a way to build a function with signatures, do I need to use HDK for that? I'm all over the place, but I'm trying to find the best way to go about maximizing an operation to the maximum number of data types... Cheers Edited June 11, 2018 by probiner Quote Link to comment Share on other sites More sharing options...
ikoon Posted June 11, 2018 Share Posted June 11, 2018 (edited) Hi, you could add the missing definitions of set() and include them? But that is probably not what you want. Edit: I have tried one of the missing definitions: float[] set (vector2 input) { return array(input[0],input[1]); } Edited June 11, 2018 by ikoon Quote Link to comment Share on other sites More sharing options...
ThomasPara Posted June 11, 2018 Share Posted June 11, 2018 (edited) You could use the function "attribtype" combined with "attribsize". Attribtype will say that the variable is a vector and attribsize will say how many components the vector have. http://www.sidefx.com/docs/houdini/vex/functions/attribtype.html http://www.sidefx.com/docs/houdini/vex/functions/attribsize.html One issue that can come up is comparing a vector2 vs a vector4 Edited June 11, 2018 by ThomasPara Quote Link to comment Share on other sites More sharing options...
acey195 Posted June 11, 2018 Share Posted June 11, 2018 (edited) yeah, ok I think I see what you mean now, I would also love stuff like: setpointattrib(0, attrib, @ptnum, point(0, attrib, otherSourcePt)); to work.. (I understand its ambiguous, but some auto casting of variables mid-code-line would still be nice) The functions from Thomas are workable they will result in almost 200 lines of code to make all checks, the strongly typed way (unfortunately I cannot share the code :/ ) Edited June 11, 2018 by acey195 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.