Export plugin crashing Max

 
 
 
Posted by:ChrisW
Data created:27 October 2009

My simple SceneExport derived plugin is crashing Max when I click Export... on the file menu. It doesn't hit any breakpoints in my code so I can't debug it. What should I do?

Hi Chris,

Can you post the (minimal) code of your plugin here?

Marsel Khadiyev (Software Developer, EPHERE Inc.)

    public class Hwnd32 : System.Windows.Forms.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);
        }
    }

Hi Chris,

I've been messing around with it all morning. There seems to be some problem with classdesc. I am not getting a crash, instead nothing happens when I press export (ie. no dialog). IsPublic and ClassName seem to be called as usual, but Create(...) is never called. I will investigate what could be wrong with this a bit later on.

You say your system crashes. Does it produce any meaningful message/exception when it does? I'd like to pin down where that happens.

Marsel

Marsel Khadiyev (Software Developer, EPHERE Inc.)

From the Autodesk Error report:

"Application: 3ds Max    Version: 3ds Max 11 - 64 bits       Error: Unhandled Exception"

 

Attached image of error dialog from Max before it closes itself.

 

 


Attached Files:
Image 1

I get exactly the same result in Max 2009 32-bit and 64-bit versions. Basic geometry and utility plugins appear to work correctly.

Any progress on this?

To be honest I haven't investigated this yet, it is on the todo list though. Currently I'm wrapping up work on Zookeeper which should take another 1-2 weeks and then I'll be able to get back and look at max.net stuff. If this is very urgent for you I can try to find some time in next couple of days, let me know.

Marsel Khadiyev (Software Developer, EPHERE Inc.)

This one can wait. I can just write my stuff as a Utility for now.

Hey,

Has this issue been resolved yet? I just discovered Max.NET. I am attempting to make a simple SceneExport plugin to export models from 3dsmax directly to a custom model format that my game engine can use directly. 

I tried running the code above. When I inherit from a ClassDesc2, 3dsmax simply crashes. When i inherit from ClassDesc i don't get an exception, but the export window won't open. I'm also don't detect any executing of the create method.

I'm running 3dsmax 2010 in 64-bit mode. 

 

MHGameWork

Hi,

I have this next on my TODO list. It will be addressed for next (1.1.9) build. It seems one of the unmanaged methods is throwing an exception and Max.NET doesn't detect it.

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Thanks for the help :D

Ok, fixed. Look for this to be working in the next build (1.1.9).

Cheers

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Thanks alot :D

how to initialize export plugin?

ok

 

I can see the export types of files

thanks

Hi SITT,

I am not sure I understand the question. Please see the code that Chris posted above in this thread.

Marsel Khadiyev (Software Developer, EPHERE Inc.)