How to retrieve value from StringProperty? I'm trying to create an addon for Blender.  The addon will have an operator part that builds a mesh and also a panel part that lets the user configure it.

One thing I want to do with the panel is have a drop down property that lets the user select the name of a reference object in the scene.  I found some examples showing how to add this to your panel using the layout.prop_search() method.  However, I wasn't able to find any information on how you are supposed to retrieve the value after the user sets it.  Right now I'm just trying to have my operator fetch the value the user set and print it to the console.  



When I try, I get the message 

(&lt;built-in function StringProperty&gt;, {'attr': 'theChosenObject'})


Also, is this the best way to go about doing this?  It looks to me that I'm cluttering up Blender's object space by having my addon insert all it's 'global' variables into bpy.types.Scene.

Here's my source:

bl_info = {
    "name": "Build It", 
    "category": "Object"
}

import bpy

class BuildItPanel(bpy.types.Panel):
    bl_label = "Build It"
    bl_idname = "VIEW_3D_TOOLS_build_it"
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS"
    bl_category = "Tools"

    def draw(self, context):
        layout = self.layout

        scene = context.scene

        col = layout.column(align=True)
        col.prop_search(scene, "referenceMesh", scene, "objects")
        col.operator("object.build_it", text="Do Build")

class BuildItOp(bpy.types.Operator):
    bl_idname = "object.build_it"
    bl_label = "Build It"
    bl_options = {"UNDO"}

    def invoke(self, context, event):
#        print(BuildItPanel.bl_category)
        print(bpy.types.Scene.referenceMesh)
        return {"FINISHED"}

def register():
    bpy.utils.register_class(BuildItPanel)
    bpy.utils.register_class(BuildItOp)
    bpy.types.Scene.referenceMesh = bpy.props.StringProperty()


def unregister():
    bpy.utils.unregister_class(BuildItPanel)
    bpy.utils.unregister_class(BuildItOp)
    del bpy.types.Object.referenceMesh



# This allows you to run the script directly from blenders text editor
# to test the addon without having to install it.
if __name__ == "__main__":
    register()
You have one small mistake: you are reading the function that creates properties for new classes, while you should be accessing the property itself in the current scene, which has the value you have stored:

print(context.scene.referenceMesh)   instead of print(bpy.types.Scene.referenceMesh)