Hello, I’m trying to open explorer that on blender’s project file location.
However, I can’t find way to open explorer. Anything way to do that?
Or if it can’t support Linux etc., can it open windows10?
Thank you.
In Linux or Mac there are some equivalent file browser programs, with a simple ‘if-then-else’ can support many of them if needed. But now only for windows do this.
import bpy
import subprocess
import os
if bpy.data.filepath != '':
dirpath = os.path.dirname(bpy.data.filepath)
#subprocess.call('explorer '+dirpath, shell=True)
os.startfile(dirpath)
Thank you for the many help!
I got after all It seems that Win and Mac have different structures.
The code can open windows explorer!
I try on Mac too, But unfortunately It couldn’t open file browser… Xl
But thank you!!
Sorry for adding, I’ll try to registration this function for keymap.
But when adding keymap function, It could not recognize…
Anything tips to do that?
Thank you.
bl_info = {
"name": "TestAddOn",
"description": "This AddOn is test AddOn",
"author": "",
"version": (1, 0, 0, 0),
"blender": (2, 80, 0),
"support": "TESTING",
"category": "Test",
"location": "",
"warning": "",
"wiki_url": "",
"tracker_url": ""
}
import bpy
import subprocess
import os
class TESTADDON(bpy.types.Operator):
bl_idname = "test.addon"
bl_label = "TestAddOn"
def execute(self, context):
if bpy.data.filepath != '':
dirpath = os.path.dirname(bpy.data.filepath)
os.startfile(dirpath)
print("Addon Running")
return {'FINISHED'}
def register():
print("regist addon")
bpy.utils.register_class(TESTADDON)
wm = bpy.context.window_manager
km = wm.keyconfigs.addon.keymaps.new(name='VIEW_3D', space_type='EMPTY')
kmi = km.keymap_items.new(TESTADDON.bl_idname, 'SPACE', 'PRESS', ctrl=True, shift=True)
addon_keymaps.append(km)
def unregister():
print("unregist addon")
bpy.utils.unregister_class(TESTADDON)
wm = bpy.context.window_manager
for km in addon_keymaps:
wm.keyconfigs.addon.keymaps.remove(km)
del addon_keymaps[:]
if __name__ == "__main__":
register()
Thank you very much for your time! It’s great detail…
I got it that needed an independent class for adding keymap! I learned a lot from that structure.
Thank you!