Having Trouble with .NET SDK Wrapper Plug-in Examples in Autodesk Docs

966 views
Skip to first unread message

Jared Smith

unread,
Jan 3, 2012, 7:57:53 PM1/3/12
to 3ds Max Developer Community
Hi, I have to say I'm pretty excited about being able to write tools
in C# using the SDK, but I can't for the life of me figure out why
this plug-in will not load in max. It always fails on assembly load.
I've tried to follow what was in the docs as best as I can, I'm new to
the SDK so I'm assuming there's something about how the class
descriptor is supposed to be handled that is escaping me.



using System;
using Autodesk.Max;
using Autodesk.Max.Plugins;

namespace NetPluginTests
{
public static class AssemblyFunctions
{
public static void AssemblyMain()
{
var g = Autodesk.Max.GlobalInterface.Instance;
var i = g.COREInterface13;
i.AddClass(new TestPlugin01.Descriptor(g));
}

public static void AssemblyShutdown()
{

}
}

public class TestPlugin01 : Autodesk.Max.Plugins.UtilityObj
{
public class Descriptor : Autodesk.Max.Plugins.ClassDesc2
{
protected IGlobal _global;
internal static IClass_ID _classID;

public IGlobal Global
{
get { return this._global; }
}

public Descriptor(IGlobal global)
{
this._global = global;
_classID = _global.Class_ID.Create(0x8962d7,
0x285b3ff9);
}

public override string Category
{
get { return "NetPluginTests"; }
}

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

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

public override object Create(bool loading)
{
return new TestPlugin01( this );
}

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

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

Descriptor _descriptor;

public TestPlugin01(Descriptor descriptor)
{
this._descriptor = descriptor;
}

public override void BeginEditParams(IInterface ip, IIUtil iu)
{
ip.PushPrompt("This is a prompt msg :D");
}

public override void EndEditParams(IInterface ip, IIUtil iu)
{
ip.PopPrompt();
}
}
}

Christopher Diggins

unread,
Jan 7, 2012, 9:55:16 AM1/7/12
to 3ds-max-d...@googlegroups.com
Hi Jared,

Sorry for the delay in responding. Do you have 3ds Max 2012 with the subscription advantage pack? Are you placing the assembly in "bin\assemblies"? When compiled have you set the project settings for Autodesk.Max.dll and Autodesk.Max.Plugins.dll assemblies so that copy local is false (see the properties of the references using the solution explorer).

Hope this helps,
Christopher Diggins  

jaredsmi...@gmail.com

unread,
Jan 10, 2012, 9:05:21 AM1/10/12
to 3ds-max-d...@googlegroups.com
The problem turned out to be getting the instance of the global interface in the assembly loader hooks.

Autodesk.Max.GlobalInterface.Instance

That actually turns out to be returning null, so the plugin could never register. Placing the dll file in the stdplugs folder seems to fix this. I don't think this is correct but it's just what I'm seeing on my end.

Christopher Diggins

unread,
Jan 10, 2012, 9:09:26 AM1/10/12
to 3ds-max-d...@googlegroups.com
This is very strange. Which DLL did you move? Could you tell me where the various DLLs are?
Autodesk.Max.dll
Autodesk.Max.Wrappers.dll
Autodesk.Max.Plugins.dll
YourDll.dll
You may have multiple copies of these guys.
 
Thanks,
Christopher

Jared Smith

unread,
Jan 19, 2012, 6:41:25 PM1/19/12
to 3ds Max Developer Community
The Autodesk.Max.dll is located in 3ds Max 2012 root,
Autodesk.Max.Wrappers.dll is in the bin\assemblies folder, I don't
appear to have Autodesk.Max.Plugins.dll and my dll is in the stdplugs
folder.

On Jan 10, 9:09 am, Christopher Diggins <cdigg...@gmail.com> wrote:
> This is very strange. Which DLL did you move? Could you tell me where the
> various DLLs are?
> Autodesk.Max.dll
> Autodesk.Max.Wrappers.dll
> Autodesk.Max.Plugins.dll
> YourDll.dll
> You may have multiple copies of these guys.
>
> Thanks,
> Christopher
>
>
>
> On Tue, Jan 10, 2012 at 9:05 AM, <jaredsmithketc...@gmail.com> wrote:
> > The problem turned out to be getting the instance of the global interface
> > in the assembly loader hooks.
>
> > Autodesk.Max.GlobalInterface.Instance
>
> > That actually turns out to be returning null, so the plugin could never
> > register. Placing the dll file in the stdplugs folder seems to fix this. I
> > don't think this is correct but it's just what I'm seeing on my end.
>
> > On , Christopher Diggins <cdigg...@gmail.com> wrote:
> > > Hi Jared,
>
> > > Sorry for the delay in responding. Do you have 3ds Max 2012 with the
> > subscription advantage pack? Are you placing the assembly in
> > "bin\assemblies"? When compiled have you set the project settings for
> > Autodesk.Max.dll and Autodesk.Max.Plugins.dll assemblies so that copy local
> > is false (see the properties of the references using the solution explorer).
>
> > > Hope this helps,
> > > Christopher Diggins
>
> > > On Tue, Jan 3, 2012 at 7:57 PM, Jared Smith jaredsmithketc...@gmail.com>

Jean-François Pérusse

unread,
May 24, 2012, 11:58:02 PM5/24/12
to 3ds-max-d...@googlegroups.com
Hi,

I had the same problems in Max 2013, and after hours of search, I realized it could be because of my DLL name which started with 3ds (3dsMax_MyPlugin.DLL).

I suspected that it was thus being loaded too early and that was the case!

Renaming the DLL to MyPlugin.DLL solved it. The GlobalInterface Instance would not be NULL anymore.

I wonder if you were having the same issue.

I hope this can help other people in the future, it would also be nice if this was documented as part of Lesson7!

Thanks.

Christopher Diggins

unread,
May 27, 2012, 8:03:57 AM5/27/12
to 3ds-max-d...@googlegroups.com
Thank you very much for reporting this.

Cheers,
Christopher
Reply all
Reply to author
Forward
0 new messages