Max Remoting

 
 
 
Posted by:Vincentt
Data created:22 November 2016

Hello,

I recently watched your video about Max remoting and found it very interesting. I'm using Max 2015 and it seemed to work alright, except I've hit an issue now, converting my IObject (RObject?) to ITriObject (RTriObject?). The following code works when I load my assembly in Max. The node is of type editable mesh. 

IManager manager = (IManager) Activator.GetObject((typeof (Autodesk.Max.Remoting.RManager)), "tcp://localhost:9995/Manager");

IINode node = manager.Global.COREInterface.GetSelNode(0);
IObjectState os = node.EvalWorldState(manager.Global.COREInterface.Time, true);
IObject osObj = os.Obj;

string osObjClassName = osObj.ClassName; //Editable Mesh
uint partA = osObj.ClassID.PartA; // 3830386867 (B is 0)

ITriObject obj = (ITriObject)osObj; //Unable to cast transparent proxy to type 'Autodesk.Max.ITriObject'.

So the last line where I cast osObj to ITriObject is where the exception is thrown. I've tried a few other things too:

ITriObject obj = (Autodesk.Max.Remoting.RTriObject)osObj; // Unable to cast transparent proxy to type 'Autodesk.Max.Remoting.RTriObject'.

 

ITriObject obj = (dynamic)osObj; // Cannot implicitly convert type 'Autodesk.Max.Remoting.RObject' to 'Autodesk.Max.ITriObject'. An explicit conversion exists (are you missing a cast?)

 

I also tried this with Max 2012 and it also fails. Do you have any idea what I can do here?

 

Thanks!
Vin

Hi Vin,

Can you do a print of osObj.GetType().ToString() to see which type it is? It looks like it is RObject (from last comment), which means that it was not automatically up-case to RTriObject and thus you can't cast it to that interface. Don't remember if there's an explicit way of upcasting inside the remoting lib (I haven't touched or used it in a very long time).

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Hey Marsel,

Thanks for the reply! osObj is indeed of type RObject ({Name = "RObject" FullName = "Autodesk.Max.Remoting.RObject"}).

I would like to find out if there is an explicit way of upcasting this RObject to RTriObject. If you would remember, that would be great.

Thanks,
Vin