Houdini is a wonderful software but when starting probably one of its biggest difficulty is to understand graph flow and single nodes semantic, developing a simple script which automatically populates and display as the node comment the headline from the official documentation may help beginners learn faster nodes and projects.




Let's start:

Create a python script with your favorite editor, name it OnCreated.py and save into HOUDINI /scripts folder

Here is the script (remember, python requests to use TABS to be syntactically correct, so where you see space you have to use one or more tab/s):

Code:

import hou

import os

import zipfile

ZIPFOLDER = os.environ['HFS']+"/houdini/help/nodes.zip".replace("/",os.sep)

ARCHIVE = zipfile.ZipFile(ZIPFOLDER, 'r')   

def getHeader(path):    

       path = path.replace("operator:","").replace("object/", "obj/").split("?")[0]    

       path = path.lower()    

       nodeHelpContent = ARCHIVE.read(path+".txt")   

       splitted = nodeHelpContent.split("\"\"\"")    

       return splitted[1] if len(splitted)>1 else "Not found"



def main(kwargs):    

       node = kwargs["node"]   

       if len(node.comment())==0 :        

              description = getHeader(node.type().defaultHelpUrl())        

              node.setComment(description)        

              node.setGenericFlag(hou.nodeFlag.DisplayComment,True)    



main(kwargs)
        

Note

If you created the file inside the /scripts folder with Houdini already opened, better to close and restart it to load properly the script, after this you are free to modify the script and see its results in realtime (every time you create a new node).


Code is quite simple:

  1. main() is called when a new node is created
  2. kwargs contains the node generated
  3. if node comment is empty (this simple check is to avoid overwriting comments generated by other plugins or scripts) we get the node description calling getHeader() method
  4. getHeader() simply read nodes.zip file, an archive which contains the whole documentation file placed into houdini/help sub-folder, and extract the headline which is delimitated by three " characters. .split("?")[0] is required to remove ?version=x get parameter. ZIPFOLDER is the path of the zip file and should work in any OS because it uses slash or backslash depending on correct configuration. 
  5. A ternary operator return the content or not found
  6. when getHeader() returns node headline we set it as a comment and enable display of the comment. 

Source code




COMMENTS

  • harryabreu 6 years, 6 months ago  | 

    Thank you :)

  • Olaf Finkbeiner 6 years, 6 months ago  | 

    Hi NeoGene,
    cool stuff. Thanks. Not many good examples/tutorials of Python use in Houdini around. And i like your idea here. Commenting is so important to understand when learning by looking at scenes.

    greetings
    Olaf

  • Bandu 6 years, 6 months ago  | 

    this is great ! cheers !!

  • sirenesoong 6 years, 6 months ago  | 

    Thank you!!!!

  • azerila idnavak 6 years, 6 months ago  | 

    Big like!!!

  • PrashanthParamasivam 6 years, 6 months ago  | 

    great

  • Lostboys 6 years, 5 months ago  | 

    I found that I got a lot of python errors when it tried to access a node with no help available. I changed the last line to this:

    try:
    main(kwargs)
    except:
    pass

    • Anton81 6 years, 4 months ago  | 

      Got a ton of errors before changing the last line to this. Thank you.

  • cracksoul769 4 years, 1 month ago  | 

    The powerful SideFX Houdini FX activation key  Full Crack software has been developed and marketed for 3D animation with side effects. Special note. This procedure animation sets the product apart from other software families.

    elanor

    cracksoul.com

Please log in to leave a comment.