[Sidefx-houdini-list] Python expression in string field parameter

Graham Thompson captainhammy at gmail.com
Tue Jan 18 10:28:19 EST 2011

Python expressions can be a little different sometimes.  For strings
you don't have to wrap them in `` and if it's more than one line you
have to return from them.  Also, in your case since you are trying to
use a module you'll have to import it in the actual parameter as it
doesn't directly share the global namespace or import the global
namespace into the parameter.

To set a string parameter expression for example I would set the node
to Python, LMB on the label of the parameter to toggle it, then RMB
and Edit Expression.  In the dialog I'd then enter something like

import myModule
return myModule.getFilePath(args)

or for a single line expression:


or if you have somehow imported myModule through say python.rc or
123.py or 456.py or some other method:

import __main__
return __main__.myModule.getFilePath(args)

2011/1/18 Pablo Giménez <pablogipi at gmail.com>:
> Hi all.
> I have a string filed parameter,a file parameter to be exact, and I
> want o to use a python function to use information from other
> parameters to conform a file path.
> I have my function in myModule.getFilePath, and I have tried to call
> to it using this form of python expression:
> `myModule.getfilePath(chs('loc'), chs('type'), chs('subtype'),
> chs('element'), chs('ver'))`
> My guess is that this parameter will be recognized automatically as a
> python expression, but not sure if the systav I am using is correct or
> not.
> Because I got just an empty string I decided to wrap my python
> expression into a hscript expression like:
> `pythonexprs(myModule(chs('loc'), chs('type'), chs('subtype'),
> chs('element'), chs('ver')))`
> But again I got nothing.
> For testing my python function just do this:
> def getDataOutLocation(location, type, subtype, element, ver):
>   return "Hello World"
> Is the first time I try to use python expressions in parameters so I
> guess I am missing something here.
> Any advice?
> Thanks
> --
> Un saludo
> Best Regards
> Pablo Giménez
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list

More information about the Sidefx-houdini-list mailing list