Notifications
Clear all

[Closed] SDK BaseInterface to IIUnwrapMod

Hello,

I’m trying to use IUnwrapMod to get information from my UVW Unwrap modifier, it’s working in C++, but it doesn’t work when I use similar code in C# using the .net wrapper (Autodesk.Max.dll). (Max 2015)

INode* node = ip->GetSelNode(0);
Object* pObject = node->GetObjectRef(); 
IDerivedObject* pDerivedObject = (IDerivedObject*)pObject; 

Modifier* modifier = pDerivedObject->GetModifier(0);

//IUnwrapMod* unwrapMod =  GetIUnwrapInterface(modifier);
IUnwrapMod* unwrapMod =  (IUnwrapMod *)(modifier)->GetInterface(UNWRAP_INTERFACE);
unwrapMod->fnOptions();

I commented out the macro because I don’t have it in C#, just so that everything is the same.

var node = GlobalInterface.Instance.COREInterface.GetINodeByHandle(handle);
var obj = node.ObjectRef;
var derivedObject = obj as IIDerivedObject;

IModifier modifier = derivedObject.GetModifier(0);
var unwrapMod = (IIUnwrapMod)modifier.GetInterface(UNWRAP_INTERFACE);

I get the exception: “Unable to cast object of type ‘Autodesk.Max.Wrappers.BaseInterface’ to type ‘Autodesk.Max.IIUnwrapMod’.”

I copied the interfaceID from C++:

var UNWRAP_INTERFACE = GlobalInterface.Instance.Interface_ID.Create(0x53b3409b, 0x18ff7ab8);

Does anybody know what I need to do to cast BaseInterface to IIUnwrapMod in C#?

Thanks

1 Reply

Has anyone succeed in casting to IIUnwrap?