python Multi-line String

   7639   3   1
User Avatar
Member
7 posts
Joined: Oct. 2013
Offline
Hi,
In “Edit parameter interface” We can create “Multi-line String”, but I can not find how I can achieve it in python??

I read the api, find this attribute,but I don't know how to set it.

http://www.sidefx.com/docs/houdini13.0/hom/hou/StringParmTemplate [sidefx.com]

itemGeneratorScript(self) → str
Return the script used to generate menu items, or an empty string if there is no such script.

This script is used when this parm template uses a menu.

Note that if the item generator script language is hou.scriptLanguage.Python, this script may be either a single-line Python expression or a multi-line body of a Python function.

============


thanks
User Avatar
Member
7871 posts
Joined: July 2005
Offline
Embed “\n” newlines into the script?
User Avatar
Member
2 posts
Joined: March 2016
Offline
For everyone who find this old topic (like me), to create a multiline string parameter. You have to modify the key “editor” value to 1.

import hou
node = hou.node('/obj').createNode('geo')
group = node.parmTemplateGroup()
folder = hou.FolderParmTemplate('folder', 'My Parms')
template = hou.StringParmTemplate('myparm', 'My Parm',1)
template.setTags({"editor": "1"}) #it's "0" by default
folder.addParmTemplate(template)
group.append(folder)
node.setParmTemplateGroup(group)
Edited by nilth - May 5, 2017 13:37:54
User Avatar
Member
18 posts
Joined: Sept. 2013
Offline
Thank you for this. It pointed me in the right direction.

If you want a multiline string param to use Python:

...setTags({"editor": "1", "editorlang": "python"})

If you want to inspect a node the asCode function is really nice.
To write it to a file we can execute snippet below in the python shell

with open('/path/to/somewhere/as_code.py', 'w') as f:
    f.write(hou.node('obj/geo1/your_node').asCode())
  • Quick Links