vtrvtr Posted August 1, 2016 Share Posted August 1, 2016 (edited) Hello. I have a couple questions. Sorry if this isn't the correct section. I'm learning Houdini and although I have some experience with C, I have much more experience with Python, so I figured I would use Python instead of VEX for most things. So question one is: Is that feasible? From what I could gather you can write everything using the python library, but I'm not sure if this is correct. Is there something that python wouldn't be able or wouldn't be a smart way to do? The second question is: what would be the recommended way to translate VEX expressions to python? Pretty much all tutorials I ever saw used VEX/hscript, so I usually have to translate, which I don't mind in the slightest, but sometimes is hard to find what are exactly the equivalents. For example, right now I'm trying to copy one attribute to a newly created one using a wrangler, which in VEX goes simply as f@new_p = @old_p But I'm not sure how would it go with python Thanks Edited August 1, 2016 by vtrvtr Quote Link to comment Share on other sites More sharing options...
symek Posted August 1, 2016 Share Posted August 1, 2016 28 minutes ago, vtrvtr said: I'm learning Houdini and although I have some experience with C, I have much more experience with Python, so I figured I would use Python instead of VEX for most things. So question one is: Is that feasible? (...) It is not. 95% of cases when you want to process geometry, it is a job for VEX. Changing attributes' values, adding points, prims, manipulating vectors, etc. VEX is very well shaped to process heavy data, forcing Python for doing this is ultimately waste of time. Using Python for a job will require learning Python->Houdini interaction anyway, which is pretty much the same as learning VEX from scratch - it is really very simple language. Both Python and VEX have their own place in Houdini, you can't escape from neither of them . 2 Quote Link to comment Share on other sites More sharing options...
vtrvtr Posted August 1, 2016 Author Share Posted August 1, 2016 6 minutes ago, symek said: It is not. 95% of cases when you want to process geometry, it is a job for VEX. Changing attributes' values, adding points, prims, manipulating vectors, etc. VEX is very well shaped to process heavy data, forcing Python for doing this is ultimately waste of time. Using Python for a job will require learning Python->Houdini interaction anyway, which is pretty much the same as learning VEX from scratch - it is really very simple language. Both Python and VEX have their own place in Houdini, you can't escape from neither of them . Alright, thanks So I thought they were interchangeable, but clearly they are not. So my next question would be: what would python in Houdini be recommended for then? Quote Link to comment Share on other sites More sharing options...
abvfx Posted August 1, 2016 Share Posted August 1, 2016 10 minutes ago, vtrvtr said: what would python in Houdini be recommended for then? Tons of things but something that it is brilliant at doing is just manipulating Houdini in general. And by that i mean just simple nodes. If you are into rigging, being proficient in python would be a useful. You could work out a nice control system by hand... then use python to automate the process. This would be different than a digital asset because you can use python to edit/control the current set of nodes in your scene. Just think of python as a high level control of Houdini, batch type jobs, nodes etc. Vex is efficient low level control dealing with geometry/attribute etc. 4 Quote Link to comment Share on other sites More sharing options...
symek Posted August 1, 2016 Share Posted August 1, 2016 Scene's elements manipulation, rendering orchestration, interacting geometry, image, channel data with numerical modules, like numpy, scipy, etc, adhoc import/export of data. Anything that VEX is not capable of, or hard to achieve in. VEX works in the sandbox of a single geometry object (with importing read-only data from 3 other geometry source). If you, say, import big, complicated FBX file, and want to postprocess it get clean up mess, Python is your man. Computing PCA? Use Numpy. Python is also great for developing plugins which will be rewritten in C++ at the end. But VEX also applies here. 1 Quote Link to comment Share on other sites More sharing options...
vtrvtr Posted August 1, 2016 Author Share Posted August 1, 2016 Understood. Thank you both Quote Link to comment Share on other sites More sharing options...
animatrix Posted August 2, 2016 Share Posted August 2, 2016 Add C++ and OpenCL to the mix too, as you have Wrangle SOPs for these so you have no excuse 1 Quote Link to comment Share on other sites More sharing options...
f1480187 Posted August 2, 2016 Share Posted August 2, 2016 13 hours ago, vtrvtr said: For example, right now I'm trying to copy one attribute to a newly created one using a wrangler, which in VEX goes simply as f@new_p = @old_p But I'm not sure how would it go with python Rough equivalent is: x.setAttribValue('new_p', x.attribValue('old_p')) But Houdini has not Python Wrangle, so, there is no real equivalent. You need to run cycle yourself and create attribute manually: geo = hou.pwd().geometry() new_p = geo.addAttrib(hou.attribType.Point, 'new_p', 0.0) old_p = geo.findPointAttrib('old_p') for point in geo.points(): val = point.attribValue(old_p) point.setAttribValue(new_p, val) Or do it this way: geo = hou.pwd().geometry() new_p = geo.addAttrib(hou.attribType.Point, 'new_p', 0.0) values = geo.pointFloatAttribValues('old_p') geo.setPointFloatAttribValues('new_p', values) 2 1 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.