Convert to TriObject

 
 
 
Posted by:MichiMichbeck
Data created:1 June 2010

Hey, I am trying to convert a GeomObject to a TriObject in Max.Net. I am using this code:

if (os.Obj.CanConvertToType(global.TriObjectClassID) != 0)

{
                ITriObject triObjConv = (ITriObject)(os.Obj.ConvertToType(0, global.TriObjectClassID));

}

At runtime Max.Net throws an exception: "Object of type Autodesk.Max.Wrappers.GeomObject" can not be converted to type "Autodesk.Max.ITriObject".
The reason is that the ConvertToType method return an object of type "GeomObject" - but actually the method is asked to deliver an ITriObject as the classID is given as argument. Is there a mistake in Max.Net or must it been done in a different way?

Thx ind advance
Greets, Michbeck

Hi Mitchbeck,

I think this is the same issue as http://ephere.com/autodesk/max/forums/general/thread_960.html

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Yes I guess this is the same issue, but there was no solution found in this thread either, was it?

I tried to set the ClassID given in this thread but it didnt work. Actually I tried the following:

         ITriObject triObj = this.global.CreateNewTriObject;

         IClass_ID objID = triObj.ClassID;

         IClass_ID triObjID = global.TriObjectClassID;

 

Both ClassID's (tribObjID and objID) are different: objID = ( 3830386867 , 0 ) , triObjID = ( 9 , 0 ). So ClassID's for different triObject should always be equal, right? Is that somehow the root of the problem?

Thx,Regards
Michbeck

The solution doesn't exist in current build, however, I already fixed it and it should be working in next build. The reason is that returned objects are of editable mesh or editable poly types (rather than triobject or polyobject).

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Thank you very much Marsel - I am looking forward to getting the next build :)

Greets

The new build is up, give it a try when you can and let me know if it fixed the problem.

Cheers

Marsel Khadiyev (Software Developer, EPHERE Inc.)