.NET - SimpleObject2

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

REPLY TO THREAD
 
Thread Tools Display Modes
  06 June 2018
.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!
 
  06 June 2018
Have you seen the Geometry example from Ephere? 
__________________
Andrés FC.
P3D_PathScripts

Last edited by aaandres : 07 July 2018 at 11:13 AM.
 
  06 June 2018
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. 
 
  06 June 2018
..........
__________________
Andrés FC.
P3D_PathScripts

Last edited by aaandres : 07 July 2018 at 11:14 AM.
 
  06 June 2018
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. 
 
  06 June 2018
THANK YOU!!!
This works! The only problem is Max crashing when saving the scene or exiting while the object has been created.
 
  06 June 2018
Do you get any error message?
If you want, send me your files and I'll try to help you.
__________________
Andrés FC.
P3D_PathScripts
 
  06 June 2018
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!

Last edited by 48design : 06 June 2018 at 10:05 AM.
 
  06 June 2018
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?

Last edited by 48design : 06 June 2018 at 01:58 PM.
 
  06 June 2018
............
__________________
Andrés FC.
P3D_PathScripts

Last edited by aaandres : 07 July 2018 at 11:15 AM.
 
  06 June 2018
I've changed the link. Thanks for your help!
About the characters: I'm trying to understand what you mean but don't really get it. Do you mind posting some code? I could also wait for your github release... 
 
  06 June 2018
........................
__________________
Andrés FC.
P3D_PathScripts

Last edited by aaandres : 07 July 2018 at 11:15 AM.
 
  06 June 2018
Thanks for checking!

I fear I can't switch to Max 2014 because I need as much backwards compatibility as I can get. 
Those parameter strings drive me crazy. I think the best will be to completely switch over to a custom WPF window on BeginEditParams and EndEditParams.
 
  06 June 2018
Originally Posted by 48design: Those parameter strings drive me crazy. I think the best will be to completely switch over to a custom WPF window on BeginEditParams and EndEditParams.
It's possibly the better solution. I would like to see it.
__________________
Andrés FC.
P3D_PathScripts

Last edited by aaandres : 07 July 2018 at 11:18 AM.
 
  06 June 2018
................
__________________
Andrés FC.
P3D_PathScripts

Last edited by aaandres : 07 July 2018 at 11:18 AM.
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:54 AM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.