dotNet + MXS


#121

BitArray?

Not sure to understand everything… But MXS can return array of bits…


#122

Im not having much luck trying to pass a float array from my function in C#/dot net to maxscript ? are you guys saying maxscript cant do this and I will have to use an integer array ?

Also is there someplace I can read up on more things like this,as all I can find in the maxscript help has to do with making tree views and stuff to do with xml , there does not seem to be much info if any at all on passing data to and from functions in C#.

And one more thing could I write my functions in C++ as I know C++ and dont know C# that well at all …

Thanks for reading and sorry for asking so much but I so badly want to learn this dotnet stuff

all the best :slight_smile:


#123

See “MAXScript / DotNet Value Conversions” in the Reference to understand what I said.

If you want to write C++ code with .NET Framework you have to use C++/CLI. This is an extension to C++ to support managed code. But I think it’s better to write assemblies (.NET DLL) in C# or VB.NET because these languages are very good and easy to understand.


#124

Thanks for the reply I will readup DotNet Value Conversions :slight_smile: and spend a bit more time on c# I will get my head round it Im sure , thanks again :slight_smile:


#125

Hi Paul! I meant to do this sometime go ago but overwhelmed by otherthings…

If you’re interested, checkout http://www.w3schools.com/xpath/default.asp and http://msdn2.microsoft.com/en-us/library/ms256086.aspx

This will give you start…yet, another query language to learn :stuck_out_tongue:

Shane


#126

Thanks Shane. I should have stuck with being a modeler, would just need to learn the odd new piece of software from time to time instead of five new languages each week.


#127

Another language I can deal with (almost)

I’m writing a script that needs to run in max 8 and max 9 x64…so i need to swap between activex and dotnet…and the xml api is NOT THE BLOODY SAME…it almost is, just enough to lure you in … and when you feel safe…bame…this property is unknown…

Going cross eyed trying to get it to work… :stuck_out_tongue:


#128

Hey gang,

I’ve been scrounging around trying to find the access to the Summary Info tab for windows files, but I can only find a COM reference. Any clues?


#129

Do you want the tab or the file info??

Shane


#130

I want to write details into the Summary fields (ie. When you right-click for properties in explorer and get the Author, Comments, Keywords etc).

I want to write a basic script to add details to an exported mesh.


#131

You don’t need .NET or COM to do that. See “3ds Max Scene File Properties” in the MAXScript Reference and the sample example.


#132

Unfortunately that only works for max scene file properties. I’m doing this for other files, ie. Exports and textures.


#133

Hello, I’m having trouble loading an xml doc from a string in MXS. This code


dotNet.loadAssembly "system.xml.dll"
message ="<?xml version=\"1.0\" encoding = \"Windows-1252\"?><bookstore></bookstore>"
xmlInDoc=dotNetObject "system.xml.xmlDocument"
xmlInDoc.loadXml message

produces “undefined” in the listener on the loadXml line.

The code in post #106 ( http://forums.cgsociety.org/showpost.php?p=4901788&postcount=106 ) also produces “undefined” for me when it tries to run the loadXml method.

Can anyone suggest a way around this?

Thanks,
Chris


#134

Hay Chris!

I can see why this might be confusing. There is actually nothing wrong…

Try this, add

xmlInDoc.OuterXml

to the end of your code and see what you get

Shane


#135

Wow. I plainly need to learn more XML & .NET. Thanks for the help – it works perfectly, of course!
Chris


#136

Hi all,

I’m posting a code snippet which might be of use to someone, utilising the TableLayoutPanel control :


 
 (
 	tv = dotNetObject "System.Windows.Forms.TableLayoutPanel"
 	
 	tv.layoutSettings.RowCount = 12
 	tv.layoutSettings.ColumnCount = 6
 	tv.BorderStyle = (dotNetClass "System.Windows.Forms.BorderStyle").None
 	tv.CellBorderStyle = (dotNetClass "System.Windows.Forms.TableLayoutPanelCellBorderStyle").Single
 	
 	tv.width = tv.layoutSettings.ColumnCount  * 32
 	tv.height = tv.layoutSettings.RowCount* 32
 	
 	for i = 0 to tv.layoutSettings.RowCount - 1 do
 		for j = 0 to tv.layoutSettings.ColumnCount - 1 do
 		(
 			btn = (dotNetObject "System.Windows.Forms.Button")
 			--dotShow 
 			btn.Width = 25
 			btn.Height = 25
 			btn.Text = (i+j) as string
 			tv.Controls.Add btn i j
 		)
 	
 
 	hForm = dotNetObject "System.Windows.Forms.Form"
 	hForm.Size = dotNetObject "System.Drawing.Size" (tv.Width + 10) (tv.Height + 30)
 	hForm.Text = ".Net TableLayoutPanel"
 	hForm.Controls.Add(tv)
 	hForm.TopMost = true
 	FormBorderStyle = dotNetClass "System.Windows.Forms.FormBorderStyle"
 	hForm.FormBorderStyle = FormBorderStyle.FixedDialog
 	hForm.ShowInTaskbar = false
 	hForm.MinimizeBox = false
 	hForm.MaximizeBox = false
 
    
 	-- Show application Form
 	hApp = dotNetClass "System.Windows.Forms.Application"
 	hApp.Run hForm
 )
 
 

If you want it as control in a dialog replace
tv = dotNetObject “System.Windows.Forms.TableLayoutPanel”
with
dotNetControl tv “System.Windows.Forms.TableLayoutPanel”

I hope this is of help to anyone, cause the tablecell take all sorts of objects, not just buttons… Allthough I’m having some slow downs building large grids with buttons inside a dialog, don’t know what it is yet.

-Johan


#137

An observation:

I see a lot of code looking like this

newNode.forecolor = (dotNetClass “System.Drawing.Color”).fromARGB 200 0 0

instancing a new dotNetClass… but in this example newNode.forecolor itself is a reference to to the same class right…?!

So wouldn’t

newNode.forecolor = newNode.forecolor.fromARGB 200 0 0

be better and even more logical! I assume it’s faster cause the class is already loaded and doesn’t need a new pointer to it. At least I find it more readable and logic.

Am I on the right track here?

-Johan


#138

I’m having some problems with the (keyboard) focus when using dotnet controls. I want to be able to use the regular 3dsmax shortcuts while using dotnet controls. Either by removing the focus each time an action is applied on the control, or through some other way. But I can’t seem to figure out how to do this.
Calling “setFocus” on the rollout from the dotnet control doesn’t seem to work…

Any ideas?


#139

Interesting code sample John! TableLayoutPanel seems useful to create dynamic UI. There’s also FlowLayoutPanel that dynamically lays out its contents horizontally or vertically.

In fact, it’s the same in the two situations because FromARGB() is a static method. So, its behaviour doesn’t depend on the object it’s executed.


#140

Okay, I still have to learn a lot I see :slight_smile: Thanks for clarifying this, although I think I’m going to stick with my method since it makes more sense to me and doesn’t require me typing a new string… copy paste will do… yes I’m lazy.

I keep thinking it would be good to have an maxscript V2 or some other langauge in max that’s more conform to OOP. Just like actionscript you have 3 flavours… I’d settle for 2 or maybe python or something… I really feel UI building is lacking severly in mxs…

-Johan