Feed Example: Combining Python’s Powerful Module Library with Houdini
Overview
This example loads in information from an RSS news feed, creating geometry objects containing the feed title text. When you click on the titles in the viewport, Houdini runs a Python script that starts up the help browser with the URL for the feed.
This example shows how you can easily access Python’s extensive library of supporting modules from within Houdini. It uses the feedparser module from feedparser.org to load and parse an RSS news feed. This module internally uses a number of Python modules to retrieve data from a web site and parse XML.
Location
Supporting files for this example are in $HFS/mozilla/documents/hom/cookbook/feed, also found in the cookbook/feed directory of cookbook_files.tar.gz.
Running the Example
Change to the cookbook/feed/part3 directory before launching Houdini so that Houdini can import the Python modules in that directory.
Launch part3/feed.hip.
Start a Python shell and type hou.session.createObjects().
Enter the selection tool in the viewer, and click on the text to launch the browser with the corresponding article.
Exploring the Implementation
This example is split into three parts. In Part 1, you’ll build a shelf tool that reads a news feed and creates different objects displaying the text of the titles of the news items. Part 2 saves the news feed information into a Python global variable, and provides an example of connecting nodes together. Part 3 attaches pick scripts to the objects and opens a URL in the help browser when you click on the text.
