[Closed] Open dotNet Form with Maxscript
Hello to everyone. I am trying to open the test Form written on C# with max script, but i cous`nt find out how to do that.
I pleaced the dll file into “3ds Max 2014\bin\assemblies” and i know that it is loaded without any errors. How could i open the Form with the script?
You have to load it as a dotNetObject, with your namespace and class names:
myForm = dotNetObject "MyNameSpace.MyClass"
myForm.show() --Windows form
myForm.showModeless() --Maxform
If you just want to show a form, there is no need to place the dll in the max installation folder. You can simply load it from any desired location and do the same:
dotNet.loadAssembly "C:\MyLocation\MyDll.dll"
myForm = dotNetObject "MyNameSpace.MyClass"
myForm.show() --Windows form
myForm.showModeless() --Maxform
That should get you started
public void Initialize(IGlobal global, System.ComponentModel.ISynchronizeInvoke sync)
{
SplineAlignDialog dialog = new SplineAlignDialog (global);
dialog.Show();
}
This code shows the simple Form With the button.
But how could i open it from 3ds max? Without writing code “dialog.Show();” right after it is being created?
This is the First tutorial form here : http://www.ephere.com/autodesk/max/
I believe you have to call the show() function.
If you want it to open it automatically you would have to add a start-up script that will load the assemblies and then call the function.
Call it from a maxscript located in the startup folder. What are you trying to achieve though? If you are trying to show something once 3ds Max has loaded, try checking out point 25 here: https://area.autodesk.com/blogs/chris/25-things-you-probably-didn039t-know-about-the-3ds-max-sdk
Thanks a lot about the last link!
I am trying to write a plugin with C# user could call in any time.
Like Material Editor Or Particle View.
Ok I get it! you followed the ephere tutorial and that shows how to set it up so that your UI opens automatically and now you want it so that instead the user opens the UI by clicking a button or by just calling a function.
You can do this. (Sorry in advance I am not an expert on c#).
first off remove this code:
public void Initialize(IGlobal global, System.ComponentModel.ISynchronizeInvoke sync)
{
SplineAlignDialog dialog = new SplineAlignDialog (global);
dialog.Show();
}
This way it wont auto load the UI on max start up.
Now you can do what Tim suggested and use the following maxScript:
myForm = dotNetObject "SplineAlign.SplineAlignDialog"
myForm.show() --Windows form
Hopefully someone will correct me if I am wrong.
Yes! Thanks for the understanding))
There are the errors:
-- Error occurred in anonymous codeblock; filename: ; position: 54; line: 1
-- Runtime error: No constructor found which matched argument list: SplineAlign.SplineAlignDialog
-- Error occurred in anonymous codeblock; filename: ; position: 83; line: 2
-- Unknown property: "show" in undefined
Maybe i should add some references?
I attached the “dll” file.
If I get some time I will try and actually look into it, Not able to open up my visual studio right now.
I am sure its a small oversight on my part