How do : a basic example

 
 
 
Posted by:johnwhile
Data created:19 December 2011

Hi, i'm using maxscript for long time but in some situation it's very slow. I learning C# also for other application so i discovered the possibility to use this language to improve maxscript velocity and memory.

I have a lot issue with C++ SDK, Autodesk.max.dll seam more simple and clearly but is difficult translate it from max sdk documentation....

The fist issue is how pass and use the 3dstudio objects, so i compiled a C#.dll using your autodesk.max.dll. The C#.dll are in a custom folder, not in maxroot\plugin\...

test.cs

using System;
using System.Collections.Generic;
using System.Text;
using Autodesk.Max;
namespace ClassLibrary
{
    public class MyClass
    {
        private void PrintToListener(IGlobal global, String stringa)
        {
            global.TheListener.EditStream.Printf(stringa + "\n", null);
            return;
        }
        //work
        public String GetNodeName(uint handle)
        {
            IGlobal global = Autodesk.Max.GlobalInterface.Instance;
            IINode node = global.COREInterface13.GetINodeByHandle(handle);
            return node.Name;
        }
        // i want pass a node or an array of node and compute geometric data
        public String Get3dDataFromNode(IValue value)
        {
            IGlobal global = Autodesk.Max.GlobalInterface.Instance;
            int t = global.COREInterface13.Time;
            IINode node = value.ToNode;
            global.TheListener.EditStream.Printf("test:" + node.Name.ToString() + "\n", null);
            IObject obj = node.EvalWorldState(t,false).Obj;
            if (obj.SuperClassID != SClass_ID.Geomobject) PrintToListener(global, "Isn't a geo sclass");
            return node.Name;
        }
    }
}

compiled into test.dll > maxscript loader:

dll = (dotnetclass "System.Reflection.Assembly").Load ((dotnetclass "System.IO.File").ReadAllBytes (@"C:\..\..\test.dll"))
esp = dll.createInstance("ClassLibrary.MyClass")
clearListener() ; showMethods esp ; showProperties esp

Issue:

esp.GetNodeName $.handle >work

esp.Get3dDataFromNode $ > -- Runtime error: No method found which matched argument list


My goal is use maxscript for some internal things, and an external code to export or work with slow function what required a lot of heapsize if i'm using maxscript....

Can someone help me to "break the ice" with C# for 3ds ? i understand the C++ SDK documents but is very complicated use only the "resource explorer" in VisualStudio.

Thanks anyway !