--[[ Split EXR prototype by S.Neve / House of Secrets Yay for Fusion 6, splitting of multi channel EXR to multiple loaders scripting is now possible This is just a protoype, might expand this to something with a GUI should our pipeline demand it (or if we all get tired with deleting unwanted loaders) ]]-- function removedups (t) -- thanks to Doug Currie at Stackoverflow for this function local result = {} local count = 0 local found for i,v in ipairs(t) do found = false if count > 0 then for j = 1,count do if v == result[j] then found = true; break end end end if not found then count = count + 1 result[count] = v end end return result, count end attrs = tool:GetAttrs() -- check to see we have a Loader with actual EXR data if attrs.TOOLS_RegID == "Loader" then if tool.Clip[comp.CurrentTime] == "" then print("No Clip to explore") return end else print("not a Loader") return end --print(attrs["TOOLST_Clip_FormatName"][1]) local exrFileName = attrs.TOOLST_Clip_Name[1] --get list of all channels channelList = tool.Clip1.OpenEXRFormat.RedName:GetAttrs().INPIDT_ComboControl_ID newChannelList = {} -- filter out None,R,G,B and A as these are already used by the original Loader for i = 1, table.getn(channelList) do if not (channelList[i] == "SomethingThatWontMatchHopefully" or channelList[i] == "R" or channelList[i] == "G" or channelList[i] == "B" or channelList[i] == "A" ) then table.insert(newChannelList,channelList[i]) end end -- asume a deranged monkey wrote out the channels and decided to scramble 'm all table.sort(newChannelList) --for index,value in ipairs(newChannelList) do --print(index, value) --end --start creating loaders, we start at the top of the table so we can safely remove entries without screwing up orders listSize = table.getn(newChannelList) loaderList = {} for i = 1, listSize do --print("inverted : " .. newChannelList[listSize - i + 1]) table.insert(loaderList, (string.gsub( newChannelList[listSize - i + 1], "[.][^.]*$", ""))) --create a table with all the new loaders end loaderList = removedups(loaderList) comp:Lock() for i = 1, table.getn(loaderList) do --print(loaderList[i]) myLoader = Loader({Clip = exrFileName}) myLoader:SetAttrs({TOOLS_Name = loaderList[i]}) myLoader.Clip1.OpenEXRFormat.RedName = "SomethingThatWontMatchHopefully" myLoader.Clip1.OpenEXRFormat.GreenName = "SomethingThatWontMatchHopefully" myLoader.Clip1.OpenEXRFormat.BlueName = "SomethingThatWontMatchHopefully" myLoader.Clip1.OpenEXRFormat.AlphaName = "SomethingThatWontMatchHopefully" myLoader.Clip1.OpenEXRFormat.ZName = "SomethingThatWontMatchHopefully" --tool.Clip1.OpenEXRFormat.RedName for j = 1 , table.getn(newChannelList) do if (string.gsub( newChannelList[j], "[.][^.]*$", "") == loaderList[i]) then if(string.sub( newChannelList[j], -1 ) == "R") then myLoader.Clip1.OpenEXRFormat.RedName = newChannelList[j] end if(string.sub( newChannelList[j], -1 ) == "G") then myLoader.Clip1.OpenEXRFormat.GreenName = newChannelList[j] end if(string.sub( newChannelList[j], -1 ) == "B") then myLoader.Clip1.OpenEXRFormat.BlueName = newChannelList[j] end if(string.sub( newChannelList[j], -1 ) == "A") then myLoader.Clip1.OpenEXRFormat.AlphaName = newChannelList[j] end print(newChannelList[j] .. " matched : " .. loaderList[i]) end end end comp:Unlock()