Using the parsing functionality of IfcOpenShell interactively

In this recipe we are going to look at an interactive way of working with Python and IfcOpenShell that allows to quickly explore the possibilities offered by the tools. When the python interpreter (python.exe) is executed without arguments it will function as a REPL (a Read Evaluate Print Loop). It enables the user to type a single line of code and immediately see the evaluated result. An example of such a session is provided below. It outlines the procedure of starting with an IfcProject and descending down to the unit for angular measures. In this particular file it seems that angles are specified as degrees, a constant factor of 0.0174533 away from radians.

Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ifcopenshell
>>> file ="IfcOpenHouse.ifc")
>>> project = file.by_type("IfcProject")[0]
>>> project
>>> project.is_a()
>>> project.is_a("IfcRoot")
>>> project.is_a("IfcWall")
>>> project.attribute_name(0)
>>> project.attribute_type(0)
>>> project.GlobalId
>>> project.Bier
Traceback (most recent call last):
  File "", line 1, in 
  File "ifcopenshell\\", line 28, in __getattr__
    except: raise AttributeError("entity instance of type '%s' has no attribute '%s'"%(self.wrapped_data.is_a(), name))
AttributeError: entity instance of type 'IfcProject' has no attribute 'Bier'
>>> project.UnitsInContext
>>> units = project.UnitsInContext.Units
>>> angle_unit = filter(lambda u: u.UnitType == "PLANEANGLEUNIT", units)[0]
>>> angle_unit
>>> angle_unit.ConversionFactor
>>> angle_unit.ConversionFactor.ValueComponent
>>> angle_unit.ConversionFactor.ValueComponent.is_a()
>>> angle_unit.ConversionFactor.ValueComponent.wrappedValue