- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am creating a library in C# that I wish to access through maxscript. I am still in the early stages of this, so one thing I would like to do is send objects to my library, inspect them in the C# code, and print their type, so I know which APIs to use one which objects.
For example, I came up with this:
public static class TypeTranslator
{
public static string TypeOf(object obj) => obj.GetType().AssemblyQualifiedName;
}
I build this DLL, and load the assembly in Max. Then from maxscript, I call it like this:
typeTranslator.TypeOf "hi"
typeTranslator.TypeOf 6These return "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, ..." and "System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, ..." as expected.
However, when I try to send it something like the selected editable mesh, or even a Point3 or #name from maxscript, I get this error: "-- Unable to convert: $GeoSphere001 to type: System.Object"
This has stumped me because I have not encountered objects that are not descended from System.Object before. I do have Autodesk.Max.dll imported into the C# solution as well. I've also tried Autodesk.Max.BaseObject as the parameter type, no go (Maxscript says there's no matching signature)
I'm aware of maxscript's "classof," but how can I inspect the type of an arbitrary object coming from Maxscript in my C# program? Indeed, how can I even accept an object of an unknown type as an argument to one of my C# methods?
Solved! Go to Solution.
