Jul 20 2011

controlling Dot Net Fonts in Maxscript (Repost)

This are some old notes, i had posted on another site regarding activeX to dotNet scripting… might be old news but i figured someone might find it usefull 🙂

So today i began to look into dot net controllers inside of max so that i can brake the studios current dependency on max 8 (activeX controller in max 9 don’t work unless 8 is installed),

and while it seem that the general work flow of the activeX controllers carries over to dotNet, there are allot of thing that are not documented and have become way more complex.

the main thing i noticed is dealing with object fonts, sizes, and styles such as bold italic etc, has become a bit more of a chore. here are some of the things i’ve found out, that i couldn’t find any where on the net.

when dealing with tree view nodes under activeX this is how you would change the text

node.font = "Tahoma"
node.fontsize = 7
node.bold = true

this has become a bit more complex in dotNet. a font is now an object value which is created out of sevral other objects and classes…

“fontfamily” this is the actual windows font to use

“fontStyle” this is the style of the text which can be bold , italic, crossed, etc

size can be controlled by a single integer value

so the first thing is to create both of this objects

fontFam = dotNetObject "system.drawing.fontfamily" "tahoma" --this makes the font object
fontStyle = dotNetClass "system.drawing.fontStyle" --this creates a list from which style can be pulled

next we will put it all together

myFont = dotNetObject "system.drawing.font" fontFam 7 fontStyle.bold
--the node font can now be overwritten by this line
node.nodeFont = myFont

anwyas i hope this helps some of you out there some. i will try and make more of this blog as i keep working with the new dotNet controllers in maxscript.



Leave a Reply