I noticed when using the subtype of either ‘FILE_PATH’ or ‘DIR_PATH’ when creating a string property to retain a user defined file path for saving the render output location, that this doesn’t work when placed in a menu only when in a panel or header or something. The folder icon appears but you can not click on it. Is it possible to get a user file path from within a menu?
You could try to invoke a file select modal operator via menu, not sure if this works for directories only too…
import bpy
class SimpleOperator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"
filepath = bpy.props.StringProperty()
filename = bpy.props.StringProperty()
directory = bpy.props.StringProperty()
files = bpy.props.CollectionProperty(type=bpy.types.PropertyGroup)
def invoke(self, context, event):
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
def execute(self, context):
s = "filepath = %s
filename = %s
directory = %s
---------------
files =
%s" % (
self.filepath,
self.filename,
self.directory,
",
".join(f.name for f in self.files)
)
self.report({'ERROR'}, s)
return {'FINISHED'}
def register():
bpy.utils.register_class(SimpleOperator)
def unregister():
bpy.utils.unregister_class(SimpleOperator)
if __name__ == "__main__":
register()
bpy.ops.object.simple_operator('INVOKE_DEFAULT')
Indeed. Many thanks.