MetaData in Max.NET

 
 
 
Posted by:ChrisW
Data created:3 November 2009

Is it possible to create and use MetaData (with IIMetaDataManager and IParamDescriptor) in Max.NET?

Also, what is the Max.NET equivalent of doing say IMetaDataManager::GetInstance() to obtain the manager singleton? I've tried global.GetCOREInterface(global.Interface_ID.Create(0xdcdd1738, 0x15ee4791)) but it won't let me cast the result to IIMetaDataManager. Do you need to create the ID from the raw hex like that or is it predefined somewhere?

You should be able to do Global.IMetaDataManager.Instance but it seems that wasn't exported for some reason. Also, as you mentioned it is not being upcast when creating through CreateInstance. I will look at this further. How urgent is this for you?

In max.net, all global static methods are under IGlobal interface, and all static methods belonging to a class are under IGlobal.ClassName property. So, in case of meta data, it should've been under Global.IMetaDataManager.

Marsel

Marsel Khadiyev (Software Developer, EPHERE Inc.)

I need to prototype an export plugin with meta-data ASAP. Any delays and I'll have to bite the bullet and write our plugins in C++ instead.

 

If meta-data is a problem, can I do the same by writing my own CustAttribs? How would the UI work for this? I want meta-data because it will allow editing in the rollout panel.

Also, is there an established way of working with Max's Tab<> objects? I noticed I have to insert items into tables as IntPtr. Does that mean I need to undermine the GC in order to obtain unsafe pointers to an object in order to put it into a Tab<>? Building meta-data means creating a definition which includes a table of ParamDescriptors.

Hey Chris,

You should be able to do the same with custom attributes. There is no good (bug-free) way of creating them through SDK but I am dealing with them in ZK. Here's some code that I'm copying pasting from my project:

internal static IValue MaxScriptExecute( string str )
        {
            bool res = false;
            IGlobal global = Plugin.Instance.Global;
            //Plugin.Log( "Executing: " + str );
            return global.ExecuteScript( global.StringStream.Create( str ), /*ref */res );
        }

internal static ICustAttrib CreateCustomAttributes( IReferenceTarget destination )
        {
            const string variableName = "temporaryZookeeperVariable";
            MaxScriptExecute( variableName + " = attributes CustomAttributes(parameters main rollout:params(param0 type:#float ui:param0 default:0) rollout params \"Parameters\"(spinner param0 \"Param 1\" type:#float))" );
            MaxScriptExecuteWithReference( "custAttributes.add {reference} " + variableName, destination );
            return MaxScriptExecuteWithReference( "custAttributes.get {reference} ( custAttributes.count {reference} )", destination ).ToReftarg as ICustAttrib;
        }

MaxScriptExecuteWithReference(...) uses a custom plugin I implemented just for keeping references. You can substitute it with any other way of getting at your reftarget from maxscript (for example $.object to get from selection)

If this way doesn't work for you let me know and I'll look into MetaData class.

Marsel

Marsel Khadiyev (Software Developer, EPHERE Inc.)

I'm writing my plugins in C++ for now but I'd like to revisit Max.NET when these issues get ironed-out and the technology becomes more mature. Good luck with it and keep me informed :-)

Hi Chris,

Just to update you, in latest Max.NET build IIMetaDataManager is now accessible through global.IMetaDataManager.Instance. This method wasn't exported due to a little bug in the exporter but now it is, along with many other public static inline methods found in Max SDK.

Cheers,

Marsel

Marsel Khadiyev (Software Developer, EPHERE Inc.)