Difference between revisions of "Palette:virtualFile"

From TouchDesigner Documentation
Jump to: navigation, search
(Created page with "{{Summary |opFamily=COMP |opType=base |opClass=Palette:virtualFile Ext |opLicense= |short= |long=This embeds a file inside a component so you don't have to refer to, or...")
 
 
Line 1: Line 1:
{{Summary
+
[[Folder DAT]]{{Summary
 
|opFamily=COMP
 
|opFamily=COMP
 
|opType=base
 
|opType=base
Line 5: Line 5:
 
|opLicense=
 
|opLicense=
 
|short=
 
|short=
|long=This embeds a file inside a component so you don't have to refer to, or depend on external files in your project - they can all be embedded in the .toe or a .tox.  
+
|long=This component '''embeds files''' within itself so you don't have to refer to, or depend on external files in your project. Instead, the embedded files will be saved within the .toe or .tox files containing this component. It is essentially an interface for the [[COMP_Class#Virtual_File_System|Virtual File System]] that is built into all COMPs.
 +
{{OPSection
 +
    |opFamily=COMP
 +
|sectionName=Usage
 +
    |sectionSummary=
 +
{{OPSubSection
 +
|sectionName=Adding Virtual Files
 +
|sectionSummary=There are three parameter-based ways to add files to the component. You can also use its [[Palette:virtualFile Ext|Extension Class]]. To see a '''File List''' of embedded virtual files, wire a nullDAT to the second output, or click the '''List All Virtual Files To Textport''' parameter with a textport open.
 +
    |opFamily=COMP}}{{OPSubSection
 +
|sectionName=Add Virtual File From Disk
 +
|sectionSummary=This adds any external file selected in the '''Source File''' parameter.
 +
    |opFamily=COMP}}{{OPSubSection
 +
|sectionName=Add Virtual Files From Table
 +
|sectionSummary=This adds multiple external files identified in the <code>paths</code> column of the tableDAT specified in the <code>Paths Table</code> parameter. You can also wire a path table into virtualFile's input. If the table has an <code>overrideName</code> column, that column will be used to set the added file's names. '''Tip:''' to preserve file hierarchy, you can use a [[Folder DAT]] with the Relative Path column turned on wired into a [[Substitute DAT]] to change 'relpath' to 'overrideName'.
 +
    |opFamily=COMP}}{{OPSubSection
 +
|sectionName=Add Virtual Image File From TOP
 +
    |sectionSummary=This converts a TOP image into an image file and stores that file without having to save the image externally. There are parameters to specify the image source, image file type, and virtual file name.
 +
    |opFamily=COMP}}{{OPSubSection
 +
|sectionName=Accessing Virtual Files
 +
    |sectionSummary=Virtual files are accessed as if they were files on disk, by file in operators (e.g. [[Movie File In TOP]] or [[File In DAT]]). They are accessed using a special '''<code>vfs</code> syntax''' to specify their location:
 +
<syntaxhighlight>vfs:<component path>:<virtual file name></syntaxhighlight>
 +
The virtual file name can include slashes to simulate a folder structure. The vfs path can be put in the <code>file</code> parameter of any operator that loads external files.
 +
    |opFamily=COMP}}{{OPSubSection
 +
|sectionName=VFS Path Helpers
 +
    |sectionSummary=There are two ways to get a <code>vfs</code> path automatically from the virtualFile component.
 +
* The '''output DAT''' contains a tableDAT showing the paths of all virtual files in the <code>virtualPath</code> column".
 +
* The read-only '''Virtual Path''' parameter holds the <code>vfs</code> path of the virtual file at the index selected in the '''Index''' parameter.
  
It will of course make your .toe or .tox file larger. Two 1 Meg images that are embedded will make your.toe file 2 Meg larger.
+
Example expressions that might be used in a <code>file</code> parameter:
 +
<syntaxhighlight lang=python>
 +
# gets the file selected by Index parameter.
 +
op('/virtualFile').par.Virtualpath
  
Change the Source File parameter and press Create Virtual File. That will replace the virtual file held in this node with your new one.
+
# gets the second virtual file if 'null1' is wired to output of a virtualFile component.
 +
op('/null1')[2, 'virtualPath]</syntaxHighlight>
  
You can access the virtual file with a File In TOP like Movie File In TOP or Audio File In TOP using the vfs: syntax that you see in out1 DAT. and
+
    |opFamily=COMP}}}}
 
 
When using the virtual file, to specify the path, use which ever is convenient in the File parameter of the OP that will read the virtual file:
 
 
 
Get from the out1 DAT:
 
 
 
op('virtualFile/out1')[0,0]
 
 
 
or if you create a Null DAT outside this component:
 
 
op('null1')[0,0]
 
 
 
or you can use the read-only Virtual Path parameter on this component:
 
 
 
op('virtualFile').par.Virtualpath
 
 
 
You can copy/paste this component anywhere and it will contain the file contents in the component and in its .tox, even if you remove the original file.
 
 
 
You generally don't need to press the List Virtual File parameter or the Remove Virtual File parameter as everything is automatically updated when you press Create Virtual File.
 
 
 
This component has a tag 'vfs' and a Parent Shortcut 'vfs' so you can locate all the virtual files in a project.
 
 
 
This is set up to hold one file per virtualFile component, though  you can hack this to hold more with the Tscript vfs command. Not sure why you would.}}
 
 
{{ParameterPage
 
{{ParameterPage
 
|opFamily=COMP
 
|opFamily=COMP
Line 39: Line 47:
 
|pageSummary=
 
|pageSummary=
 
|items={{Parameter
 
|items={{Parameter
|opFamily=
+
|opFamily=COMP
 +
|opType=
 +
|parLabel=Version
 +
|parName=Version
 +
|parType=Str
 +
|parReadOnly=
 +
|parSummary=Component Version
 +
|parOrder=
 +
|parItems=}}
 +
{{Parameter
 +
|opFamily=COMP
 
|opType=
 
|opType=
 
|parLabel=Help
 
|parLabel=Help
Line 45: Line 63:
 
|parType=Pulse
 
|parType=Pulse
 
|parReadOnly=
 
|parReadOnly=
|parSummary=
+
|parSummary=Open this wiki page
|parOrder=0
+
|parOrder=
 +
|parItems=}}
 +
{{Parameter
 +
|opFamily=COMP
 +
|opType=
 +
|parLabel=List All Virtual Files To Textport
 +
|parName=List
 +
|parType=Pulse
 +
|parReadOnly=
 +
|parSummary=Print the vfsFileList to textport
 +
|parOrder=
 +
|parItems=}}
 +
{{Parameter
 +
|opFamily=COMP
 +
|opType=
 +
|parLabel=Remove All Virtual Files
 +
|parName=Remove
 +
|parType=Pulse
 +
|parReadOnly=
 +
|parSummary=Remove virtual files from this component
 +
|parOrder=
 +
|parItems=}}
 +
{{Parameter
 +
|opFamily=COMP
 +
|opType=
 +
|parLabel=Echo Commands To Texport
 +
|parName=Echocommands
 +
|parType=Toggle
 +
|parReadOnly=
 +
|parSummary=Print vfs commands run by parameter functions. This is for visibility and learning of the TouchDesigner vfs Python commands.
 +
|parOrder=
 +
|parItems=}}
 +
{{Parameter
 +
|opFamily=COMP
 +
|opType=
 +
|parLabel=Remove All Files Before Adds
 +
|parName=Removeallbeforeadds
 +
|parType=Toggle
 +
|parReadOnly=
 +
|parSummary=Remove all files first when adding virtual files
 +
|parOrder=
 
|parItems=}}
 
|parItems=}}
 
{{Parameter
 
{{Parameter
|opFamily=
+
|opFamily=COMP
 
|opType=
 
|opType=
|parLabel=Version
+
|parLabel=Index
|parName=Version
+
|parName=Virtualfileindex
 +
|parType=Int
 +
|parReadOnly=
 +
|parSummary=Index of the specific virtual file for parameters below
 +
|parOrder=
 +
|parItems=}}
 +
{{Parameter
 +
|opFamily=COMP
 +
|opType=
 +
|parLabel=Virtual Path
 +
|parName=Virtualpath
 
|parType=Str
 
|parType=Str
 
|parReadOnly=
 
|parReadOnly=
|parSummary=
+
|parSummary=vfs path of the selected virtual file
|parOrder=1
+
|parOrder=
 +
|parItems=}}
 +
{{Parameter
 +
|opFamily=COMP
 +
|opType=
 +
|parLabel=Remove Virtual File
 +
|parName=Removesingle
 +
|parType=Pulse
 +
|parReadOnly=
 +
|parSummary=Remove the selected virtual file
 +
|parOrder=
 +
|parItems=}}
 +
{{Parameter
 +
|opFamily=COMP
 +
|opType=
 +
|parLabel=Rename Virtual File
 +
|parName=Rename
 +
|parType=Pulse
 +
|parReadOnly=
 +
|parSummary=Open a dialog to give the selected virtual file a new internal filePath
 +
|parOrder=
 
|parItems=}}
 
|parItems=}}
 
{{Parameter
 
{{Parameter
|opFamily=
+
|opFamily=COMP
 
|opType=
 
|opType=
 
|parLabel=Source File
 
|parLabel=Source File
Line 65: Line 153:
 
|parType=File
 
|parType=File
 
|parReadOnly=
 
|parReadOnly=
|parSummary=
+
|parSummary=The external file to embed
|parOrder=2
+
|parOrder=
 
|parItems=}}
 
|parItems=}}
 
{{Parameter
 
{{Parameter
|opFamily=
+
|opFamily=COMP
 
|opType=
 
|opType=
|parLabel=Create Virtual File
+
|parLabel=Add From Disk
|parName=Create
+
|parName=Add
 
|parType=Pulse
 
|parType=Pulse
 
|parReadOnly=
 
|parReadOnly=
|parSummary=
+
|parSummary=Add the file selected in Source File parameter
|parOrder=3
+
|parOrder=
 +
|parItems=}}
 +
{{Parameter
 +
|opFamily=COMP
 +
|opType=
 +
|parLabel=Paths Table
 +
|parName=Pathstable
 +
|parType=DAT
 +
|parReadOnly=
 +
|parSummary=Table with 'path' column containing file paths of files to embed. An optional 'overrideName' column will be used as well, if found.
 +
|parOrder=
 +
|parItems=}}
 +
{{Parameter
 +
|opFamily=COMP
 +
|opType=
 +
|parLabel=Add From Table
 +
|parName=Addfromtable
 +
|parType=Str
 +
|parReadOnly=
 +
|parSummary=Add files specified in Paths Table DAT
 +
|parOrder=
 
|parItems=}}
 
|parItems=}}
 
{{Parameter
 
{{Parameter
|opFamily=
+
|opFamily=COMP
 
|opType=
 
|opType=
|parLabel=List Virtual File
+
|parLabel=Image Source TOP
|parName=List
+
|parName=Imagesourcetop
|parType=Pulse
+
|parType=TOP
 +
|parReadOnly=
 +
|parSummary=TOP to use to create virtual image file
 +
|parOrder=
 +
|parItems=}}
 +
{{Parameter
 +
|opFamily=COMP
 +
|opType=
 +
|parLabel=Virtual File Name
 +
|parName=Virtualfilename
 +
|parType=Str
 
|parReadOnly=
 
|parReadOnly=
|parSummary=
+
|parSummary=Virtual name of the created file
|parOrder=4
+
|parOrder=
 
|parItems=}}
 
|parItems=}}
 
{{Parameter
 
{{Parameter
|opFamily=
+
|opFamily=COMP
 
|opType=
 
|opType=
|parLabel=Remove Virtual File
+
|parLabel=Auto-Increment Name
|parName=Remove
+
|parName=Autoincrementname
|parType=Pulse
+
|parType=Toggle
 
|parReadOnly=
 
|parReadOnly=
|parSummary=
+
|parSummary=When on, add one to the digit at end of Virtual File Name every time an image is embedded
|parOrder=5
+
|parOrder=
 
|parItems=}}
 
|parItems=}}
 
{{Parameter
 
{{Parameter
|opFamily=
+
|opFamily=COMP
 
|opType=
 
|opType=
|parLabel=Virtual Path
+
|parLabel=Virtual File Image Filetype
|parName=Virtualpath
+
|parName=Virtualfileimagefiletype
 +
|parType=Menu
 +
|parReadOnly=
 +
|parSummary=File type to embed
 +
|parOrder=
 +
|parItems=
 +
    }}
 +
{{Parameter
 +
|opFamily=COMP
 +
|opType=
 +
|parLabel=Add From TOP
 +
|parName=Addfromtop
 
|parType=Str
 
|parType=Str
 
|parReadOnly=
 
|parReadOnly=
|parSummary=
+
|parSummary=Add virtual file from Image Source TOP
|parOrder=6
+
|parOrder=
 
|parItems=}}
 
|parItems=}}
 +
 +
}}
 +
{{InputsPage
 +
|opFamily=COMP
 +
|opInputs={{OPInput
 +
|opFamily=DAT
 +
|inputIndex=0
 +
|inputName=Paths Table
 +
|inputSummary=Table with 'path' column (and optionally 'overrideName' column) containing file paths of files to embed. Will override Paths Table parameter}}
 
}}
 
}}
 
{{OutputsPage
 
{{OutputsPage
Line 114: Line 252:
 
|opFamily=DAT
 
|opFamily=DAT
 
|outputIndex=0
 
|outputIndex=0
|outputName=out1
+
|outputName=vfsFiles
|outputSummary=}}
+
|outputSummary=info about all embedded virtual files}}
{{OPOutput
 
|opFamily=DAT
 
|outputIndex=1
 
|outputName=out2
 
|outputSummary=}}
 
 
}}
 
}}
 
