dotNet + MXS


#261

when using a dotNetMXSValue, to get the stored value again, you use its .value property - and you dont need to store it by reference
eg.


    struct test
 (
 name,
 fn start = (print "hello")
   )
    t = test()
    t.name = "Mike"
 
 myVar = dotNetMxsValue t -- note: using t not &t
 -- calling:
 myVar.value.name
 -- returns "Mike" as expected
 myVar.value.start()
 -- prints "hello" as expected
    
    

#262

Thanks Joel!

I can’t explain how I missed that. I thought for sure it was the first thing I tried haha.
Well this is a good start to the day. Thanks again.

edit:

I see where I got confused. On the javascript side it isn’t coming out properly

alert(window.external); will return “MXS_dotNet.DotNetMXSValue+DotNetMXSValue_Proxy”
alert(window.external.value); will come up as undefined


#263

A dotnetMXSvalue is comparable to a BLOB. The BLOB makes it so that you can store 3ds max/maxscript-specific values using dotNET, and maxscript can read those values back out into useful data. But any other language is just going to see gobbledygook and won’t even know that ‘value’ is a ‘property’ of that data.


#264

I’m afraid that makes sense. I guess I’m at a dead end with the ObjectForScripting property. I was hoping to have asynchronous communication between javascript and max with the .net web browser.
Unless someone can figure out how to write a .net object that will then execute whatever maxscript is passed to it. I don’t know enough about the dotNet integration to know if that is possible.

Thanks for clearing that up for me.


#265

Well I found a work around. You guys are probably going to laugh at it, but that might motive someone who knows what they are doing to put out an example :smiley:

Since I can’t figure out a way to properly call maxscript methods via ObjectForScripting, I thought maybe if I can get the command stored in a real dotNet system object, then I can execute it via one of the events. Dirty, I know.

Here is some sample code:


   clearListener()
   try(destroydialog html_rol);catch()
   
   rollout html_rol "dotNet HTML Interface" width:540 height:600
   (
   	local url = "C:\\your\\path\\here\	est.html"
   	
   	dotNetControl wb "System.Windows.Forms.WebBrowser" pos:[0,0] width:540 height:600 	dotNetControl exec "System.Windows.Forms.Textbox" pos:[0,0] visible:false --hidden textbox that will hold commands passed from javascript
   	
   	on html_rol open do
   	( 
   		if doesFileExist url then
   		(
   			neturl = dotNetObject "System.Uri" ("file://" + url)
   			wb.Navigate neturl
   			wb.ObjectForScripting = exec
   			print exec 
   		)
   		else
   		(
   			print url + " can't be found"
   		)
   			
   	)
   				
   	on exec TextChanged e do --once we get a command, execute it. Don't try this at home.
   	(
   		execute(exec.text)
   	)
   )
 
  
   createdialog html_rol
   

the html is the same pretty much as what they had on the msdn reference i linked to earlier:


   <html><head>
   <script>
   function test(message) { alert('received: ' + message); }
   </script>
   </head>
   <body>
   <button onclick="window.external.text ='box()'">call client code from script code</button>
   </body>
   </html>
   

#266

I’m looking to get the drawing rec of a treeView node. In list view I think it is GetItemRect but there is no method like this in treeView. What I’m looking at doing is drawing the full width of the treeView control behind the selected node.

Any suggestions?


#267

How about just using the tree’s width property?
Like this.Bounds.Width


#268

Width is fine but where do I draw it up and down?


#269

Hi Paul!

Are you trying to draw a rect around the node it self or the whole tree??

I would think that Pjanssen is on the right track, you can use either TreeView.bounds or TreeNode.bounds

Bounds returns an instance of Rectangle. You should be able to use any number of properties within to achieve what you want (in fact, you could use the returned result…)

Bottom - Gets the y-coordinate that is the sum of the Y and Height property values of this Rectangle structure.
Height - Gets or sets the height of this Rectangle structure.
IsEmpty - Tests whether all numeric properties of this Rectangle have values of zero.
Left - Gets the x-coordinate of the left edge of this Rectangle structure.
Location - Gets or sets the coordinates of the upper-left corner of this Rectangle structure.
Right - Gets the x-coordinate that is the sum of X and Width property values of this Rectangle structure.
Size - Gets or sets the size of this Rectangle.
Top - Gets the y-coordinate of the top edge of this Rectangle structure.
Width - Gets or sets the width of this Rectangle structure.
X - Gets or sets the x-coordinate of the upper-left corner of this Rectangle structure.
Y - Gets or sets the y-coordinate of the upper-left corner of this Rectangle structure.


#270

Just around the node but the full width of the control. I will look at bounds, I didn’t see that listed.


#271

How the hell I missed that I will never know. Thanks, looks like exactly what I’m after.


#272

Well you could use both then :wink:


#273

I’m just curious: where/how are you going to do this drawing? In the treeview control (C#/C++) itself, or in maxscript?


#274

I’m doing the drawing in Max script. I’m doing a sort of slider effect when you scrub your mouse side ways on a treeview node. Working great now. I limited the problem with flashing by only invaliding a portion of the rec that I didnt need anymore. Only there is a bit of flashing is when you are over top of the selected text. I might even get rid of the selection high light when I do it.

So the one that I’m drawing is from the left side of the control to the x position of the mouse and the invalidate rec is from the x position of the mouse to the right side of the control. The height for both is determined by the .bounds, thanks Shane. I really wish we could get at double buffering, shame.


#275

DUH! I remember seeing that method while scanning the docs and I was wondering when I’d find a use for it.

Seems I’ve been spelunking waaay to deep on the .NET side of things. Sometimes you get tunnel vision.

Nice work Paul!


#276

Don’t know how useful this is for anyone, but here’s a little snippet to check the status of a service on a remote server. used as part of a little farm management utility that I’m updating to run with the 64bit stuff and experimenting with the net framework. :slight_smile:


	fn checkService ServiceName server =
	(
		dotnet.loadassembly "System.ServiceProcess"
		sc = dotNetObject "System.ServiceProcess.ServiceController"
		if (server == "") do server = "." -- if no server is supplied, run the check on the local machine
		sc.Machinename = server
		try(scServices = sc.GetServices(server))catch(return "Timed Out")
		for scTemp in scServices do
		(
			if (scTemp.ServiceName as string == ServiceName) then
			(
				--print ( ServiceName + " - " + server + " - " +scTemp.Status.toString() )
				return scTemp.Status.ToString()
			) 
		)
		return "Service Not found"
	)


#277

Hi Vsai, that’s way cool!!

Do you know if you can do remote execution as well??

Shane


#278

You can do it via WMI directly, but it doesn’t handle failure very well and isn’t very fast… its somewhat difficult to do remote execution and have it be interactive with the desktop however due to needing to supply domain credentials. So I tend to do most of that by way of the DOS ‘pstools’ from sysinternals. I’ll post something up sometime soon :slight_smile:


#279

An article about Integrating MaxScript and .NET Systems (By Shea McCombs and Kevin Rabun) is online on Gamasutra website.


#280

Not sure if you resolved this issue or not, but Ctl+Enter and Ctl+Tab seem to work here ( I’m on a laptop and have found that I need to use Ctl+Enter to execute lines of code I’m testing in the listener… hope that helps

-Ari