Notifications
Clear all

[Closed] Possibilities to remotely control 3ds Max

Hello!

I am looking for a solution for a specific scenario a client is asking for. I am not looking for specific commands for now, only looking for a general route to go and maybe, if not possible at all, think of something else.

Here is the scenario:

  • Someone has a notebook with internet access, somewhere in the world. No 3ds Max license on it and the person operating does not know how to use 3ds Max.

  • In a web interface the person logs in his account, uploads an illustrator file and some settings like extrude by 5 and give it the blue material.

  • This should be send to a server with a licensed 3ds max on it, which opens a starting scene with camera, lights etc., imports the illustrator file, extrudes it, gives it the blue material – and renders it with render settings from the web interface.

  • When the rendering is finished, the image should be emailed automatically to the one who logged in previously.

  • This should work for several users simultaneously.

The part within 3ds Max is not the problem, I have already written a MaxScript doing the import-extrude-material-render-stuff. It is all the parts around that I do not know how to tackle. Is this basically possible, and if yes, what main components (software and hardware) would I need for that? If I have to hire a programmer for a certain task, I will do so, I still would need to know, which programming language is needed etc.

Any ideas are welcome!

Thanks a lot,
Bob

9 Replies

What your client wants is basically a renderfarm, but for the other type of files.

Well, I would say it is more than a render service since the files to render need to be remotely generated first. I am not sure what you mean by “the other type of files”, can you elaborate a little further please?

Thanks
Bob

I meant this. RenderFarm service for .AI type of files

Back in the days I remember there was a problem to import AI files saved in version newer than 8.0. I’m curious if anything has changed since then.

there’s the comsrv project in the SDK you could look at.

theres also OLE automation … install it (there’s instructions in mxs help)

run the following snippet in max

fn OLERunScript script = ( runscript script; )
registerOLEInterface #(OLERunScript)

then from a VS console app with the following code…

#include <iostream>
#include <afxwin.h>
#include <afxext.h>
#include <wininet.h>
#include <afxdisp.h>
#include <afxdtctl.h>
#include <stdio.h>
#include <tchar.h>
#include <conio.h>
#include <comutil.h>

#include <Objbase.h>
#include <Shlobj.h>

using namespace std;

//********************************************************************************************
//   nTypes can be DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYGET | DISPATCH_METHOD

HRESULT OLEMethod(int nType, VARIANT *pvResult,  IDispatch *pDisp,LPOLESTR ptName, int cArgs...)
{
    if(!pDisp) return E_FAIL;

    va_list marker;
    va_start(marker, cArgs);

    DISPPARAMS dp = { NULL, NULL, 0, 0 };
    DISPID dispidNamed = DISPID_PROPERTYPUT;
    DISPID dispID;
    char szName[200];

    // Convert down to ANSI
    WideCharToMultiByte(CP_ACP, 0, ptName, -1, szName, 256, NULL, NULL);

    // Get DISPID for name passed...
    HRESULT hr= pDisp->GetIDsOfNames(IID_NULL, &ptName, 1, LOCALE_USER_DEFAULT, &dispID);
    if(FAILED(hr)) 
        return hr;

    VARIANT *pArgs = new VARIANT[cArgs+1]; // Allocate memory for arguments...
   
    for(int i=0; i<cArgs; i++)   // Extract arguments...
	{
        pArgs[i] = va_arg(marker, VARIANT);
    }

    // Build DISPPARAMS
    dp.cArgs = cArgs;
    dp.rgvarg = pArgs;

    
    if(nType & DISPATCH_PROPERTYPUT)  // Handle special-case for property-puts!
	{
        dp.cNamedArgs = 1;
        dp.rgdispidNamedArgs = &dispidNamed;
    }

    // Make the call!
    hr = pDisp->Invoke(dispID, IID_NULL, LOCALE_SYSTEM_DEFAULT, nType, &dp, pvResult, NULL, NULL);
    if(FAILED(hr)) 
        return hr;

    va_end(marker);     // End variable-argument section...
    delete [] pArgs;
    return hr;
}

//********************************************************************************************

int _tmain(int argc, _TCHAR* argv[])
{
	CoInitialize(NULL);
	CLSID clsid;
	HRESULT hr = CLSIDFromProgID(L"MAX.Application", &clsid);
	if(SUCCEEDED(hr))
	{
		IDispatch *pWApp;
		hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void **)&pWApp);
		if(SUCCEEDED(hr))
		{
			_variant_t script("delete objects\n b = box pos:[25,0,0]\n s = sphere pos:[-25,0,0]\n");
			hr = OLEMethod(DISPATCH_METHOD, NULL, pWApp, _T("OLERunScript"), 1, script);
			if(SUCCEEDED(hr))
			{
				wcout << _T("Call save max file") << endl;
			}
		}
	}
	else
		wcout << _T("No Max.Application COM") << endl;

	CoUninitialize();
	//getch();
	return 0;
}

there is also a python library to do the same…

import win32com.client;


MaxApp = "MAX.Application"

conn = win32com.client.Dispatch(MaxApp)
conn._FlagAsMethod("OLERunScript")

try:
    res = conn.OLERunScript("delete objects\n b = box pos:[25,0,0]\n s = sphere pos:[-25,0,0]\n")
except:
    print "oops";

throws an error but still works

Thanks Serejah, I am also not sure if it still needs to be v8, but this would not be a problem, because it is a small fixed amount of people using it in the end and they could just be told to export it correctly.

Thanks a lot Klvnk for the input! It is a little early for me to test certain code snippets, for now I am just looking for general feasibility. I will have a look at it later on.
Thanks for directing me in an interesting direction. I now have read the documentation about COM an OLE and it looks like 3ds Max could be controlled without someone sitting in front of it.

How could the bridge between a website and 3ds Max get built then? It seems that I can register 3ds Max as a server listening for commands, but how would I get these commands to 3ds Max via internet?

And is 3ds Max itself capable of sending emails with attached images or does 3ds Max has to communicate to an external tool as well? If so, which programming language could be used to do so?

Thanks,
Bob

Can other users upload to my Google Drive?
With File Upload Forms for Google Drive, you can allow others to upload files directly to your Google Drive. Anyone can upload files via your form without having to sign-in to their Google Account.

I guess it is possible not only to allow users to upload the files, but also save the settings for the task into a spreadsheet or something like that. Or force users to upload not only the .AI file but also a command file that contains 3dsmax task settings.

Then on the PC where 3dsmax installed you synchronize the googledrive folder by timer and launch jobs for unprocessed files.

Interesting idea, I did not know that one could do that. It is probably a little too dependent on an external service for my client, he would rather have everything under control and not break with an update from Google or something like that.
But let’s say, the web interface creates a maxscript-file and uploads the AI-file, and sends them both to a certain folder on the server. Could there be some kind of program running on the server watching for new files in that folder and starting 3ds Max directly with a certain scene and maxscript-commands? In which programming language should that watch-program be developed?

Thanks
Bob

Wouldn’t it make more sense to have a PC with 3dsmax checking if there’re new files on remote server that runs the website? Then you download the files via ftp and start the task.
Most likely it is doable with WordPress and a few plugins for user auth and file uploading. I’m not an expert in this field, so you better ask web developers.

Thanks, I will research further in this direction. You are right, this part leaves the realm of 3D programming and I will also look somewhere else. Maybe somehow the pieces of the puzzle will fit…

Thanks,
Bob