3dsmax 2012 and sceneExport

 
 
 
Posted by:gooky
Data created:17 May 2012

Hi all,

I have read the thread on how to create and exporter:

https://www.ephere.com/autodesk/max/forums/general/thread_1181.html

Also I have read the SDK regarding AssemblyMain. In total I have the following code:

using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using Autodesk.Max;
using Autodesk.Max.Plugins;
using System.Windows.Forms;


public static class AssemblyFunctions
{
    public static void AssemblyMain()
    {
        var g = Autodesk.Max.GlobalInterface.Instance;
        var i = g.COREInterface13;
        i.AddClass(new TestExporter.TestExporterDescriptor(g));
    }

    public static void AssemblyShutdown()
    {
    }
}

public class TestExporter : SceneExport
{
    public class Hwnd32 : IWin32Window
    {
        private IntPtr m_hwnd;

        public Hwnd32(IntPtr handle)
        {
            m_hwnd = handle;
        }

        public IntPtr Handle
        {
            get { return m_hwnd; }
        }
    }

    public class TestExporterDescriptor : ClassDesc2        //must be a nested class
    {
        private IGlobal m_global;
        private static IClass_ID s_classID;

        public TestExporterDescriptor(IGlobal global)
        {
            m_global = global;
            s_classID = global.Class_ID.Create(8264, 9283472);
        }

        public override string Category
        {
            get { return "A Test Exporter"; }
        }

        public override IClass_ID ClassID
        {
            get { return s_classID; }
        }

        public override string ClassName
        {
            get { return "ATestExporter"; }
        }

        public override object Create(bool loading)
        {
            return new TestExporter(m_global, this);
        }

        public override bool IsPublic
        {
            get { return true; }
        }

        public override SClass_ID SuperClassID
        {
            get { return SClass_ID.SceneExport; }
        }
    }

    private IGlobal m_global;
    private TestExporterDescriptor m_ClassDesc;

    public TestExporter(IGlobal global, TestExporterDescriptor descriptor)
    {
        m_global = global;
        this.m_ClassDesc = descriptor;
    }

    public override string AuthorName { get { return "Lasse Johansen"; } }
    public override string CopyrightMessage { get { return "Copyright 2009 MWL"; } }
    public override int ExtCount { get { return 1; } }
    public override string LongDesc { get { return "A test Exporter using Max.NET SDK"; } }
    public override string ShortDesc { get { return "A test Exporter"; } }
    public override uint Version { get { return 100; } }            //multiply version number by 100 here

    public override int DoExport(string name, IExpInterface ei, IInterface i, bool suppressPrompts, uint options)
    {
        MessageBox.Show(new Hwnd32(i.MAXHWnd), "TestExporter.DoExport() called");
        return 1;
    }

    public override string Ext(int n)
    {
        return "SMS";
    }

    public override string OtherMessage1()
    {
        return String.Empty;
    }

    public override string OtherMessage2()
    {
        return String.Empty;
    }

    public override void ShowAbout(IntPtr hWnd)
    {
        MessageBox.Show(new Hwnd32(hWnd), LongDesc, "About " + ShortDesc);
    }
}

I have put the dll inside the bin\assemblies folder. However when I try to export, 3dsmax crashes. I have tried with ephere max.net and the 3dsmax sap, both with same result. Anyone made an exporter using max.net?

P.s. I use 3dsmax 2012 32 bit version