PDA

View Full Version : muhahaa, Max Contro Maya with dotnet


CGGD
05-06-2009, 05:16 AM
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 \n \n 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 \n \n 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

CGGD
05-07-2009, 04:59 AM
nothing............

RobGalanakis
05-08-2009, 05:59 PM
This is... diabolical.

ulb
05-08-2009, 07:25 PM
What does that do exactly? I don't have maya...

thatoneguy
05-08-2009, 08:21 PM
creates objects in Maya. Using Max.

MarcoBrunetta
05-08-2009, 08:23 PM
Isn't that one of the signs of the Apocalypse?

LoneRobot
05-08-2009, 09:42 PM
does Maya have a teapot primitive?

IkerCLoN
05-11-2009, 09:51 AM
does Maya have a teapot primitive?

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/

CGTalk Moderation
05-11-2009, 09:51 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.