TransWikia.com

How to get user input for a function?

Blender Asked by Nburgess on November 29, 2020

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

One Answer

I was not calling the information properly. It is not under bpy.types.Scene.conf_path but rather C.scene.conf_path.

Answered by Nburgess on November 29, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP