Difference between revisions of "Experimental:Palette:virtualFile Ext"

From TouchDesigner Documentation
Jump to: navigation, search
Line 20: Line 20:
 
|class=VirtualFileExt
 
|class=VirtualFileExt
 
|name=AddFile
 
|name=AddFile
|call=AddFile(filePath=None, byteArray=None, removeAllFirst=None, returnVFSPath=False)
+
|call=AddFile(filePath=None, overrideName=None, removeAllFirst=None, returnVirtualPath=False)
|returns=dict or str
+
|returns=VFSFile or virtual path
|text=Add a virtual file to the component. Returns a vfs info dictionary OR vfs paths using mode defined by par.Uselabel
+
|text=Add an embedded file from disk to the component with an option to override the name.
 
*filePath - (Keyword, Optional) The path of the file to add. Default = par.Filesource
 
*filePath - (Keyword, Optional) The path of the file to add. Default = par.Filesource
*byteArray - (Keyword, Optional) A byte array of data to be stored along with the file in VFS. If a byte array is provided then that data will be treated as if it came from a file at filePath
+
*overrideName - (Keyword, Optional) When specified, will override the name of the file in VFS.
 
*removeAllFirst - (Keyword, Optional) If True, remove all the virtual files first, default = par.Removeallbeforeadds  
 
*removeAllFirst - (Keyword, Optional) If True, remove all the virtual files first, default = par.Removeallbeforeadds  
*returnVFSPath - (Keyword, Optional) If True, return the vfs path instead of the vfs info dictionary
+
*returnVirtualPath - (Keyword, Optional) If True, return the virtual path instead of VFSFile
 
}}
 
}}
 
{{ClassMethod
 
{{ClassMethod
 
|class=VirtualFileExt
 
|class=VirtualFileExt
 
|name=AddFromImage
 
|name=AddFromImage
|call=AddFromImage(top=None, filePath=None, filetype=None, removeAllFirst=None, returnVFSPath=False)
+
|call=AddFromImage(top=None, name=None, filetype=None, removeAllFirst=None, returnVirtualPath=False)
|returns=dict or str
+
|returns=VFSFile or virtual path
 
|text=Add an image file created from the provided TOP. Returns an vfs info dictionary OR vfs paths using mode defined by par.Uselabel
 
|text=Add an image file created from the provided TOP. Returns an vfs info dictionary OR vfs paths using mode defined by par.Uselabel
 
*top - (Keyword, Optional) The TOP image to use. Default = par.Imagesourcetop
 
*top - (Keyword, Optional) The TOP image to use. Default = par.Imagesourcetop
*filePath - (Keyword, Optional) The "filePath" to be stored with the image. This is not a real filePath, but really just a string stored for uniquely identifying this virtual file. Default = top path + par.Virtualfilelabel + par.Virtualfileimagefiletype  
+
*name: the name to be stored with the image. Default = par.Virtualfileimagename + par.Virtualfileimagefiletype
 
*filetype - (Keyword, Optional) The file filetype to save virtual file in. For available formats, see https://docs.derivative.ca/TOP_Class saveByteArray function. Default = par.Virtualfileimagefiletype  
 
*filetype - (Keyword, Optional) The file filetype to save virtual file in. For available formats, see https://docs.derivative.ca/TOP_Class saveByteArray function. Default = par.Virtualfileimagefiletype  
 
*removeAllFirst - (Keyword, Optional) If True, remove all the virtual files first, default = par.Removeallbeforeadds
 
*removeAllFirst - (Keyword, Optional) If True, remove all the virtual files first, default = par.Removeallbeforeadds
*returnVFSPath - (Keyword, Optional) If True, return the vfs path instead of the vfs info dictionary}}
+
*returnVirtualPath - (Keyword, Optional) If True, return the virtual path instead of VFSFile
 +
}}
 
{{ClassMethod
 
{{ClassMethod
 
|class=VirtualFileExt
 
|class=VirtualFileExt
 
|name=AddFromTable
 
|name=AddFromTable
 
|call=AddFromTable(table=None, removeAllFirst=None, returnVFSPath=False)
 
|call=AddFromTable(table=None, removeAllFirst=None, returnVFSPath=False)
|returns=list of dicts or list of str
+
|returns=list of VFSFiles or list of Virtual Paths
|text=Add all files from 'path' column in input table. Returns a list of vfs info dicts OR vfs paths using mode defined by par.Uselabel.
+
|text=Add all files from 'path' column in input table. If there is an 'overrideName' column, use this for virtual names. Returns a list of VFSFiles OR virtual paths
 
*table - (Keyword, Optional) table of filepaths, default = wired input or par.Pathstable
 
*table - (Keyword, Optional) table of filepaths, default = wired input or par.Pathstable
 
*removeAllFirst - (Keyword, Optional) if True, remove all the virtual files first, default = par.Removeallbeforeadds
 
*removeAllFirst - (Keyword, Optional) if True, remove all the virtual files first, default = par.Removeallbeforeadds
*returnVFSPath - (Keyword, Optional) if True, return list of vfs paths instead of vfs info dictionaries }}
+
*returnVirtualPath - (Keyword, Optional) if True, return list of vfs paths instead of VFSFiles
{{ClassMethod
+
}}
|class=VirtualFileExt
 
|name=ByteArray
 
|call=ByteArray(labelOrPath, useLabel=True)
 
|returns=bytearray
 
|text=Get the byteArray object of a virtual file.
 
*labelOrPath - (Keyword, Optional) the label or filePath of the virtual file
 
*useLabel - (Keyword, Optional) defines how to read labelOrPath argument}}
 
{{ClassMethod
 
|class=VirtualFileExt
 
|name=ExportFiles
 
|call=ExportFiles(pattern='*', useLabel=True, overwrite=False, folder=None)
 
|returns=list of str
 
|text=Exports to disk any virtual files in the component that match against the pattern. Returns a list of the new file paths.
 
*pattern - (Keyword, Optional) The pattern to match against. Default is * (ie. all files).
 
*useLabel - (Keyword, Optional) When true, will match against the file label instead of the full path.
 
*overwrite - (Keyword, Optional) When true, will overwrite any existing files.
 
*folder - (Keyword, Optional) The folder to export to. When unspecified it will export to the current path of the file.}}
 
 
{{ClassMethod
 
{{ClassMethod
 
|class=VirtualFileExt
 
|class=VirtualFileExt
|name=FileList
+
|name=Find
|call=FileList(pattern='*', useLabel=True, recurse=False)
+
|call=FileList(pattern='*')
|returns=list of dict
+
|returns=list of VFSFiles
|text=Returns a list of dictionaries describing the virtual files in thecomponent that match against the pattern.
+
|text=Finds all files in VFS with names matching the pattern. Returns a list of VFSFile objects.
 
*pattern - (Keyword, Optional) The pattern to match against.
 
*pattern - (Keyword, Optional) The pattern to match against.
*useLabel - (Keyword, Optional) When true, will match against the file label instead of the full path.
 
*recurse - (Keyword, Optional) When true, will recurse over the component's children.}}
 
 
{{ClassMethod
 
{{ClassMethod
 
|class=VirtualFileExt
 
|class=VirtualFileExt
 
|name=Remove
 
|name=Remove
|call=Remove(pattern='*', useLabel=True)
+
|call=RemoveFiles(pattern='*')
|returns=True or None
+
|returns=
|text=Removes any virtual file from the component that matches with the supplied pattern. Returns True if files successfully removed.
+
|text=Destroys any virtual file from the component that matches with the supplied pattern.
 
*pattern - (Keyword, Optional) The pattern to match against.
 
*pattern - (Keyword, Optional) The pattern to match against.
 
*useLabel - (Keyword, Optional) When true, will match against the file label instead of the full path.}}
 
*useLabel - (Keyword, Optional) When true, will match against the file label instead of the full path.}}
Line 87: Line 69:
 
|name=RemoveSingle
 
|name=RemoveSingle
 
|call=RemoveSingle(index=None)
 
|call=RemoveSingle(index=None)
|returns=True or None
+
|returns=
|text=Remove a virtual file by index. Returns True if file successfully removed.
+
|text=Destroy a virtual file by index
 
*index - (Keyword, Optional) Index of file to remove. Default = par.Virtualfileindex}}
 
*index - (Keyword, Optional) Index of file to remove. Default = par.Virtualfileindex}}
 
