Vray mesh export doesn't export materials.

Even with the “Create Multi/Sub-Object Mtl” box checked, the proxy comes in with no material. I’ve tried this with various objects but still can’t get the materials to work.

This is the first time I’ve tried to do this in 3.4 but in previous versions it worked no problemo. If I check “Automatically create proxies”, the materials are there on the object. However, if I a create a Vray Proxy then import the vrmesh file, it does not.

Since the initial implementation V-Ray Proxy feature it supports only geometry and it doesn’t support materials.
When Automatically Create Proxies option is enabled V-Ray applies the materials of the original geometry to the imported V-Ray Proxy objects automatically but the material is again not exported the to V-Ray Proxy file. If you would like to manually import V-Ray Proxy files you should also manually assign its material, it works this way in any V-Ray version.

I would like there to be an option to create a .mat file automatically when you create a vrmesh file, or even a DCC agnostic .vrmat would be very cool too, then we could send assets from max to maya to nuke much easier :slight_smile:

Many + to this one, would be super cool to export material along with proxy. It should not be that hard to implement - export .mat along with proxy ?

Here’s some functions that do that:


fn exportVrMeshAndMat theObj =	
(
	theName = theObj[1].name
	TheVrFilename = getSaveFileName filename:theName types:"Vrmesh(*.vrmesh)"
	theVrmesh = vrayMeshExport meshfile:(TheVrFilename + ".vrmesh") autoCreateProxies:true exportMultiple:false createMultiMtl:true
	-- theProxy = getNodebyName ("vrayProxy_" + theObj.name)
	theVrmesh[1].material.name = ((getFilenameFile TheVrFilename) + "_proxy")

	if classof theVrmesh[1].material == multimaterial then
	(
		for m = 1 to theVrmesh[1].material.count do
		(
			theVrmesh[1].material[m].name = ((getFilenameFile TheVrFilename) + "_" + theVrmesh[1].material[m].name)
		)
	)

	theMats = materialLibrary theVrmesh[1].material
	saveTempMaterialLibrary theMats (TheVrFilename + ".mat")
)

exportVrMeshAndMat (selection as array)

fn importVrMeshAndMat =
(
	theFile = getOpenFileName caption:"Pick a vrmesh file:" types:"Vrmesh(*.vrmesh)"
	theVrmesh = VRayProxy fileName:theFile
	theMatlibName = (substituteString theFile ".vrmesh" ".mat")
	print theMatlibName
	theMats = loadTempMaterialLibrary theMatlibName
	print theMats
	theVrmesh.material = theMats[1]
	theVrmesh.name = "vr_" + getFilenameFile theFile
)

importVrMeshAndMat()

We’ve got an environment artist in here that’s come from a far better company that uses shotgun for version control and scene update, I’m going to add a few bits to this so that the version of the vrmesh loaded into your max scene uses user defined properties as a simple record of the loaded version. We can then do another script which can check what version your scene has compared to what’s in the folder the vrmesh is loaded from and then maybe do something like leave a selection of the objects that can be updated or change their wirecolour to red, then you can choose to update to the latest version or not.

Sorry for reviving an old thread but could someone help to expand on the code joconnell posted above? I’m not good with scripting. I’m wondering if it’s possible to allow the user to select multiple .vrmesh files in the open dialog box and apply the code to all selected files. Also, to fix error in the script if the user cancels the open dialog box. Appreciate the help. Thanks.

fn importVrMeshAndMat =
(
theFile = getOpenFileName caption:"Pick a vrmesh file:" types:"Vrmesh(*.vrmesh)"
theVrmesh = VRayProxy fileName:theFile
theMatlibName = (substituteString theFile ".vrmesh" ".mat")
print theMatlibName
theMats = loadTempMaterialLibrary theMatlibName
print theMats
theVrmesh.material = theMats[1]
theVrmesh.name = "vr_" + getFilenameFile theFile
)

importVrMeshAndMat()

@Horizon I’m on it

This is the modified version that should do the job:


fn importVrMeshAndMat =
(
   openDiag = dotNetObject "System.Windows.Forms.OpenFileDialog"
   openDiag.Title = "Pick vrmesh file(s)"
   openDiag.Filter = "Vrmesh(*.vrmesh)|*.vrmesh"
   openDiag.Multiselect = true
   clickedAction = openDiag.ShowDialog()
   if clickedAction.Equals clickedAction.OK then
   (
      selectedFiles = openDiag.filenames
      for each in selectedFiles do
      (
         theVrmesh = VRayProxy fileName:each
         theMatlibName = (substituteString each ".vrmesh" ".mat")
         print theMatlibName
         theMats = loadTempMaterialLibrary theMatlibName
         print theMats
         theVrmesh.material = theMats[1]
         theVrmesh.name = "vr_" + getFilenameFile each
      )
   )
   else (print "Cancelled!")
)
importVrMeshAndMat()

Sorry for the late reply…I’m recovering from surgery. I just wanted to say you’re awesome! That works perfectly. This will really speed up my workflow. Thanks so much for your help Miroslav.

You’re welcome and have a speedy recovery!