[Closed] .NET – SimpleObject2
Dear community,
I’m trying to create a c# plugin by extending SimpleObject2. I’ve read that one shouldn’t extend from the Autodesk.Max.Plugins namespace but also read that some classes can be inherited from so I gave it a try. The result is: Max always crashes no matter what I try. Sometimes directly on start, sometimes when the dll is loading. I don’t get it done.
The question I have is: has anybody created a working SimpleObject2 plugin in c#? If so: could you lead me to the right direction?
Thanks in advance!
Thank you very much for answering that fast!
I’ve studied ephere.com a while ago but things that seem to work there do not work when using the “new/adopted/regular” Max .NET SDK…
I didn’t try to use it with loadAssembly because I thought that does exactly the same but thank you for pointing me in that direction!
The question on where it crashes isn’t easy to answer. I’ve changed things up and down and it crashed on different parts even using the absolutely minimalistic version of implementation.
I’ve mainly used a slightly changed version of your “ScriptCustomAttrib” plugin btw.
Brilliant! I absolutely have no clue why it must be that hard to get things done…
As far as I can tell the loadAssemly trick does work! At least Max doesn’t crash anymore and the object shows up in the create panel!
Let’s see if I can create a mesh this way and show it in the viewport.
THANK YOU!!!
This works! The only problem is Max crashing when saving the scene or exiting while the object has been created.
Do you get any error message?
If you want, send me your files and I’ll try to help you.
Thank you,
I’ve attached the solution. It’s a slightly modded version of ephere’s Plane plugin:
Link to c# solution
Usage:
Update references and in project’s settings change the “Post-build event” in “Build Events” to the directory you need.
Maxscript (for example):
local assemblyFile = @“Plane.dll”
local AssemblyLoader = (dotnetClass “System.Reflection.assembly”).Load ((dotnetClass “System.IO.File”).ReadAllBytes assemblyFile)
local PlaneType = AssemblyLoader.GetType(“PlaneNamespace.PlaneInitializer”)
local Plane = (dotNetClass “System.Activator”).CreateInstance PlaneType
Oh, and if someone knows a fix:
The strings for the parameter block are not encoded correctly! At least in 3D Studio Max 2013. Must have something to do with the unicode changes of Autodesk…
Thank you very much!
I’ve checked the save problem again. It seems this is also okay now when loading the DLL from MaxScript! (crazy… I wish I knew that before. THANK YOU again!!!)
BUT: if an object has been created and you close 3dsMax it crashes…
EDIT:
I fixed it by overriding “AutoDelete”:
public override RefResult AutoDelete() => RefResult.AutoDelete;
Now 3dsMax does not crash anymore. Is this a good idea or should I do anything else?