Created
February 11, 2016 12:05
-
-
Save AndrewHazelden/522baed0215220fbf1c3 to your computer and use it in GitHub Desktop.
A Blackmagic Design Fusion LUA script example to check the current comp's flow area for the currently selected Loader/Saver nodes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Find out if we are running Fusion 6, 7, or 8 | |
local fu_major_version = math.floor(tonumber(eyeon._VERSION)) | |
-- Find out the current operating system platform. The platform local variable should be set to either "Windows", "Mac", or "Linux". | |
local platform = "" | |
if string.find(fusion:MapPath("Fusion:\\"), "Program Files", 1) then | |
-- Check if the OS is Windows by searching for the Program Files folder | |
platform = "Windows" | |
elseif string.find(fusion:MapPath("Fusion:\\"), "PROGRA~1", 1) then | |
-- Check if the OS is Windows by searching for the Program Files folder | |
platform = "Windows" | |
elseif string.find(fusion:MapPath("Fusion:\\"), "Applications", 1) then | |
-- Check if the OS is Mac by searching for the Applications folder | |
platform = "Mac" | |
else | |
platform = "Linux" | |
end | |
-- Find out the current directory from a file path | |
-- Example: print(dirname("/Users/Shared/file.txt")) | |
function dirname(mediaFileName) | |
-- LUA dirname command inspired by Stackoverflow code example: | |
-- http://stackoverflow.com/questions/9102126/lua-return-directory-path-from-path | |
sep = '' | |
if platform == "Windows" then | |
sep = "\\" | |
elseif platform == "Mac" then | |
sep = "/" | |
else | |
-- Linux | |
sep = "/" | |
end | |
return mediaFileName:match("(.*"..sep..")") | |
end | |
-- Lock the comp flow area | |
composition:Lock() | |
local mediaFileName = nil | |
-- List the selected Node in Fusion | |
selectedNode = comp.ActiveTool | |
if selectedNode then | |
print("[Selected Node] ", selectedNode.Name) | |
toolAttrs = selectedNode:GetAttrs() | |
-- Read data from either a the loader and saver nodes | |
if toolAttrs.TOOLS_RegID == "Loader" then | |
mediaFileName = fusion:MapPath(toolAttrs.TOOLST_Clip_Name[1]) | |
-- Get the file name from the clip | |
print("[Loader Image] ", mediaFileName) | |
elseif toolAttrs.TOOLS_RegID == "Saver" then | |
mediaFileName = fusion:MapPath(toolAttrs.TOOLST_Clip_Name[1]) | |
print("[Saver Image] ", mediaFileName) | |
else | |
end | |
-- Launch the viewer tool with this media clip | |
if mediaFileName ~= nil then | |
if eyeon.fileexists(mediaFileName) then | |
-- The code to process the selected image goes here | |
print("[Launching Terminal Command] ") | |
else | |
print("[Media File Missing] ", mediaFileName) | |
end | |
end | |
else | |
print("[Node Selection Required] No media node was selected. Please select and activate a loader or saver node in the flow view.") | |
end | |
-- unlock the comp flow area | |
composition:Unlock() | |
-- End of the script | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment