Documentation of Loader PSDFormat

User avatar
bryanfordney
Posts: 39
Joined: Tue Jan 29, 2019 1:10 pm
Location: Atlanta, GA

Documentation of Loader PSDFormat

#1

Post by bryanfordney » Mon Feb 11, 2019 6:43 am

I'm just getting started with scripting in Fusion. I am attempting to manipulate some parameters that are specific to the PSD format of Loader.

I am using splitEXR as a reference on how to manipulate Loaders. In that case, the author is accessing

Code: Select all

loader.Clip1.OpenEXRFormat
to deal with EXR-specific parameters. I see that the equivalent exists for PSD,

Code: Select all

loader.Clip1.PSDFormat
, however I have no idea what the attributes are for this object.

Is there documentation for these objects, or is there some way to dump all their attributes?

I am actually using Python, but a Lua example should be close enough.

Thanks,

Bryan

User avatar
AndrewHazelden
Fusionator
Posts: 1219
Joined: Fri Apr 03, 2015 3:20 pm
Location: West Dover, Nova Scotia, Canada
Been thanked: 11 times
Contact:

Re: Documentation of Loader PSDFormat

#2

Post by AndrewHazelden » Mon Feb 11, 2019 6:55 am

Check out Svene Neve's hos_PSDLayers lua script.

Direct Download link: hos_PSDLayers_v1.6.zip

The individual layers in a PSD file are accessed using the "Layer" attribute which is an integer number:

Code: Select all

Inputs = {
	["Clip1.PSDFormat.Layer"] = Input { Value = 2, },
},

You can print the active PSD channels on the selected Loader node using this lua code snippet:

Code: Select all

dump(comp.ActiveTool.Clip1.PSDFormat.Layer:GetAttrs().INPST_ComboControl_String)

This results in a Lua table output being printed to the Fusion Console:

Code: Select all

table: 0x187bda38
	1 = Merged Layers
	2 = Background
	3 = Background


If you have Reactor installed, the "Scripts/Comp" category has a "UI Manager Lua & Python Examples" atom package you can install. The "List Input Control Names.lua" script lists the two Clip1.PSDFormat input controls as "Clip1.PSDFormat.Layer" and "Clip1.PSDFormat.AlphaFrom".

List Input Control Names.png
You do not have the required permissions to view the files attached to this post.

User avatar
bryanfordney
Posts: 39
Joined: Tue Jan 29, 2019 1:10 pm
Location: Atlanta, GA

Re: Documentation of Loader PSDFormat

#3

Post by bryanfordney » Mon Feb 11, 2019 7:29 am

Wonderful! Thank you.

pixelstuff
Posts: 41
Joined: Sun Jul 15, 2018 11:50 am
Been thanked: 1 time

Re: Documentation of Loader PSDFormat

#4

Post by pixelstuff » Mon Feb 11, 2019 8:33 am

Would anyone be able to confirm, if they experience the same freeze in this script(mentioned above "List Input Control Names.lua" ), I don't think its specifically this script as I get the same issue with other, ui:AddNotify() events


I have tested it in both Windows10 and OSX, but the issue I'm having is that it will lock up and stop updating after around 10-14 seconds of clicking between different nodes to load the inputs. Sometimes it can freeze after a few clicks. The console no longer responds but is ok after the script is closed.

I can't seem to find a solution to this and thought maybe its a bug or something else that I have installed that's causing it. The trouble is I don't know how to troubleshoot it. The "action listener script" picks up the updates then stops when I get this freeze, is there a way to maybe find what is stopping the AddNotify event. It's just really strange that it stops at random times if anyone else has experienced this and knows of a fix? Or happy to fudge it by refreshing "something" to make it work. I just don't know where the data goes to find the cause.

Image

List Input Control Names.lua


Code: Select all

--[[
List Input Control Names v1 - 2017-09-12 8.59 AM
by Andrew Hazelden
Email: andrew@andrewhazelden.com
Web: www.andrewhazelden.com

The "List Input Control Names" UI Manager script is based upon Chad's Lua script for getting input control names:
https://www.steakunderwater.com/wesuckless/viewtopic.php?f=16&t=1298#p9550

Overview:
This script is a Fusion Lua based UI Manager example that works in Fusion 8.2.1 and Fusion 9. The example displays a list of the input control names for the currently selected node in a ui:Tree view. 

You can click on any of the input control name items in the list and the expression value will be copied to your clipboard.

The "ui:AddNotify('Comp_Activate_Tool', comp)" command is used to track the changing node selection in the flow area for the current comp. This AddNotify event runs the function disp.On.Comp_Activate_Tool(ev) which automatically updates the tree view when you select a new node.


Installation:
Step 1. Copy the "List Input Control Names.lua" script to your Fusion user preferences "Scripts/Comp/" folder.

Step 2. Select a node in the Fusion Flow area.

Step 3. Go to the Script menu and select the "List Input Control Names" item.

Notes:
For more details on reading node inputs and outputs check out:
https://www.steakunderwater.com/VFXPedia/96.0.243.189/index87f2.html?title=Eyeon:Script/Tutorials/Console_Introduction/Attributes,_Input-Output_List

]]

-- Find out if we are running Fusion 6, 7, 8, or 9
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'.
platform = ''
if string.find(comp:MapPath('Fusion:\\'), 'Program Files', 1) then
  -- Check if the OS is Windows by searching for the Program Files folder
  platform = 'Windows'
elseif string.find(comp:MapPath('Fusion:\\'), 'PROGRA~1', 1) then
  -- Check if the OS is Windows by searching for the Program Files folder
  platform = 'Windows'
elseif string.find(comp:MapPath('Fusion:\\'), 'Applications', 1) then
  -- Check if the OS is Mac by searching for the Applications folder
  platform = 'Mac'
else
  platform = 'Linux'
end

local ui = fu.UIManager
local disp = bmd.UIDispatcher(ui)
local width,height = 600,700

win = disp:AddWindow({
  ID = 'MyWin',
  WindowTitle = 'Input Control Names',
  Geometry = {100, 100, width, height},
  Spacing = 0,
  
  ui:VGroup{
    ID = 'root',
      
    ui:HGroup{
      Weight = 0,
      ui:Label{ID = 'TitleLabel', Text = 'This script lists the input controls for the currently selected node.', Alignment = {AlignHCenter = true, AlignTop = true},},
    },

    ui:Tree{ID = 'Tree', SortingEnabled=true, Events = {ItemDoubleClicked=true, ItemClicked=true},},
  },
})

-- Read the current noe selection
selectedTool = tool or comp.ActiveTool

-- Track the Fusion selection changed events
ui:AddNotify('Comp_Activate_Tool', comp)

-- Add your GUI element based event functions here:
itm = win:GetItems()

-- Handle the notification
function disp.On.Comp_Activate_Tool(ev)
  -- dump(ev.Args)
  prevTool = ev.Args.prev
  selectedTool = ev.Args.tool
  print('[Active tool] ', selectedTool, ' [Previous Tool] ', prevTool)
  UpdateTree()
end

-- The window was closed
function win.On.MyWin.Close(ev)
  disp:ExitLoop()
end

-- Copy the expression name to the clipboard when a Tree view row is clicked on
function win.On.Tree.ItemClicked(ev)
  if selectedTool ~= nil then
    x = selectedTool:GetInputList()
    nodeName = selectedTool:GetAttrs().TOOLS_Name

    -- Copy the "Node.InputName" value to the clipboard
    inputName = nodeName .. '.' .. ev.item.Text[0]
    CopyToClipboard(inputName)
  end
end


-- Update the contents of the tree view
function UpdateTree()
  -- Clean out the previous entries in the Tree view
  itm.Tree:Clear()
  
  -- Add a header row
  hdr = itm.Tree:NewItem()
  hdr.Text[0] = 'Input'
  hdr.Text[1] = 'Name'
  hdr.Text[2] = 'Data Type'
  itm.Tree:SetHeaderItem(hdr)

  -- Number of columns in the Tree list
  itm.Tree.ColumnCount = 3

  -- Resize the Columns
  itm.Tree.ColumnWidth[0] = 300
  itm.Tree.ColumnWidth[1] = 200
  itm.Tree.ColumnWidth[2] = 100

  -- Make sure a node is selected
  if selectedTool ~= nil then
    x = selectedTool:GetInputList()
    nodeName = selectedTool:GetAttrs().TOOLS_Name
    
    -- Update the window title to track the current node name
    itm.MyWin.WindowTitle = 'Input Controls: ' .. nodeName
    print('Input Controls: ' .. nodeName)

    -- Add an new row entries to the list
    for i, inp in pairs(x) do
      itRow = itm.Tree:NewItem(); 
      
      itRow.Text[0] = inp:GetAttrs().INPS_ID
      itRow.Text[1] = inp:GetAttrs().INPS_Name
      itRow.Text[2] = inp:GetAttrs().INPS_DataType

      itm.Tree:AddTopLevelItem(itRow)
    end
    
    print('[Done]')
  else
    -- Nothing was selected in the flow
    itRow = itm.Tree:NewItem(); 
    itRow.Text[0] = 'Please select a node in the flow area.'
    itm.Tree:AddTopLevelItem(itRow)
    
    print('Please select a node in the flow area.')
  end
end


-- Copy text to the operating system's clipboard
-- Example: CopyToClipboard('Hello World!')
function CopyToClipboard(textString)
  -- The system temporary directory path (Example: $TEMP/Fusion/)
  outputDirectory = comp:MapPath('Temp:\\Fusion\\')
  clipboardTempFile = outputDirectory .. 'ClipboardText.txt'

  -- Create the temp folder if required
  os.execute('mkdir "' .. outputDirectory .. '"')

  -- Open up the file pointer for the output textfile
  outClipFile, err = io.open(clipboardTempFile,'w')
  if err then
    print("[Error Opening Clipboard Temporary File for Writing]")
    return
  end

  outClipFile:write(textString)
  -- outClipFile:write(textString,'\n')

  -- Close the file pointer on the output textfile
  outClipFile:close()
  command = ''
  if platform == 'Windows' then
    -- The Windows copy to clipboard command is "clip"
    command = 'clip < "' .. clipboardTempFile .. '"'
  elseif platform == 'Mac' then
    -- The Mac copy to clipboard command is "pbcopy"
    command = 'pbcopy < "' .. clipboardTempFile .. '"'
  elseif platform == 'Linux' then
    -- The Linux copy to clipboard command is "xclip"
    -- This requires a custom xclip tool install on Linux:
 
    -- Debian/Ubuntu:
    -- sudo apt-get install xclip
 
    -- Redhat/Centos/Fedora:
    -- yum install xclip
    command = 'cat "' .. clipboardTempFile .. '" | xclip -selection clipboard &'
  end

  print('[Copy to Clipboard] ' .. textString)
  -- print('[Command] ' .. command)
  os.execute(command)
end

-- Update the contents of the tree view
UpdateTree()

win:Show()
disp:RunLoop()
win:Hide()