{{History}}
 
{{History}}

Latest revision as of 16:02, 21 May 2020

Folder DAT{{Summary |opFamily=COMP |opType=base |opClass=Palette:virtualFile Ext |opLicense= |short= |long=This component embeds files within itself so you don't have to refer to, or depend on external files in your project. Instead, the embedded files will be saved within the .toe or .tox files containing this component. It is essentially an interface for the Virtual File System that is built into all COMPs.

Usage

Adding Virtual Files

There are three parameter-based ways to add files to the component. You can also use its Extension Class. To see a File List of embedded virtual files, wire a nullDAT to the second output, or click the List All Virtual Files To Textport parameter with a textport open.

Add Virtual File From Disk

This adds any external file selected in the Source File parameter.

Add Virtual Files From Table

This adds multiple external files identified in the paths column of the tableDAT specified in the Paths Table parameter. You can also wire a path table into virtualFile's input. If the table has an overrideName column, that column will be used to set the added file's names. Tip: to preserve file hierarchy, you can use a Folder DAT with the Relative Path column turned on wired into a Substitute DAT to change 'relpath' to 'overrideName'.

Add Virtual Image File From TOP

This converts a TOP image into an image file and stores that file without having to save the image externally. There are parameters to specify the image source, image file type, and virtual file name.

Accessing Virtual Files

Virtual files are accessed as if they were files on disk, by file in operators (e.g. Movie File In TOP or File In DAT). They are accessed using a special vfs syntax to specify their location:

vfs:<component path>:<virtual file name>

The virtual file name can include slashes to simulate a folder structure. The vfs path can be put in the file parameter of any operator that loads external files.

VFS Path Helpers

There are two ways to get a vfs path automatically from the virtualFile component.

  • The output DAT contains a tableDAT showing the paths of all virtual files in the virtualPath column".
  • The read-only Virtual Path parameter holds the vfs path of the virtual file at the index selected in the Index parameter.

Example expressions that might be used in a file parameter:

# gets the file selected by Index parameter.
op('/virtualFile').par.Virtualpath

# gets the second virtual file if 'null1' is wired to output of a virtualFile component.
op('/null1')[2, 'virtualPath]


Parameters - VFS Page

Version Version - Component Version  

Help Help - Open this wiki page  

List All Virtual Files To Textport List - Print the vfsFileList to textport  

Remove All Virtual Files Remove - Remove virtual files from this component  

Echo Commands To Texport Echocommands - Print vfs commands run by parameter functions. This is for visibility and learning of the TouchDesigner vfs Python commands.  

Remove All Files Before Adds Removeallbeforeadds - Remove all files first when adding virtual files  

Index Virtualfileindex - Index of the specific virtual file for parameters below  

Virtual Path Virtualpath - vfs path of the selected virtual file  

Remove Virtual File Removesingle - Remove the selected virtual file  

Rename Virtual File Rename - Open a dialog to give the selected virtual file a new internal filePath  

Source File Filesource - The external file to embed  

Add From Disk Add - Add the file selected in Source File parameter  

Paths Table Pathstable - Table with 'path' column containing file paths of files to embed. An optional 'overrideName' column will be used as well, if found.  

Add From Table Addfromtable - Add files specified in Paths Table DAT  

Image Source TOP Imagesourcetop - TOP to use to create virtual image file  

Virtual File Name Virtualfilename - Virtual name of the created file  

Auto-Increment Name Autoincrementname - When on, add one to the digit at end of Virtual File Name every time an image is embedded  

Virtual File Image Filetype Virtualfileimagefiletype - File type to embed  

Add From TOP Addfromtop - Add virtual file from Image Source TOP  


Operator Inputs

  • Input 0 - Table with 'path' column (and optionally 'overrideName' column) containing file paths of files to embed. Will override Paths Table parameter


Operator Outputs

  • Output 0 - info about all embedded virtual files


Palette
Palette • Palette:arcBallCamera • Palette:arcBallGeometry • Palette:audioAnalysis • Palette:audioSet • Palette:battery • Palette:blendModes • Palette:bloom • Experimental:Palette:camera • Palette:cameraBrowser • Palette:camSchnappr • Palette:changeColor • Palette:changeToColor • Palette:checker • Palette:chromaKey • Palette:colorThreshold • Palette:compareComp • Palette:convolve • Palette:cornerPinSOP • Palette:customAttributes • Experimental:Palette:debugControl • Palette:dent • Palette:depthExtract • Palette:dilate • Palette:equalizer • Palette:feedback • Palette:feedbackEdge • Palette:firmata • Palette:geoPanel • Palette:gestureCapture • Palette:graphPlot • Palette:histogram • Palette:hsvBlur • Palette:imageSearch • Palette:julia • Palette:kantanMapper • Palette:kinectCalibration • Palette:kinectPointcloud • Palette:leapPaint • Palette:lightTunnel • Palette:mandelbrot • Palette:mesh • Palette:monochrome • Palette:motionSense • Palette:moviePlayer • Palette:multiLevel • Palette:multiMix • Palette:noise • Palette:onScreenKeyboard • Palette:opticalFlow • Palette:particlesGpu • Palette:pixelate • Palette:pixelRelocator • Palette:pointGenerator • Palette:pointillize • Palette:pointMerge • Palette:pointRender • Palette:pointRepack • Palette:pointTransform • Palette:pointWeight • Palette:popDialog • Palette:probe • Palette:projectorBlend • Palette:pushPins • Palette:puzzle • Palette:radialBlur • Palette:remotePanel • Palette:rgbaBlur • Palette:rgbaDelay • Palette:rgbContrast • Palette:search • Palette:searchReplace • Palette:sharpen • Palette:softenAlpha • Palette:solarize • Palette:sopRender • Palette:stitcher • Palette:stoner • Palette:superFormula • Palette:sweetSpotPreviz • Palette:TDVR • Palette:transitMap • Palette:twirl • Palette:vectorScope • Palette:virtualFile • Palette:waveformMonitor • Palette:webBrowser • Palette:xyScope

An Operator Family that contains its own Network inside. There are twelve 3D Object Component and eight 2D Panel Component types. See also Network Path.

A built-in panel in TouchDesigner that contains a library of components and media that can be dragged-dropped into a TouchDesigner network.

TOuch Environment file, the file type used by TouchDesigner to save your project.

TouchDesigner Component file, the file type used to save a Component from TouchDesigner.

A dialog box in which commands and scripts can entered manually. Script errors and python print() messages are also output to the textport.

The location of an operator within the TouchDesigner environment, for example, /geo1/torus1, a node called torus1 in a component called geo1. The path / is called Root. To refer instead to a filesystem folder, directory, disk file or http: address, see Folder.

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.

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 manipulates text strings: multi-line text or tables. Multi-line text is often a command Script, but can be any multi-line text. Tables are rows and columns of cells, each containing a text string.

An Operator Family that contains its own Network inside. There are twelve 3D Object Component and eight 2D Panel Component types. See also Network Path.

A form of DATs (Data Operators) that is structured as rows and columns of text strings.