------------------------------------------------------ -- Graceful clip failure tool -- Sets up a BG and DX to catch out of range LDs -- Oct 31, 2008 -- -- To do: -- DONE: 1) Check LD's flow position, so new tools are placed in a logical coordinate in the flow. -- 2) Figure out a way to force the LD to render without using a viewer. -- -- place in Fusion:/Scripts/Tool/AT -- -- Written by Chad Capeland (ccapeland[GO-AWAY-SPAMBOT!]@anatomicaltravel.com) -- Copyright (c) 2008 Anatomical Travelogue LLC -- (http://www.anatomicaltravel.com/research) -- -- The authors hereby grant permission to use, copy, and distribute this -- software and its documentation for any purpose, provided that existing -- copyright notices are retained in all copies and that this notice is -- included verbatim in any distributions. Additionally, the authors grant -- permission to modify this software and its documentation for any -- purpose, provided that such modifications are not distributed without -- the explicit consent of the authors and that existing copyright notices -- are retained in all copies. -- IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR -- DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING -- OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES -- THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF -- SUCH DAMAGE. -- THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, -- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND -- DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, -- UPDATES, ENHANCEMENTS, OR MODIFICATIONS. ------------------------------------------------------ ------------------------------------------------------ -- declare the function function BGDX(t) -- get the attributes of the tool local ta = t:GetAttrs() local tx,ty = comp.CurrentFrame.FlowView:GetPos(t) if ta.TOOLI_ImageDepth == nil then print("\n---------------------------------------------- Notice: ----------------------------------------------\n" ..ta.TOOLS_Name,"has not rendered yet, new BG parameters will be set to defaults and may be incorrect" .."\n----------------------------------Graceful_LD_failure_(BG-DX_Add)------------------------------------\n") local bg = comp:AddTool("Background") local dx = comp:AddTool("Dissolve") -- set their positions comp.CurrentFrame.FlowView:SetPos(bg, tx + .5, ty - 1.5) comp.CurrentFrame.FlowView:SetPos(dx, tx + 1.5, ty) -- connect the tools together dx.Background = bg.Output dx.Foreground = t.Output else -- assign some variables local w = ta.TOOLI_ImageWidth local h = ta.TOOLI_ImageHeight local d = (ta.TOOLI_ImageDepth) - 4 local xa = ta.TOOLN_ImageAspectX local ya = ta.TOOLN_ImageAspectY -- add some tools local bg = comp:AddTool("Background") local dx = comp:AddTool("Dissolve") -- set some properties bg.Width = w bg.Height = h bg.Depth = d bg.PixelAspect = {xa,ya} -- set their positions comp.CurrentFrame.FlowView:SetPos(bg, tx + .5, ty - 1.5) comp.CurrentFrame.FlowView:SetPos(dx, tx + 1.5, ty) -- connect the tools together dx.Background = bg.Output dx.Foreground = t.Output end end -- run the function if tool.Clip then -- test to see if it is a functional LD BGDX(tool) -- output an error if tool is not a loader else print( toolname, "is not a Loader. This script is designed to allow for graceful failure of LDs whose ranges do not match that of the requesting tool. Look at you, fancy Time Lord.") end