Hi all. Long time reader first time poster, and hoping someone can help point me in the right direction.
I’m writing scripts to go from Vray/3ds max to Maya/Arnold and the first part of that process is to leverage the scene converter inside 3ds to convert the Vray scene to arnold. I’m working through the different map types/scenarios and have got stuck on the vray multisubtex map. I’ve chosen to convert this to an osl 1 in n color map, for which i’m dynamically generating the osl code based on the number of layers in the multisubtex map which is all fine. The issue i’m having is when I’m trying to repoint the maps from the multisubtex map to the osl map. The code works when I test it locally in the editor, but fails when run via the scene converter. The error I’m getting is
– MAXScript Conversion Manager Exception:
– Unknown property: “texmap” in undefined
– MAXScript callstack:
– thread data: threadID:38032
– [stack level: 0]
– In i loop; filename: Y:\DEV\SCRIPTS\DEV\AssetConverter\DEV\AssetConverter_v010.ms; position: 36; line: 1
– i: 1
– i: 1
– OSLnumber: 0
– OSLcmd: “aiSSurface.I0_map = source.texmap”
– source: Free:source : Map #7:VRayMultiSubTex
– owner: undefined
I believe that this is because I am using execute to run the script which always runs in the global scope so it’s losing reference to the local variables here
if (source.texmap[i] != undefined) do ( OSLnumber = i - 1 OSLcmd = ("aiSSurface.I" + (OSLnumber as string) + "_map = source.texmap[" + (i as string) + "]") execute OSLcmd )
As a new user I’m not allowed to attach the full script for reference apparently, so here’s the function that’s called. I took one of the existing conversion scripts as a base, hence the odd naming, but in this instance aiSSurface is the newly created osl 1 in n map and source is the vray multisubtex map.
fn SetBaseColor aiSSurface source =
– MATERIAL ID
if source.from_id == 0 do – if multisub is set to get ID from face material ID do this
for i=1 to source.texmap_num do – go through the osl map layers and add inputs
if (source.texmap[i] != undefined) do
OSLnumber = i - 1
OSLcmd = (“aiSSurface.I” + (OSLnumber as string) + “_map = source.texmap[” + (i as string) + “]”)
) matIDmap = OSLMap () -- create OSL Map matIDmap.name = "Material ID" -- change material id map name matIDmap.OSLPath = "C:\Program Files\Autodesk\3ds Max 2023\OSL\GetMtlID.osl" -- Set OSL map to use Material ID outputMap = MultiOutputChannelTexmapToTexmap sourceMap:matIDmap outputChannelIndex:2 -- output map between matID map and 1 t N map aiSSurface.Index_map = outputMap -- set 1 to N map index to use output map )
I can’t think of a way around this at the moment so if anyone has any thoughts I would greatly appreciate some input.
Thanks in advance for the help!