Notifications
Clear all

[Closed] SubClassing .Net Classes??

Hi, Guys, just had a quick question is it possible to SubClass .Net classes in mxs or would i need to do it C# first and then bring that into max?? I’m currently trying to put togather a treelistctrl in mxs and running into some problems…

Any help would be appreciated!

Cheers
Dave

15 Replies

It’s not possible to SubClass .Net classes in script because MAXScript isn’t an object oriented managed language. But you can do that in VB.NET, C# and Python? for example.

It’s only possible to use/instanciate/create the managed classes loaded from an assembly.

2 Replies
(@specxor)
Joined: 11 months ago

Posts: 0

Hi, ypuech,

I suspected as much… I have been having some trouble creating a TreeListCtrl ( http://www.codeproject.com/treectrl/treelist.asp?df=100&forumid=59&exp=0&select=1572713 )…

I’ll post some code to see if you can shed some light in it… Do you no any other treelistctrl’s?

Cheers
Dave

(@ypuech)
Joined: 11 months ago

Posts: 0

This is an MFC control?! not a custom .Net control…

 PEN

Interesting, I was just wondering if I can do this yesterday. Except I would like to have a treeList with drop down menus. I haven’t tested anything yet how ever.

I look forward to seeing what you come up with.

Hi Paul,

Not too hard to create developing a custom control in C# or VB.NET. Just use a ListView and subclass the item select handler to display a DropDown Menu.

 PEN

Can that then be exposed to Max script?

And could this be done in Python instead so that I’m not introducing another language?

2 Replies
(@specxor)
Joined: 11 months ago

Posts: 0

Hi, Paul,

Im going to have a good look at doing this with iron python over the next few days to see what i can up with, from what i understand this should be entirely possible…

Ill keep you posted.

Cheers
Dave

(@ypuech)
Joined: 11 months ago

Posts: 0

Yes, loading the assembly containing the custom control in MAXScript you can create it.

Maybe using ironPython you can develop such custom .Net control in Python.

Last time I checked you had to jump through some hoops to get assemblies made with ironpython to load correctly. Here’s a link to the mailing list, but its from 06, maybe things have changed (hopefully): http://lists.ironpython.com/pipermail/users-ironpython.com/2006-February/001725.html

 PEN

Would this sort of thing be better done in C++ then? Reason that I ask that is the other language that I’m learning, well slowely learning. Adding VB or other languages into the mix at this point will be more over load. Python looks like a fast scripting solution for system wide needs and C++ I need for Max and Maya plugins.

I dunno Paul… C# is about as hard as MXS, it just has more classes/methods. Its a really super clean syntax that makes a lot of sense. I’d say you could become proficient in C# 5x faster than you could in C++… which I am also learning slowly, sigh. You don’t have to worry about pointers or references or arrays only holding one type or any of that low-level stuff. I feel the same as you about language overload though…

2 Replies
(@specxor)
Joined: 11 months ago

Posts: 0

Hi, Guys,

d3coy I did some further research into building assemblies with iron python, it seems its a little bit hit and miss, the answer I mostly found was that it would “sometimes” work but you would ordinarily get problems when trying to import the assemblie… So I think i will jump into C# I must admit that have used C# from time to time to do simple things, and it is a very clean easy to read/learn language…

I totally agree with you guys on language overload I’m trying to juggle Python, MXS, C#, C++ and a touch of MEL thrown into the mix just for fun! what bends my mind is getting them all to talk and play nicely together…

Cheers
Dave

(@joel_hooks)
Joined: 11 months ago

Posts: 0

I’d advance the position that C# is way easier to learn than MXS given the high quality IDE you have to work with (code completion, ect). The POS MSX IDE is in dire need of some sort of update. I wish somebody would write an exclipse plugin or something similar.

Not to mention the killer docs, books, and other materials available for C# over MXS. Either way, it is worlds clearer than C++.

 PEN

Ok, you guys are a pain in the ass you know that right. You just added C# to my list of things to learn before lunch. If my brain explodes you guys have to come and clean it up.

So, if C# is what I’m after what do I need for C#, what compiler and where can I get it, what is the best book and web resource for it to get started?

So here is another question then. If C# is so easy why use Python? Is C# only for windows? Also I gather it would need compiling unlike Python. I’m trying to find the more streamlined way to get the most control. Adding 10 languages into the mix would be very messy. So if I only need C# to setup some fancy UI controls that isn’t a problem and wouldn’t complicate the final tools I gather as the result would be a compiled tool that I could call from Max script…right?

I have feel the vien in the side of my head pulsing.

lol Paul,

Free IDE and compiler here: http://msdn.microsoft.com/vstudio/express/visualcsharp/

The best resource is the MSDN, if you type “system.windows.forms.listview” (or any class) into google, you’ll get the link. Some other people posted good resources back in the other .net thread… I think the best way to learn though is to crawl through someone else’s subclassed .net control from thecodeproject.com and see how they did it. I might write a tutorial on this to prevent other people pulling their hair out at that particular stage like I did. I bought Murach’s C# book but I didn’t find it all that useful.

Yea its easy; sometimes python is just faster. If I want to do some batch renaming of sequences or reversing sequences or little tasks like that, I will bang it out in python just b/c its faster to write things like that. Also I don’t have to load up an IDE and compile etc, just command line and any good text editor. Originally it was windows only but there exists something called Mono, made by Novell, that is a .net implementation on linux, so it is basically cross platform. Apple might have something too, I’m not sure.

C# compiles down to IL (intermediate language) which in turn gets compiled by the JIT (just in time) compiler to machine code. All of the .net languages compile down to IL. When you made an assembly .dll file it just holds IL that is compiled at runtime. So when you use loadassembly in MXS it is compiled on the fly for your use. Its a virtual machine (but they call it the CLR [common language runtime]) with some extra stuff thrown in. The python interpreter works similarly… but with different languages. Wikipedia has a great article on how the .net stuff works.

All I really use C# for is fancy control objects… but there’s a host of useful classes that I want to expose to MXS too. For instance an assembly available to MXS that encapsulates all the .net string methods so I have more string manipulation power, or regexes. I started to write a MXS IDE (custom richtextcontrol with regex syntax highlighting, treeview, splitter, my tab control), but I put it on hold for now since I heard a better script editor might be in store for us? Another idea I had was a little messageboard inside 3dsmax so we could post messages in the studio

Good luck man, post back with your trials and tribulations