custom classes for scriptOp with maxscript on-fly assembly ?
#1
Hi Tyson,
I would like to have all my C# classes and functions loaded in all tyflow scriptOps with the "using" command... do I have to compile my C# code or can I go with the on-fly maxscript method? I tried but with no luck... I don't want to open visual studio! please tell me it's possible! and how Wink
  Reply
#2
Can you be more specific about how you'd like to load the classes? Do you have a pre-built DLL you want to import or is it just a .cs file?
  Reply
#3
Here is what I'm trying to achieve from maxscript in order to get my classes back
I thaught just typing "using MyNamespace;" in a scriptOp would work but no..

Code:
fn MyAssembly =
(
    source  =
"//////////////////////////////////////////////////////   C#   ////////////////////////////////////////////////////////////////
using System;
using Autodesk.Max;      
using Autodesk.Max.Wrappers;
using tfcpp; // tyFlow namespace ???
 
namespace MyNamespace
{
   public class MyClass
   {
       public static void myMethod()
       {
        // bla bla using tyFlow.classes eventually
       }
   }
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
"

    local csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
    local compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
    compilerParams.ReferencedAssemblies.Add "Whatever is needed"
    compilerParams.GenerateInMemory = on
    local compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)

    (compilerResults.CompiledAssembly).CreateInstance "MyNamespace.MyClass"
)

I wanted to do it from maxscript for convenience and of course for not having to restart max, but if prebuild dll is the only way, I'll do it.
I'm writing a Max helper pugin for character rigging purposes and IK solving, for now in maxscript/C# and maybe totally C# later..,
and I want it to work for both rigs and tyActors!

It would be great if you could point me how to load/access my classes in the scriptOp?
whether it be on max startup or on fly, using maxscript, cs file, or prebuilt dll...

thanks!
  Reply
#4
I'm just starting learning C# and really enjoyed using the script operator so far, this my new favorite hobby!
But problems began when I wanted to use my own classes  in different scriptOps...
Just for you to know, my classes are just made of dictionnaries or arrays of int, quat and point3 with a few methods... but the code is getting bigger and bigger!
I hope not to bother you with all these questions, I don't even know if my last request implies that you recompile tyflow to add references from my cs files Big Grin
Anyway, it seems way more difficult than manipulting dotnet objects in maxscript! and writing c# for late use in tyflow is far from being a simple csproj tutorial  Undecided
I know you're busy but any examples, tips or links regarding the usage of cs.files or pre build dll with tyflow script operator would be much appreciated!

thanks!
  Reply


Forum Jump: