Skip to content

Commit

Permalink
LOOM_OT_open_folder - globals, fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
p2or authored Oct 10, 2021
1 parent c306ea3 commit d5da00a
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions loom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2978,7 +2978,14 @@ class LOOM_OT_open_folder(bpy.types.Operator):
folder_path: bpy.props.StringProperty()

def execute(self, context):
fp = os.path.realpath(bpy.path.abspath(self.folder_path))
fp = self.folder_path
glob_vars = context.preferences.addons[__name__].preferences.global_variable_coll
if any(ext in fp for ext in glob_vars.keys()):
fp = replace_globals(fp)

fp = os.path.realpath(bpy.path.abspath(fp))
if os.path.isfile(fp) or not os.path.exists(fp):
fp = os.path.dirname(fp)
if not os.path.isdir(fp):
self.report({'INFO'}, "'{}' does not exist".format(fp))
return {"CANCELLED"}
Expand All @@ -3005,18 +3012,19 @@ class LOOM_OT_open_output_folder(bpy.types.Operator):
bl_options = {'REGISTER'}

def execute(self, context):
fp = os.path.dirname(
os.path.realpath(
bpy.path.abspath(
context.scene.render.filepath
)
)
)
fp = context.scene.render.filepath
glob_vars = context.preferences.addons[__name__].preferences.global_variable_coll
if any(ext in fp for ext in glob_vars.keys()):
fp = replace_globals(fp)

fp = os.path.realpath(bpy.path.abspath(fp))
if not os.path.isdir(fp):
fp = os.path.dirname(fp)
if os.path.isdir(fp):
bpy.ops.loom.open_folder(folder_path=fp)
else:
bpy.ops.loom.open_folder(folder_path=bpy.path.abspath("//"))
self.report({'INFO'}, "Folder does not exist")
return {"CANCELLED"}

bpy.ops.loom.open_folder(folder_path=fp)
return {'FINISHED'}


Expand Down Expand Up @@ -4619,7 +4627,7 @@ def draw_loom_compositor_paths(self, context):
icon='ERROR', text="", emboss=False).directory = os.path.dirname(o.base_path)
'''
row.operator(LOOM_OT_open_folder.bl_idname,
icon='DISK_DRIVE', text="", emboss=False).folder_path = os.path.dirname(o.base_path)
icon='DISK_DRIVE', text="", emboss=False).folder_path = o.base_path

if lum.comp_image_settings:
col = box.column()
Expand Down Expand Up @@ -4679,6 +4687,8 @@ def draw_loom_dopesheet(self, context):
"$LENS": '"{:0.0f}mm".format(bpy.context.scene.camera.data.lens)',
"$VIEWLAYER": 'bpy.context.view_layer.name',
"$MARKER": 'next((i.name for i in bpy.context.scene.timeline_markers if i.frame == bpy.context.scene.frame_current), "NO_NAME")',
"$COLL": 'bpy.context.collection.name',
"$OB": 'bpy.context.active_object.name',
"$SUM": 'str(sum([8, 16, 32]))'
}

Expand Down

0 comments on commit d5da00a

Please sign in to comment.