Vray vrmat import from directory string

Right guys,

I have ran into a little issue. Material import node for vray does not have any inputs and you can not feed the directory string. And all of the geometry in vray grasshopper requires preloaded material and not the directory sting as far as I understand.

Any ideas on how could I load vray materials from a directory string?

Thank you for your help in advance!


Jonas Blazinskas

Hi, Jonas,

I’m not sure what you’re after - is it either something like a live directory, where you examine a folder for .vrmat files every time a solution runs, or a lazier way to get all .vrmat files in a directory without going thought selecting them.

And all of the geometry in vray grasshopper requires preloaded material

that is not true. If you don’t set a material a default material will be used on-the-fly. This won’t work with RenderInProject component though, it requires a real material

There are ways to do it for both.

The “MaterialFromFile” component do accepts input. In fact it is not a component but a floating parameter, and so it acts just like a regular parameter. Just stick the incoming wire somewhere in where is supposed to be an input bump (which is not drawn)…:


Though this works, it won’t do file searching for you. You have to pass one or more .vrmat file paths, not a folder path.
There a numerous ways to do this.

  1. If you want to pass a folder name and get all .vrmat files in it (the order is not guaranteed), you’d need a small script component. Here is a C# example, but the python code would also be a oneliner
private void RunScript(object Path, object y, ref object A)
    A = System.IO.Directory.GetFiles(Path as string, "*.vrmat", System.IO.SearchOption.TopDirectoryOnly);
  1. You can select multiple files in the Path component and feed the result into a MaterialFromFile parmeter:

  2. You can select multiple files in the Mtl File Path components:

It depends on what your goal is…

Hi Nikolay,

Thank you for your help so much. It was as easy as just plugin in the path to the component. But like you said it is not drawing the input node on it. Therefore it never came to my mind that it would still take in an input.

All tho whilst writing this I am testing it and for some reason I am unable to feed it a file path string?

vrmat.gh (14.1 KB)

Any idea what am I doing wrong?


Jonas Blazinskas

Hi Jonas,

I can’t really tell what the problem is. First off your version seems to be a bit older. Certain components have been upgraded in the latest version. Please update to Update 2.1 (4.20.02) and try again.

On my side opening (and upgrading) your file I see this:

I can assume it is a version problem, unless it is something wrong with that particular vrmat

Also, you don’t need the “Path” intermediate. If you have the means to construct a string for the name, that is good enough to feed into the MaterialFromFile.
*Edit 2
You may try to flatten the Branch component output

Yeah I think I need to update Vray. Thank you for your help Nikolay!