I have created a function that requires a file path input, I found a way to have the user input a file location but I am not sure how to access it. I thought it was assigned to the bpy.types.Scene.conf_path
but I do not get the directory when its printed. Here is my code.
import bpy
class HelloWorldPanel(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Hello World Panel"
bl_idname = "OBJECT_PT_hello"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
def draw(self, context):
layout = self.layout
obj = context.object
col = layout.column()
col.prop(context.scene, 'conf_path')
def register():
bpy.utils.register_class(HelloWorldPanel)
bpy.utils.register_module(__name__)
bpy.types.Scene.conf_path = bpy.props.StringProperty \
(
name = "XML Location",
default = "",
description = "Define the root path of the project",
subtype = 'DIR_PATH'
)
def unregister():
bpy.utils.unregister_class(HelloWorldPanel)
bpy.utils.unregister_module(__name__)
del bpy.types.Scene.conf_path
if __name__ == "__main__":
register()
I appreciate any help or direction. Thanks
C.scene.conf_path
Note this is an instance not the class. Don't use register class and register module together. Registering registerable classes withregister_class
is whatregister_module
is doing for you.. (register_module
has been ditched for 2.8) seriously consider starting from 2.8 at this point in time. Finally, On formatting, open braces are also considered a line continuation by python $\endgroup$