Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

how to develop a standalone software using 3ds max SDK (or C#) to control running 3ds max projects remotely? (Solution uses OLE Automation with C# and maxscript)

how to develop a standalone software using 3ds max SDK (or C#) to control running 3ds max projects remotely? (Solution uses OLE Automation with C# and maxscript)

FelixP5NJM
Enthusiast Enthusiast
2,971 Views
21 Replies
Message 1 of 22

how to develop a standalone software using 3ds max SDK (or C#) to control running 3ds max projects remotely? (Solution uses OLE Automation with C# and maxscript)

FelixP5NJM
Enthusiast
Enthusiast

If there is another way? Or Is it impossible with normal approaches?

0 Likes
Accepted solutions (2)
2,972 Views
21 Replies
Replies (21)
Message 2 of 22

denisT.MaxDoctor
Advisor
Advisor

It's possible, but 3DS MAX must be installed anyway to get not only libs but also some used dlls. So there is no a big difference to make a standalone app or a plugin for 3DS MAX. Where the second is much easier. 

0 Likes
Message 3 of 22

denisT.MaxDoctor
Advisor
Advisor

Another way is to work with "exported" data from 3DS MAX (OBJ, FBX, etc.) using a related SDK.

0 Likes
Message 4 of 22

FelixP5NJM
Enthusiast
Enthusiast

Is there an official tutorial about making a standalone app using 3ds max SDK?

0 Likes
Message 5 of 22

denisT.MaxDoctor
Advisor
Advisor

@FelixP5NJM wrote:

Is there an official tutorial about making a standalone app using 3ds max SDK?


I don't think there is anything official from Autodesk about this for 3DS MAX. Unlike Maya, where some time ago such a development was offered and welcomed by Autodesk.

0 Likes
Message 6 of 22

klvnk
Collaborator
Collaborator

what does "to control 3ds max projects?" even mean ? control max ? open max files ?

0 Likes
Message 7 of 22

Swordslayer
Advisor
Advisor
0 Likes
Message 8 of 22

FelixP5NJM
Enthusiast
Enthusiast

such as importing models, creating objects and adding animations. Other things can be done with plug-ins, but I need to make them a standalone application.

0 Likes
Message 9 of 22

klvnk
Collaborator
Collaborator
Accepted solution

just use OLE automation then, you can make max dance to the tune of python, C/C++ etc to your hearts content.

 

ole.gif

this is a console app (written in c++)  using OLE to run the script sent to it (in this case from sublime text editor)

0 Likes
Message 10 of 22

FelixP5NJM
Enthusiast
Enthusiast

Thank you. But does it need libraries provided by AutoDesk to make it work, or do you just write code from scratch?

0 Likes
Message 11 of 22

klvnk
Collaborator
Collaborator

the console app is written from just windows libraries.... it needs Max to be OLE enabled and provide the server side functions (which is documented in MXS help). Exposing a run script function is useful as it minimizes the server side work required even if it's not the most efficient. 

0 Likes
Message 12 of 22

FelixP5NJM
Enthusiast
Enthusiast

I followed the instructions in the doc.


@klvnk wrote:

the console app is written from just windows libraries.... it needs Max to be OLE enabled and provide the server side functions (which is documented in MXS help). Exposing a run script function is useful as it minimizes the server side work required even if it's not the most efficient. 


After I wrote a "runScript" function and exposed it. How can I connect my program (for example, in C++) to a 3ds max instance and invoke the "runScript" function with the parameter (script file name)?

0 Likes
Message 13 of 22

klvnk
Collaborator
Collaborator
0 Likes
Message 14 of 22

trykle
Contributor
Contributor

I think you still need to install the whole 3dsmax and run it, then you can use cmd to pass parameters, there is a 3dsmaxbatch.exe in the 2018 version, it may be more convenient.

0 Likes
Message 15 of 22

FelixP5NJM
Enthusiast
Enthusiast
Accepted solution

Thank everyone's help. I finally find an easy solution using C# on GitHub. Here is the link.  

 

This was all I need after registering 3ds Max and exposing the Maxscript function "filein".

 

using Westwind.Utilities;

string prog_id = "Max.Application";
Type com_type = Type.GetTypeFromProgID(prog_id);
object com_obj = Activator.CreateInstance(com_type);

com_obj.GetType().InvokeMember("filein",																 ReflectionUtils.MemberAccess | BindingFlags.InvokeMethod,																  null, com_obj, new object[] {filepath});

 

With this, I can control 3ds Max to run any Maxscript files.

 

 

 

 

 

Message 16 of 22

denisT.MaxDoctor
Advisor
Advisor

Hmm.. I remember you were talking about "standalone" .. no longer?

0 Likes
Message 17 of 22

denisT.MaxDoctor
Advisor
Advisor

As far as I understand, if MAX runs, then talking about "standalone" does not make sense.

0 Likes
Message 18 of 22

klvnk
Collaborator
Collaborator

"remote" maybe a better description

0 Likes
Message 19 of 22

FelixP5NJM
Enthusiast
Enthusiast

Sorry about that, I don't understand the definition very well. I am developing a "standalone" app and "control 3ds max" is just one of the functionalities.

0 Likes
Message 20 of 22

FelixP5NJM
Enthusiast
Enthusiast
Thank you, I will update the question.
0 Likes