siddd Posted August 5, 2010 Share Posted August 5, 2010 Hey all, I was wondering if anyone might be able to give me a quick pointer on how to write expressions that have multiple lines of code in them inside Houdini. I basically just want to do the following (simplified version) dist = distance(0,0,0, $TX, $TY, $TZ) div = dist / 5 /obj/meshing/attribcreate1/value1 = div And that's it! Does anyone know the correct python and hscript syntax for this? Cheers, Sid (Total n00b) Quote Link to comment Share on other sites More sharing options...
symek Posted August 5, 2010 Share Posted August 5, 2010 (edited) { float dist = distance(0,0,0, $TX, $TY, $TZ); float div = dist / 5; return div; } in AttributeCreate/value1 parm. In case of Python expression, open expr. editor (Alt+E) and put the code as it be a body of a function. Edited August 5, 2010 by SYmek 3 Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted August 5, 2010 Share Posted August 5, 2010 Thanks, that was a cool tip that I didn't know. Quote Link to comment Share on other sites More sharing options...
katisss Posted March 8, 2011 Share Posted March 8, 2011 (edited) How can i do this with python? Easy by using the expresion editor but my pre render script has some lines i want to set there from my farm rop module... Ah by the way is pre render script expected to run before idf file generation? Edited March 8, 2011 by katisss Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted March 8, 2011 Share Posted March 8, 2011 That I do is use the expression editor in the "edit / Aliases and Variables" to create a function, and then call that function. If your expression is more then one line this is a lot easier to manage, and you can re-use it elsewhere. Quote Link to comment Share on other sites More sharing options...
katisss Posted March 8, 2011 Share Posted March 8, 2011 (edited) Expression editor is probably not an option, no way of putting multiline python? Another person sets the rops and the farm rop is only managing the renders... That I do is use the expression editor in the "edit / Aliases and Variables" to create a function, and then call that function. If your expression is more then one line this is a lot easier to manage, and you can re-use it elsewhere. Edited March 8, 2011 by katisss Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted March 8, 2011 Share Posted March 8, 2011 I'm still using hscript so I haven't tried python in the editor, but maybe if you switch the default language to python it will work. Also, the manual says you can enter multiline python expressions using the editor (alt+e). http://www.sidefx.com/docs/houdini11.0/hom/expressions Quote Link to comment Share on other sites More sharing options...
katisss Posted March 8, 2011 Share Posted March 8, 2011 hi, the python editor works great it puts a tab sign in the result (like mircosoft word )... I just need to do it from python. 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.