Hello,
I’m trying to use IIUnwrapMod but I’m having difficulties actually getting a hold of the object. The help says that I need to call the macro GetFPInter(f)ace(UNWRAP_INTERFACE). I’ve looked at this in the samples and it looks like this:
GetIUnwrapInterface(cd) \
(IUnwrapMod *)(cd)->GetInterface(UNWRAP_INTERFACE)
So I have the following C# code:
var UNWRAP_INTERFACE = GlobalInterface.Instance.Interface_ID.Create(0x53b3409b, 0x18ff7ab8); //taken from the iunwrap.h
var uvmapMod = (IModifier)GlobalInterface.Instance.COREInterface.CreateInstance(SClass_ID.Osm, GlobalInterface.Instance.Class_ID.Create(0x02df2e3a,0x72ba4e1f)); //Create new unwrap mod
var unwrapBaseInterface = (IIUnwrapMod)uvmapMod.GetInterface(UNWRAP_INTERFACE);
Unable to cast object of type 'Autodesk.Max.Wrappers.BaseInterface' to type 'Autodesk.Max.IIUnwrapMod'.
I also tried getting the Unwrap modifier from the object, instead of creating a new one:
var derivedObject= _node.ObjectRef as IIDerivedObject
IModifier unwrapMod = derivedObject.Modifiers[0];
I have tried the same code in C++ and it seems to work:
INode* node = ip->GetSelNode(0);
Object* pObject = node->GetObjectRef();
IDerivedObject* pDerivedObject = (IDerivedObject*)pObject;
Modifier* modifier = pDerivedObject->GetModifier(0);
//IUnwrapMod* unwrapMod = GetIUnwrapInterface(modifier); //don’t have this macro in C#
IUnwrapMod* unwrapMod = (IUnwrapMod *)(modifier)->GetInterface(UNWRAP_INTERFACE);
unwrapMod->fnOptions();
Any ideas what I can do here?
Thanks,
Vin