[Closed] Telnet <-> MaxScript
I’ d really like to remote control 3dsMax-in-server-mode from PHP (don’t ask why )
I did a bit of research and I think a method would be to create a startup maxscript that starts listening for telnet commands via some dotnet telnet interface.
3dsMax <-> insert missing piece here <-> telnet/SSH <-> PHP
I want to be able to send either singe commands or complete scripts into max for execution and get any return values back if possible.
As far as I can see this is doable, but my dotnet skills are a bit flacky at best so I’d like to know If I’ll hit any technical roadblocks with this approach before I dive any deeper into it.
Any feedback is much appreciated!
Using the 3dsMax SDK, I would build a utility plugin *.dlx which opens a socket connection to 3dsMax and then use something like python/ironpython (with .net) to send commands to 3dsMax and receive feedback. You need a layer to handle 3dsMax just randomly ‘blowing-up’ on you as it de-stabilises which believe it or not, does actually happen
With this in place, a web server layer can be implemented to control the python layer.
this can be done in pure maxscript.
we’ve done this in a renderer we develop (open source.).
this script here is used to SEND commands from 3dsmax to a listening application.
it should get you started…
you can read source file here:
http://src.luxrender.net/luxmax/file/283df49b6149/gplourde/mzp/Luxmax/telnet.ms
That all sounds very interesting ( in a geeky way ) …
I’ d really like to remote control 3dsMax-in-server-mode from PHP (don’t ask why )
Jonathan:
so you want to control Max from a webserver or get status messages from Max or something ?
It’s for some cloudfarm tools, in the long run it should replace backburner.
I’ve got max -> php working already using tcp/ip sockets, I think I can do quite some cool stuff with it once it a 2-way connection. Real funny to see maxscript sends its data into a dos prompt
I can build a simple backburner clone quite easily I think, maybe even sort of a poor man’s iRay RealityServer setup or create a live connection between 2 max sessions or any other program supporting python for example. The possibilities are endless.
But the first step would be to create an opensource connection kit that can connect max to external things like php, python, maybe even javascript etc with a few working examples.
This sounds really interesting! I’d love to see a full example of a two way connection.
What about the other direction ?
Imagine sending maxscript commands from a Linux shell directly into the Maxscript Listener/Maxscript Editor and remote control Max from anywhere you like 😈 ?
BTW:
this was an idea i planned to implement in my MXSEditor exposure plugin too. Currently i’m a bit stuck because of money related work ( yes i need money to live).
Jep that ‘sthe plan, send a string for max script to evaluate!
I’ve got the same problem Hacking away at it while waiting for renders to complete, I caught my self setting the settings a bit higher so I’d have some more to play
Alright, got a 2 way connection thing going on! I’ve scrapped some bits and pieces together from various sites, and I’m not really sure I’m going the right way with the backgroundworker since the TcpListener does support an async method… I just couldn’t get that to work.
it’s very ruff, no error handling what so ever, if you can improve feel free to assist
Fn BackgroundTcpListenerDoWork theSender theEvent =
(
IPAddress = DotNetClass "System.Net.IPAddress"
theIPAddress = IPAddress.Parse "127.0.0.1"
theTcpListener = DotNetObject "System.Net.Sockets.TcpListener" theIPAddress 7500
theTcpListener.Start()
theString="";
print "listening"
theSocket = theTcpListener.AcceptSocket()
while theString!="exit" do
(
theByteStream = DotNetObject "System.Byte[]" 10000
theSocket.Receive theByteStream
Encoding = DotnetClass "System.Text.Encoding"
theString = trimright (Encoding.UTF8.GetString(theByteStream))
if theString!="" do (
print theString
ascii_encoder = dotNetObject "System.Text.ASCIIEncoding"
bytes = ascii_encoder.GetBytes ( "Hi, I've recieved: "+theString+"
" as string )
result = theSocket.Send bytes
)
)
print "stopped"
theTcpListener.Stop()
theSocket.Close()
)
BackgroundWorker = DotNetObject "System.ComponentModel.BackgroundWorker"
DotNet.AddEventHandler BackgroundWorker "DoWork" BackgroundTcpListenerDoWork
BackgroundWorker.WorkerSupportsCancellation = true
BackgroundWorker.RunWorkerAsync()
how to use:
Load script and run it… ‘Listening’ should be printed to the maxscript listener if all goes well. This runs in the background and should be non-blocking.
Now start putty ( http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html ) an connect to:
ip: localhost
port: 7500
Connection type: raw
Anything you type in putty’s window should be printed in the maxscritp listener as well. Maxscript returns the input back to putty. type “exit” to close the socket.
If you re-run the script after a non proper exit you’ll get an error the port is already in use, just pick a new port number to use.
My dotnet skills aren’t that great so I’d be very happy if someone could help improve a little on this