{{ClassMethod
 
{{ClassMethod
 
|class=VirtualFileExt
 
|class=VirtualFileExt
 
|name=Rename
 
|name=Rename
|call=Rename(oldPath, newPath)
+
|call=Rename(oldName, newName)
 
|returns=
 
|returns=
|text=Change the filePath of a virtual file.
+
|text=Change the name of a virtual file
*oldPath - (Keyword) filePath of file to rename
+
*oldName - name of file to rename
*newPath - (Keyword) new filePath for file}}
+
*newPath - new name for file}}
{{ClassMethod
 
|class=VirtualFileExt
 
|name=VFSPathFromFileListing
 
|call=VFSPathFromFileListing(listing, useLabel=None)
 
|returns=str
 
|text=Get the vfs path for a given virtual file info dictionary. Returns a vfs path.
 
*listing - (Keyword) info dictionary from FileList
 
*useLabel - (Keyword, Optional) determines format of returned vfs path. Default = par.Uselabel.}}
 
 
{{ClassMethod
 
{{ClassMethod
 
|class=VirtualFileExt
 
|class=VirtualFileExt
|name=VFSPathFromIndex
+
|name=VFSFileFromIndex
|call=VFSPathFromIndex(index, useLabel=None)
+
|call=VFSFileFromIndex(index)
|returns=str
+
|returns=VFSFile
|text=Get the vfs path for a virtual file by index. Returns a vfs path.
+
|text=Get a VFSFile by index
 
*index - (Keyword) index of the file
 
*index - (Keyword) index of the file
*useLabel - (Keyword, Optional) determines format of returned vfs path. Default = par.Uselabel.}}
 
 
}}
 
}}
 
{{History}}
 
{{History}}

Revision as of 17:10, 4 May 2020

These Extentions reference a specific Palette:virtualFile.


VirtualFileExt[edit]

The VirtualFileExt extension provides extended functionality for working with the virtual files embedded in the component. Many of the functions mirror the vfs functions that exist on all COMPs.

Members[edit]

No operator specific members.


{{ClassMethodSection |sectionSummary=

   |empty=

|items= AddFile(filePath=None, overrideName=None, removeAllFirst=None, returnVirtualPath=False)VFSFile or virtual path:

Add an embedded file from disk to the component with an option to override the name.

  • filePath - (Keyword, Optional) The path of the file to add. Default = par.Filesource
  • overrideName - (Keyword, Optional) When specified, will override the name of the file in VFS.
  • removeAllFirst - (Keyword, Optional) If True, remove all the virtual files first, default = par.Removeallbeforeadds
  • returnVirtualPath - (Keyword, Optional) If True, return the virtual path instead of VFSFile

AddFromImage(top=None, name=None, filetype=None, removeAllFirst=None, returnVirtualPath=False)VFSFile or virtual path:

Add an image file created from the provided TOP. Returns an vfs info dictionary OR vfs paths using mode defined by par.Uselabel

  • top - (Keyword, Optional) The TOP image to use. Default = par.Imagesourcetop
  • name: the name to be stored with the image. Default = par.Virtualfileimagename + par.Virtualfileimagefiletype
  • filetype - (Keyword, Optional) The file filetype to save virtual file in. For available formats, see https://docs.derivative.ca/TOP_Class saveByteArray function. Default = par.Virtualfileimagefiletype
  • removeAllFirst - (Keyword, Optional) If True, remove all the virtual files first, default = par.Removeallbeforeadds
  • returnVirtualPath - (Keyword, Optional) If True, return the virtual path instead of VFSFile

AddFromTable(table=None, removeAllFirst=None, returnVFSPath=False)list of VFSFiles or list of Virtual Paths:

Add all files from 'path' column in input table. If there is an 'overrideName' column, use this for virtual names. Returns a list of VFSFiles OR virtual paths

  • table - (Keyword, Optional) table of filepaths, default = wired input or par.Pathstable
  • removeAllFirst - (Keyword, Optional) if True, remove all the virtual files first, default = par.Removeallbeforeadds
  • returnVirtualPath - (Keyword, Optional) if True, return list of vfs paths instead of VFSFiles

{{ClassMethod |class=VirtualFileExt |name=Find |call=FileList(pattern='*') |returns=list of VFSFiles |text=Finds all files in VFS with names matching the pattern. Returns a list of VFSFile objects.

  • pattern - (Keyword, Optional) The pattern to match against.

RemoveFiles(pattern='*'):

Destroys any virtual file from the component that matches with the supplied pattern.

  • pattern - (Keyword, Optional) The pattern to match against.
  • useLabel - (Keyword, Optional) When true, will match against the file label instead of the full path.

RemoveSingle(index=None):

Destroy a virtual file by index

  • index - (Keyword, Optional) Index of file to remove. Default = par.Virtualfileindex

Rename(oldName, newName):

Change the name of a virtual file

  • oldName - name of file to rename
  • newPath - new name for file

VFSFileFromIndex(index)VFSFile:

Get a VFSFile by index

  • index - (Keyword) index of the file


Lets you embed files inside a .tox or .toe file. Operators like the Movie File In TOP that read regular files can also read the embedded VFS files using a vfs: syntax.

An Operator Family that creates, composites and modifies images, and reads/writes images and movies to/from files and the network. TOPs run on the graphics card's GPU.