Notifications
Clear all

[Closed] .NET and it's Implications for Maxscript [Max 9]

Good to know that!. Our last 3D game engine was developed entirely in C# + Managed DirectX and it worked great.

Hey, that was one of the doubts I had. So you can use normal MXS functions as event handlers/callback functions. Great!.

I wish they would create a C# wrapper for the SDK but I think this is something that carry a lot more work (and maybe a lot of headaches). Do exists plans for that?. I used to code in C++ but since I tried C#, is a pain to go back to C++ (but sometimes it’s irremediable).

Thanks.

As of now, I wouldn’t want that to happen. The SDK needs a little polishing up to clean up the rust from 6 years of being locked.

Chris J.

Bobo,

Thanks for clarifying… much appreciated and relieved. I’m not against adding additional options or functionality, obviously. I was just scared that Maxscript had just become much more complicated than it used to be. Now I can try to expand my knowledge and scripts as time permits.

I see you’ve spotted my fiery temperment .

Cheers, and regards,

Maneswar

Well i agree, this is a big one!

What alpine said really has the biggest impact on the way you develope tools and interfaces in max. personally i will never write a rollout again, except for custom attributes.

you can now use .NET forms to write your complete UI. this includes very very easy to manage tabbed interfaces, just to mention one very basic example.

the biggest advantage of .NET forms over classic rollouts is their openness. anyone who ever had to dynamically generate rollout code using strings and ‘execute’ knows what i mean. (this is probably every intermediate maxscript user)

the next biggest thing (this is one of the things that i would consider ‘the whole distance and then some’, to quote bobo) is that you can actually store maxscript values on .NET classes using their .tag property.

e.g. let’s say you write a controller tool using .NET treeview, you can store the controllers on their corresponding tree nodes/leafs. very similar to what you can do with kees’ helium.

also, .NET controls have dozens of event handlers, instead of 1 or 2 for some maxscript ui controls. if you ever wanted a right click event handler for some button, this is your solution.

way to go autodesk!

to really get an idea of what is possible now, you might want to take a look at paint.net on the microsoft site, which is written with .NET. with maxscript, .Net and some C# additions you can do all of this in max now.

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

Rollouts are just the beginning.
BEHOLD! :buttrock:
http://www.scriptspot.com/bobo/mxs9/dotNet/UsingTheClipboard.html
(more examples of DotNet usage coming…)

Also see my WIP reference of most Forms and classes referenced by them:
http://www.scriptspot.com/bobo/mxs9/dotNet/DotNetControls.html

I think this is all good, but people who writes code that support more than 1 max version will not be able to put them into use, right?

Only for tools that need to work under max 9 and forward, which is good too.

Light

Hot damn you’re quick Bobo.

Awesome. I can see this being fun already.

awesome!

i need to get that clr book right now…

bobo, can you maybe show an example of how to use the visualstylerender/visualstyleelement classes to draw controls with visual styles in max?

Hi all,

Yes it’s a pretty good new feature. I’ll do some interestings scripts…
I’m a software programmer and I love .Net and C# a lot. I’m preparing some tutorials and articles on the use of .Net with maxscript.

Aearon, you can try :

(
	fn whenButtonIsPressed a b = 
	(
		format "Pressed from a DotNet Button
"
		format "Argument a (Form): <%> 
" (classof a)
		
		format "Properties:
"
		showproperties a
		
		format "Methods:
"
		showmethods a
		
		format "Events:
"
		showevents a
		
		format "
Argument b (Button): <%> 
" (classof b)
		
		format "Properties:
"
		showproperties b
		
		format "Methods:
"  
		showmethods a
		
		format "Events:
"  
		showevents a
	)
	
        -- Access application to enable visual styles
	hApp = dotNetClass "System.Windows.Forms.Application"
	hApp.EnableVisualStyles() -- Enable Office 2005/.Net 2.0 style

	--Create a DotNet Button
	mButton = dotNetObject "System.Windows.Forms.Button"
	mButton.text = "BIG DotNet Button"
	mButton.size = dotNetObject "System.Drawing.Size" 160 160
	mButton.location = dotNetObject "System.Drawing.Point" 60 60
	
	-- Create a DotNet Form
	hForm = dotNetObject "System.Windows.Forms.Form"  
	hForm.controls.add mButton --add the Button to the Form
	hForm.topmost = true
	
	--Add an Event Handler for the click event:
	dotNet.addEventHandler mButton "click" whenButtonIsPressed 
	hForm.show() --show the Form with the Button
)

I’ve modified the .Net form example from MAXScript Reference.

Yannick

What about a .Net 2.0 form with a menu ?!

(
	fn OnExit =
	(
		hApp = dotNetClass "System.Windows.Forms.Application"
		hApp.Exit()  -- Close and exit form application
	)
	
	-- Access application to enable visual styles
	hApp = dotNetClass "System.Windows.Forms.Application"
	hApp.EnableVisualStyles() -- Enable Office 2005/.Net 2.0 style
	
	-- Create menu and menu items
    mMenu = dotNetObject "System.Windows.Forms.MenuStrip"
    mFileMenu = dotNetObject "System.Windows.Forms.ToolStripMenuItem"
    mExitMenu = dotNetObject "System.Windows.Forms.ToolStripMenuItem"
    mFileMenu.Text = "File";
    mExitMenu.Text = "Exit";
    
    -- Add file menu item to menu
    mMenu.Items.AddRange(#(mFileMenu))
    
    -- Add exit menu item to file menu
    mFileMenu.DropDownItems.AddRange(#(mExitMenu))
    
    -- Create a DotNet Form
    hForm = dotNetObject "System.Windows.Forms.Form"
    hForm.Size = dotNetObject "System.Drawing.Size" 300 300
    hForm.Text = ".Net 2.0 Form with Menu"
    hForm.Controls.Add(mMenu)     -- Add menu control to form controls
    hForm.MainMenuStrip = mMenu   -- Set menu control as main menu of the form
    hForm.topmost = true          -- Always displayed over the others windows
    
    -- Add click event to exit menu item
    dotNet.addEventHandler mExitMenu "click" OnExit
    
    -- Show form
    hForm.show()
)

I’m doing some tests and benchs in order to view what’s possible to do with dotNet and I’ve also successfully created a C# class library and used it in MAXScript.

Yannick

Page 2 / 7