Accessing (Parent) node properties in Dynamic Plugins

I am writing a dynamic plugin that takes a directory and looks for files in it (to do some stuff with them) - via the System.IO.Directory class.
Now the problem I have is, that the Directory selected via my Directory is given in a relative path, relative to the patch containing my plugin and System.IO.Directory assumes a standard working directory (usually different from my patch location).

So I want to get some info on the containing patch to set the working directory to the containing patch’s location, but I find it impossible to get an entry point to node-related info. Everything in VVVV.PluginInterfaces is - surprise! - interfaces and I can’t get a reference to the current node or the parent node or something.
So how do I instantiate a INode, INodeInfo, … object?

void VVVV.PluginInterfaces.V1.IPluginHost.GetHostPath ( out string Path)

is what you are looking for

IPluginHost FHost;

string hostpath;
FHost.GetHostPath(out hostpath);

Ah cool, thanks a bunch for the quick reply!
So I was missing the Import() IPluginHost thing.

this looks like a bug to me, a filename or directory pin should give you an absolute path. i will check that…

@tf: isn’t this exactly the topic cat and joreg discussed here?

nope, it is kinda related, but has nothing to do with each other. the idea in plugins is that the manual approach you demoed is done automagically for you as so as pluginwriter you always deal with the correct absolut paths.

Defaulting to absolute paths would be kinda bad, because patches using _Directory_s would be virtually immobilized and become unportable.

If you (devvvvs) want a simpler way than GetHostPath() and Directory.SetCurrentDirectory(), imo a standardized way (i.e. method) to correctly access a relative path given from a Directory on a D-Plugin would be the way to go.

@granny: you missunderstood. the idea is that FMyInputi returns already the correct absolut path for you, ie. it does the GetHostPatch()…thing for you.

i’d rather not use Directory.SetCurrentDirectory() as i think it actually sets the current dir process-wide. lets see what tonfilm comes up with.

Hm, yes that would be more convenient :)

So I’ll settle with building the absolute path out of the relative path & GetHostPath() by hand for now.

Okay, I found something:
My Directory pin selection in the patch is
That (when hovering over the pin) get’s ‘relatived’ to
(because my patch is on my desktop in my user account)

Now inside the D-Plugin apparently (via ILogger) I get

So it does convert the relative path (is it really relative or just in the gui?) to an absolute one, but in the wrong way. Either it only takes one dir up (from my desktop to myAccount folder) instead of two, or it just goes from myAccount in any case. Will check that in a minute.

Okay I think I know what goes wrong inside the Directory pin, because I made the same mistake when I wanted to do it by hand:
GetHostPath() gives you the full path including patch filename. Before removing as many folders as the relative path has “…” or “.” the patch filename needs to be removed.

thank you, nice find! that exactly was the case, next version the filename and directory pin will do:

protected string GetFullPath(string path)
if(Path.IsPathRooted(path)) return path;

string patchPath;
FHost.GetHostPath(out patchPath);

patchPath = Path.GetDirectoryName(patchPath);
path = Path.GetFullPath(Path.Combine(patchPath, path));
catch (Exception e)
FLogger.Log(LogType.Error, e.Message);

return path;

When I try to use this (in beta25) as described, I get the following exception:

Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘VVVV.PluginInterfaces.V1.IPluginHost’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{E72C5CF0-4738-4F20-948E-83E96D4E7843}’ failed due to the following error: Interface wordt niet ondersteund (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

Same happens if I don’t use the import but I keep a reference to IPluginHost host that is passed as a paramater to the constructor…

Does anyone know what I am doing wrong?

what exactly do you use?

In beta 25 I use:

IPluginHost FHost;


protected string GetFullPath(string path) {
    try  {
        FHost.GetHostPath(out patchPath);
   catch (Exception e) {
        Log(LogType.Error, e.Message);

    return fullPath;

But also when I store the host variable passed as a parmeter to the constructor and call host.getHostPath, it gives me the same error.

// import host and hand it to base constructor
public XXXXXNode(IPluginHost host) : base(host) {

hello ft, have you understood, that the string pin does this for you? you dont need to call this, i just posted it to give an insight, what the string pin is doing:

[Input(“Input”, StringType = StringType.Directory)](Input(“Input”, StringType = StringType.Directory))
ISpread FInput;


[Input(“Input”, StringType = StringType.Filename)](Input(“Input”, StringType = StringType.Filename))
ISpread FInput;

I understand, but because I want the user to be able to add parameters behind the filename, I need to do it myself.

So I’d be glad if you could tell me how I could do that.

ok, could be a dll version issue, will have a look at it…

this just works for me:

IPluginHost FHost;

  #endregion fields & pins

  //called when data for any output pin is requested
  public void Evaluate(int SpreadMax)
  	var s = "";
  	FHost.GetHostPath(out s);
  	FLogger.Log(LogType.Debug, s);

maybe your vvvv installation is somehow corrupted, can you try it with a clean download?

The above seems to work in another installation, so now I need to check what’s wrong here.