Jump to content

make a parm use python instead hscript


pelos

Recommended Posts

I have a parameter in my node that I want to convert to use python,   usually we can right click> expression >change language to python  but for some reason  is gray out =(

and reading documentation I could do parm.setExpression("2+2". language=Something)  but I thought using hou.lenguage.Python as argument but wants a value?   do we have something like

parm.setScriptLenguage?  or an easy way to switch all the node to use python,  or just that parameter?

Link to comment
Share on other sites

it's grayed out, because you don't have any keyframe or existing expression there, if you had one, you can convert

you can also set your node language to Python and then when your parm is in expression editing mode, you can just type it in and it will create expression keyframe for you

but this should work too, what errors are you getting?:

yourParm.setExpression("2+2", hou.exprLanguage.Python)

 

Link to comment
Share on other sites

if I do something like

    exp = """
node = hou.pwd()
geo = node.geometry()
prim0 = geo.prim(0)
return len(prim0.points())
"""
    attribvop_node.parm("num_points_per_line").setExpression(exp, hou.exprLanguage.Python)

 

now it works =)   in the UI shows purple,  and not green  I think is because just that parm is python and the rest are hscript.

 

thanks =)!!!! 

 

(go to sleep  is 1 am)

Edited by pelos
Link to comment
Share on other sites

yes, the colors may be confusing

- it all depends on what is the node's default scripting language (shown top-right next to cog icon)

- if expression on the parameter is the same language, it is green, if it is other language then purple

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...