Notifications
Clear all

[Closed] muhahaa, Max Contro Maya with dotnet

execute this code in maya


if(! `commandPort -q ":7457"`) commandPort -rnc -n ":7457"

after run this MaxScript in max 9 or hight


/*
execute this mel in maya ,after execute this maxscript

if(! `commandPort -q ":7457"`) commandPort -rnc -n ":7457"

*/
Try (DestroyDialog  RolMaxConMaya) Catch()
rollout RolMaxConMaya "MaxControlMaya" 
(
	checkbutton CkbMayaConnected "Maya Connected"
	button BtnMayaCreCube "PolyCube" 
	button BtnMayaCreSphere "PolySphere" 
	edittext TextMelText "" 
	button BtnExecutetoMaya "Execute Mel" 
	button BtnCloseMaya "CloseMaya" 
	
	local TheDotNetIPAddress 
	local TheDotNetTcpClient
	local TestDotNetStream
	local TheMsgOutput
	local TheOutCmd
	
	fn TheOutCmd  FnString  FnDotNetStream =
	(
		if FnDotNetStream.CanWrite and (((MaxVersion())[1] / 1000.0) >= 12) do
		(
			TestDotNetEncode = DotNetClass "System.Text.Encoding"
			TheMelCom = TestDotNetEncode.UTF8.GetBytes FnString
			TestDotNetStream.Write  TheMelCom 0 TheMelCom.Count
		)
		if FnDotNetStream.CanWrite and (((MaxVersion())[1] / 1000.0) < 12) do
		(
			TheMsgOutput.MxsSendMessage FnString FnDotNetStream 
		)
	)
	
	
	on RolMaxConMaya open do 
	(
		if ((MaxVersion())[1] / 1000.0) < 12 do
		(
			TheRootDir = GetDir #MaxRoot
			TheLoadDll = getFiles (TheRootDir + "TestMax.dll")
			if TheLoadDll.Count == 0 then
			(
				MessageBox "please Copy TestMax.dll to Max root directory"
				DestroyDialog  RolMaxConMaya
			)
			else
			(
				DotNet.loadAssembly TheLoadDll[1] 
				TheMsgOutput = DotNetObject "TestMax.SittMaxNetClass"
			)
		)

		TheDotNetIPAddress = ( DotNetClass "System.Net.IPAddress").Parse "127.0.0.1"
		TheDotNetTcpClient = DotNetObject "System.Net.Sockets.TcpClient"
		try 
		(
			TheDotNetTcpClient.Connect TheDotNetIPAddress 7457
			TestDotNetStream = TheDotNetTcpClient.GetStream()
		)
		catch(MessageBox "Please execute this mel in Maya 
 
  if(! `commandPort -q \":7457\"`) commandPort -rnc -n \":7457\" ")
		if TheDotNetTcpClient.Connected do 
		(
			CkbMayaConnected.Checked = true
		)
	)
	on RolMaxConMaya close do
	(
		try (TheDotNetTcpClient.Close()) catch()
	)
	on CkbMayaConnected changed state do
	(
		if state== true then
		(
			TheDotNetIPAddress = ( DotNetClass "System.Net.IPAddress").Parse "127.0.0.1"
			TheDotNetTcpClient = DotNetObject "System.Net.Sockets.TcpClient"
			try 
			(
				TheDotNetTcpClient.Connect TheDotNetIPAddress 7457
				TestDotNetStream = TheDotNetTcpClient.GetStream()
				CkbMayaConnected.Checked = true
			)
			catch
			(
				CkbMayaConnected.Checked = false
				MessageBox "Please execute this mel in Maya 
 
  if(! `commandPort -q \":7457\"`) commandPort -rnc -n \":7457\" "
			)
		)
		else
		(
			TheDotNetTcpClient.Close()
			CkbMayaConnected.Checked = false
		)
	)
	on BtnMayaCreCube pressed  do
	(
		TheOutCmd "polyCube" TestDotNetStream
	)
	on BtnMayaCreSphere pressed  do
	(
		TheOutCmd "polySphere" TestDotNetStream
	)
	on BtnExecutetoMaya pressed  do
	(
		if TestDotNetStream.CanWrite do 
		(
			TheOutCmd TextMelText.Text TestDotNetStream
			TextMelText.Text = ""
		)
	)
	on BtnCloseMaya pressed  do
	(
		 TheOutCmd "quit -force" TestDotNetStream
	)
)

CreateDialog RolMaxConMaya

this MaxScript need TestMax.dll in max9 – 2009
need copy TestMax.dll to Max root directory
Zip file is there

7 Replies

nothing…

This is… diabolical.

 ulb

What does that do exactly? I don’t have maya…

creates objects in Maya. Using Max.

Isn’t that one of the signs of the Apocalypse?

does Maya have a teapot primitive?

1 Reply
(@ikerclon)
Joined: 10 months ago

Posts: 0

I guess this is the only purpose for opening this thread

Something similar, but with XSI and MAX, here (oldie but good):

http://www.sloft.net/2006/11/26/how-to-make-xsi-and-max-friends/