I'm building an addon which is a collection of scripts, and I have my UI coded as one of this scripts. On of my tools (script) requires a user input, in this case a folder path, but I don`t know how to pass it onto my export tool so it knows where to export the selected objects. Here is how it is written in my UI script, I just copied it:
# root for export scn = context.scene col = layout.column(align=True) col.prop(scn.my_tool, "path", text="")
It shows great in my Panel but I'm not sure how use the string it gives in another script.
Following @WhataMesh pointed out here is what I did. In my UI script I added a class with a string property and changed the layout to fit, also had to register and unregister the new class and the property.
class MySettings(PropertyGroup): path = StringProperty( name="path", description="Path to Directory", default="", maxlen=1024, subtype='DIR_PATH' def draw(self, context): layout = self.layout # root for export scn = context.scene mytool = scn.my_tool col = layout.column(align=True) col.prop(mytool, "path", text="") def register(): bpy.utils.register_class(UI) bpy.utils.register_class(MySettings) bpy.types.Scene.my_tool = PointerProperty(type=MySettings) def unregister(): bpy.utils.unregister_class(UI) bpy.utils.unregister_class(MySettings) del bpy.types.Scene.my_tool