And it seems you need to get rid of the call to invalidate too, in order to display the color you specified:
So remove this:
g_hForm.Invalidate()
And you will see the color you wanted. Otherwise it’s just grey.
Chris J.
Hi Chris,
Thank you very much for the help! It works now but I cannot understand why the first time it works :banghead:.
And it seems you need to get rid of the call to invalidate too, in order to display the color you specified: So remove this: g_hForm.Invalidate()
Invalidate() is a way of forcing form and control redraw in my C# code. But in MAXScript this instruction does not refresh correctly the form.
The source code for maxscript .NET comes with the SDK. So for you folks out there who want to tinker with it… go ahead.
I will take a look!
Well, I’m developing a small 3D engine in C#. It will be possible to create an OpenGL control or a DirectX control. The goal is to simplify for example the creation of a small real time viewer inside max written in MAXScript using this graphics engine!
Here’s a screenshot with an OpenGL control displaying one colored triangle :
On the left a .Net 2.0 form and on the right a Rollout :
Here’s the code for the .Net 2.0 form with the OpenGL control :
(
global g_hGLControl
global g_UpdateTimer
AssemblyFileName = "Good3D.dll"
-- Create the Assembly class in order to load the class library
Assembly = dotNetClass "System.Reflection.Assembly"
-- Load the class library created
Assembly.LoadFrom AssemblyFileName
-- Create Goo3D OpenGL control
g_hGLControl = dotNetObject "Good3D.OpenGLControl"
g_hGLControl.Location = dotNetObject "System.Drawing.Point" 0 0
DockStyle = dotNetClass "System.Windows.Forms.DockStyle"
g_hGLControl.Dock = DockStyle.Fill
g_hGLControl.Visible = true
-- Create a DotNet Form
hForm = dotNetObject "System.Windows.Forms.Form"
hForm.Size = dotNetObject "System.Drawing.Size" 400 400
hForm.Text = ".Net 2.0 Form with OpenGL Control!"
hForm.Controls.Add(g_hGLControl)
hForm.topmost = true
-- Show form
hForm.show()
)
Here’s the code for the Rollout with the OpenGL control :
(
AssemblyFileName = "Good3D.dll"
-- Load the engine class library
dotnet.LoadAssembly AssemblyFileName
rollout Good3DRollout "Rollout with OpenGL Control!" width:400 height:400
(
dotNetControl GLControl "Good3D.OpenGLControl" pos:[0,0] width:400 height:400
)
createdialog Good3DRollout
)
The code of the Rollout is the smaller and the simplier! Rollouts are good :).
That’s awesome Yannick.
Guess I need to go buy a C# book after work today
That’s awesome Yannick.
Thanks but it’s just the beginning!
Guess I need to go buy a C# book after work today
Yes C# is the future and I :love: C#.
Hi, Guys,
Just having a quick look at the new dotnet stuff, I noticed some people mentioned using the dotnet xml parser, just wondering if some one could elborate on that a bit more…
For instance can do something like:
XmlObject = dotnetobject “System.Xml”
or
XmlClass = dotnetclass “System.Xml”
Would this be right, I have not had a chance to play around with it yet…
Sounds like Ill have to hit up some dotNet books to…
Hi David,
In order to parse XML files you can use the simple classes XmlReader and XmlWritter.
Look at http://msdn2.microsoft.com/en-us/library/tx3wa6ka.aspx or http://www.functionx.com/vcsharp/xml/Lesson06.htm for a tutorials on how using the XmlWritter.
I will post a reply with a sample code of how reading/writting a simple XML.
XmlObject = dotnetobject “System.Xml”
or
XmlClass = dotnetclass “System.Xml”
This will not work because “System.Xml” is a namespace containing classes.
And the dotNetClass is only useful when dealing with static classes ; classes that we cannot create an object.
At that time I’m using a lot the dotNet wrapper in MAXScript because I’m a fan of C# and .Net. By the way, the wrapper is very good and I like it! Thanks Autodesk :applause:.
Have you guys found any way to convert Max bitmap data type to a dotnet image (bitmap) data type or vice versa with out saving and opening file.
Like: myBitmap = render()
Now I want to display this bitmap in a dotnet picture box without saving the file as temp.
For continuous data exchange I think save and open is not a good idea. The only solution I find is setPixel or getPixel. But as you know maxscript is slow for a big loop. So it is forcing me to develop a dlx maxscript function using SDK to extract pixel information from max bitmap. Then I can pass it to my dot net component…again I need a same kind of loop function in my dotnet component(using setPixels and getPixels) to create a dotnet bitmap or image from this data.
I face same type of data or value conversion problem in other areas (as per maxscript ref it only supports the basic data type conversion). It will be cool to get all max object (classes) in dotnet assembly (as HalfVector said about a dotnet wrapper on SDK) so we can use them in C# (or whatever language you want) to make our own custom component (Not only for UI… also for developing logic) and further use them with maxscript. It will create new possibilities of tool development in 3dsmax…like the bitmap painting tool (that one from maxscipt ref), you can easily develop with the power of GDI+ in dotnet and for 3d painting you can use maxscript. See this link http://www.getpaint.net/ . They develop Photoshop type app using dotnet. But only using maxscript the bitmap painting will be slow, feature less and just a demo of maxscript use not for practical implementation. I know we can use 3dsMax SDK for heavy processing (You also know the reason behind maxscript popularity in tool development compare to max SDK)
but dotnet is really powerful for rapid development. What you guys think? May be Im thinking in wrong way.
This all sounds sweet where can I read up on this and maybe see some code examples?
-Baker
The basics and some code examples are in the MAXScript Reference 9.0. In addition, the Render To Texture and Named Selection Sets dialogs shipping with Max 9 were rewritten to use DotNet so you can read them as examples.
In addition, you can go to
http://www.scriptspot.com/bobo/mxs9/dotNet/index.html
which has a Work In Progress Reference of most System.Windows.Forms classes and a few examples of their usage (more to come over time). It also has links to the related Microsoft Dev. Network pages.
Bobo without you I don’t think many of us would make it. You always give the most concise answers to every question and then some.
Thanks a million for your help and support for the community.
-Baker