garf Posted May 26, 2017 Share Posted May 26, 2017 Ayup! How do you evaluate a parameter to determine it's contents 'type' - e.g. expression/string - 'type' method is currently crossed out in the docs http://www.sidefx.com/docs/houdini/hom/hou/Parm import hou sel = hou.selectedNodes() for i in range(len(sel)): for p in range(0, len(sel[0].parms())): sel[1].parms()[p].set(sel[0].parms()[p].eval()) print str(sel[0]) + ' = ' + str(sel[0].parms()[p].eval()) print str(sel[1]) + ' = ' + str(sel[1].parms()[p].eval()) Quote Link to comment Share on other sites More sharing options...
f1480187 Posted May 26, 2017 Share Posted May 26, 2017 It will return hou.parmTemplateType value, which is not exactly "expression/string" information. I think you can use this to get same result: parm.parmTemplate().type() Not sure if there is a better method, but you can check for expression like this: try: parm.expression() except hou.OperationFailed: print('Not expression branch.') else: print('Expression branch.') 1 Quote Link to comment Share on other sites More sharing options...
eyevex Posted May 30, 2017 Share Posted May 30, 2017 above should work on numerical parms, once that is determined and for string parms you could try something like.... is_exp=False raw = parm.unexpandedString() if any(['`' in raw, '$' in raw, '(' in raw]): is_exp = True or some variation depending on exaxtly what other than string literal you are trying to detect Quote Link to comment Share on other sites More sharing options...
garf Posted August 3, 2017 Author Share Posted August 3, 2017 Thanks chaps - so added to this, is there a way to determine which language is used in the expression e.g. Python/Hscript or is it simply a case of interrogating the code to determine what it is? Quote Link to comment Share on other sites More sharing options...
garf Posted August 3, 2017 Author Share Posted August 3, 2017 Scratch that expressionLanguage() 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.