PDA

View Full Version : Integrate extern application in Max


Tesctassa
02-27-2008, 01:29 PM
Hi all!

As the title says, I'm developing an extern application, using .Net and c#, and I'd like to make it usable by MaxScript.
That is I'd like to be able to use methods of the applications from script much likely as I do with dotNet objects. Practically I think the application should expose some methods that I can call from scripts and, more important, I should be able to create a "myApp" object inside script which rapresent the instance of my application....

I don't know if that was clear enough, in case ask more details plz! I really need your help!

Thanks in advance,
Adriano

ypuech
02-27-2008, 01:42 PM
To be able to call your .NET code with MAXScript, you'll need to build an assembly/class library (if it's not done) containing the core operations of your application.

Tesctassa
02-27-2008, 01:49 PM
To be able to call your .NET code with MAXScript, you'll need to build an assembly/class library (if it's not done) containing the core operations of your application.

Hi ypuech, thanks for your reply. Actually it's not .Net code that I need to execute, but my application methods. So basically I need to do something like what has been done for .Net and Max.
I was wondering if this involves using the Max SDK, or what else.

Regards,
Adriano

ypuech
02-27-2008, 02:28 PM
Actually it's not .Net code that I need to execute, but my application methods.
I cannot see the difference; your application is .NET.

So basically I need to do something like what has been done for .Net and Max.
I was wondering if this involves using the Max SDK, or what else.
It's possible to call .NET code in MAXScript but you need to build a class library; you'll be able to use it in C# and MAXScript.
And with dotNet.LoadAssembly() function, you'll be able to load and use the classes defined in your assembly.

Tesctassa
02-27-2008, 04:26 PM
I cannot see the difference; your application is .NET.
Maybe I'm misunderstanding, but only my application's appearance is based on .Net. If it's more clear, let's say that I want to call notepad methods directly from scripts.
Suppose that notepad.exe application as a method called "openFile(String fileName)" and I want to use this method directly from a script. I should be able to create a notepad object inside the script and call its method openFile, a bit like doing with dotNet controls (like treeview or listview) where you declare a treeview variable and the you call methods of the treeview class.

Again, maybe I'm misunderstanding what you're saying, but as far as I see I cannot use that method you say since it's for dotNet objects, classes, assemblies, event handlers ecc only (as reported by the maxscript help), while my application is a completely stand-alone piece of software.

The solution I've been trying to use till now is to use the ShellLaunch command with different parameters for each operation I want to perform by my application, but I was looking for something less tricky :P

By the way, thanks for your help!
Regards,
Adriano
:)

RustyKnight
02-27-2008, 09:24 PM
Have you considered using a COM style bridge??

Or exposing sections of your application to the .net assembilies via a dll or such

Shane

ypuech
02-27-2008, 10:55 PM
As Shane said and as I said before, the best and easiest solution for your problem is to create a .NET class library.
Implement the core methods of your application in this assembly (dll code) and not in your application (exe code). The class library will implement the main operations and you'll be able to call them from C# application exe code and MAXScript.
For example, in the class library you can declare a class "MyApplicationOperations" that will implement all the main application operations. In your application exe code, you add this class library dependency and you can use it as any other .NET class.

In MAXScript, you'll need to load the class library to use it:
dotNet.loadAssembly "AssemblyPath\\MyApplicationOperations.dll"
myApplicationOperations = dotNetObject "MyApplicationNamespace.MyApplicationOperations"
myApplicationOperations.DoOperation1()
etc.

In fact, in .NET, class libraries are very interesting to be able to reuse code. Keeping all the code of a managed application in its exe and you'll loose many advantages of .NET.

Tesctassa
02-28-2008, 06:31 AM
Thanks guys!

As I guessed before I was misunderstanding, now I see what you were saying ypuech. Thanks again for this advice.

Regards,
Adriano
^____^

CGTalk Moderation
02-28-2008, 06:31 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.