Sunpath Node

The VI-Suite Sunpath node creates a 3D sun path diagram, sun lamp and sun mesh within Blender. The node also enables real-time control of sun position and colour based on day-of-year and hour-of-day settings. These controls also modify the Hosek/Wilkie sky orientation for realistic sky control within Blender’s Cycles rendering engine. The short video below details the operation of the node.

VI-Suite Sunpath Node from Ryan Southall on Vimeo.

Anatomy of a node

One of the simplest nodes in the VI-Suite is the location node. The location node defines the location of the building to be analysed in terms of latitude and longitude, and is a required node for Sun Path, Shadow Study, Wind Rose, LiVi and EnVi analyses.

The image below shows the Python code listing for the location node.

Basic node Python code

A node in Blender is an instance of a Python class and so the code begins with a class definition that locates the node within the ‘VINodes’ node tree.   Lines 2 to 5 identifies the name, label and icon of the node.

Lines 7 to 13 define some parameters associated with the node. Parameters are important as they not only hold values, but also create user interface elements to allow the user to alter their values. Parameters for the location node include the latitude and longitude values.

A Blender node has a number of built-in functions, but as a node is an instance of a class we call these built-in functions methods, that are called during the ‘life’ of the node. When a node is created by the user the ‘init’ method is executed and lines 15 to 21 defines what happens when this occurs. In this method a property is associated with the node called ‘nodeid’ which contains the name of the node and the name of nodetree that the node sits in. An external function is run called ‘nodeinit’ which creates some platform specific parameters the VI-Suite uses, and finally an output socket is created.

Whenever the user changes the socket connections of this node the method ‘update’ is executed, which is defined on lines 23 & 24. When the update method is executed it in turn executes an external function called socklink that checks if the socket on the other node we are connecting the output socket of this node to is the same colour. If so the connection is made, if not the connection is not made. This helps make sure the user does not construct node connections that would result in an error.

The final method we use here is the draw_buttons method where we can define the user-interface presented by the node. In this function some of the parameters of the node defined earlier are presented. For example the ‘loc’ parameter is defined as a Blender EnumProperty. An EnumProperty in Blender basically represents a list, and the loc parameter has two entries in its list: A ‘Manual’ entry and an ‘EPW’ entry. When we include the ‘loc’ parameter in the draw_buttons method Blender automatically creates a drop-down menu interface for this parameter. Similarly, the latitude and longitude parameters are defined as FloatProperties, which represent regular numbers. When these are included in the draw_buttons function, Blender creates boxes that allow the user to manipulate these numbers.

If ‘EPW’ is selected in the ‘loc’ menu then an EnumProperty drop-down menu is displayed to select the desired EnergyPlus weather file. Weather files with an .epw or .EPW extension should be placed within the vi-suite/EPFiles/Weather directory. After adding a weather file Blender needs to be restarted to see the new file.

The short video shows how the location node functions.

VI-Suite location node from Ryan Southall on Vimeo.

Installing the VI-Suite

First get hold of a copy of the most recent version of Blender (2.69 at the time of writing) from http://www.blender.org and install it. If this is the first time you have used Blender open it and select the ‘File – User Preferences’ menu item. The settings window will appear and for now simply click the ‘Save User Settings’ button in the bottom left corner. This makes sure that the Blender configuration directory is created on your system.

On a Windows 7 PC this directory can be found at  C:\Users\your_username\AppData\Roaming\Blender Foundation\Blender\blender_version

On a Mac it can be found at /Users/your_username/Library/Application Support/Blender/blender_version

And on an Arch Linux machine can be found at /home/your_username/.config/blender/blender_version

Other operating systems may vary but this directory should be created somewhere similar.

Within this folder create a directory called ‘scripts’ and within this a directory called ‘addons’.

For those comfortable with the command-line navigate to the ‘addons’ directory above and checkout, with Mercurial, the VI-Suite code from the Google Code repository with the command:

hg clone https://code.google.com/p/vi-suite/

This should place a ‘vi-suite’ directory within the addons directory.

Alternatively, a zip file containing the VI-Suite code can be downloaded from https://code.google.com/p/vi-suite/source/list by clicking the download zip button just above the list of code changes. The directory within the zip file should be renamed to ‘vi-suite’ and moved to the ‘addons’ directory.

Upon starting Blender the VI-Suite should be registered as an available add-on. The video below shows how to activate this add-on within Blender.

Activating the VI-Suite from Ryan Southall on Vimeo.