Export Plugin doesn't show?

 
 
 
Posted by:Dwood
Data created:28 March 2011

I created a plugin for exporting files, but it doesn't show up in 3ds max when I click the export option. The plugin using the tutorials, however, works just fine.

I am using 3ds max 2010 and I used the code from a few pages back:

 

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

    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
    {
        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 "Max.NET Test Exporter"; }
        }

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

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

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

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

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

    public class TestExporter : SceneExport
    {
        private IGlobal m_global;

        public TestExporter(IGlobal global)
        {
            m_global = global;
        }

        public override string AuthorName { get { return "Chris Wood"; } }
        public override string CopyrightMessage { get { return "Copyright 2009 MWL"; } }
        public override int ExtCount { get { return 1; } }
        public override string LongDesc { get { return "Test Exporter using Max.NET SDK"; } }
        public override string ShortDesc { get { return "Test Exporter"; } }
        public override uint Version { get { return 1; } }

        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);
        }
    }

 

 

Now it's working.

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

namespace TestExporter
{
    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 "Max.NET Test Exporter"; }
            }

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

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

            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 "Chris Wood"; } }
        public override string CopyrightMessage { get { return "Copyright 2009 MWL"; } }
        public override int ExtCount { get { return 1; } }
        public override string LongDesc { get { return "Test Exporter using Max.NET SDK"; } }
        public override string ShortDesc { get { return "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);
        }
    }
}

preview

 


No luck.... What folder are you putting it in? I'm putting mine in the plugins folder aka

 

C:\Program Files (x86)\Autodesk\3ds Max 2010\plugins

It's the right folder; I put it in the same place. Here is the .dll I compiled as well as the source code. Try it.

 

http://www.mediafire.com/?cpdafcuga98ozct

 

If it still doesn't work open the MaxDotNet utility from Utilities>More... and in the Parameters rollout ensure that "Load Plugins On Startup" has been checked.

 

 

No go. Even though MaxDotNet there is checked. I'm using an education license... could that get in the way? I mean, I'm not above trying to get around it to use the full features of a program I have legally... But I don't have any idea what else could be the problem.

Actually I'm not a developer or learning 3ds max in an official setting, just a hobbyist. Since I am not running an educational version of 3ds max yes you could be right on that point...

Something else I feel you should know. SceneExport and SceneImport plugins written using MaxDotNet cannot be unloaded without restarting 3ds max; I know this because I am writing a SceneImport plugin and Marsel confirmed it in a thread you'll find on this forum (MaxDotNet documentation).

You will doubtless be testing intermediate builds of your exporter before it is finished so to avoid the annoyance of restarting 3ds max every time you may want to compile it as a UtilityObj plugin to start with. Required functionality should be available since UtilityObj plugins have access to an instance of IInterface.

Try to put a breakpoint inside your ClassDesc2 class' constructor (and your export plugin's constructor) and see if it gets called. Or, if you can't attach debugger before it starts loading, try to log to a file. That would rule out if Max.NET finds your class or not.

Marsel Khadiyev (Software Developer, EPHERE Inc.)