Search code examples
c#maxscriptmethod-signature

How do I pass a 3dMax mesh from a maxscript funtion a C# function?


I have a mesh that's created in a maxscript script.
And I want to pass it to my C# code, I just can't get the right function signature apparently...
It works with a void function (code is called, I get a breakpoint, string is passed back to 3dMax)

I load my DLL, create my object, and try to pass the mesh to the function, but I get the following error:

MAXScript MacroScript Error Exception: -- Runtime error: No method found which matched argument list <<

My maxscript code that loads the DLL:

newMesh = mesh vertices:verts faces:faces   

dotnet.loadassembly ( dllDir )

ThisTestObject  = dotnetobject "_3dMaxExporter.Test" "test"

myText = ThisTestObject.TestFunc newMesh 

C# code:

    public string TestFunc(Autodesk.Max.IMesh test)
    {
       return ("You can call me " + Name + "!");
    }

Any idea what type i need to have in my signature?


Solution

  • Either UIntPtr or IntPtr. UIntPtr if you want to pass it via handle (getHandleByAnim MAXScript side, GetAnimByHandle(UIntPtr handle) .NET side), IntPtr if you want to pass it via its address (refs.getAddr MAXScript side, MarshalNativeToManaged method of Wrappers.CustomMarshalerMesh .NET side).