How to pass a points arry to a Dotnet function

How to pass a points arry to a Dotnet function

flyingc007
Explorer Explorer
1,145 Views
8 Replies
Message 1 of 9

How to pass a points arry to a Dotnet function

flyingc007
Explorer
Explorer

Hi,

I have an array of points,such as #([1,3,4],[53,12,1])

If I want to pass it as an argument to a DotNet funtion .

How would I do?

 

Thanks in advance.

 

0 Likes
1,146 Views
8 Replies
Replies (8)
Message 2 of 9

flyingc007
Explorer
Explorer

(where do I edit the post?I can't find )

 

This question  is about MAXScript.

 

I need to pass an argument of  points array to a DotNet function.

 

 

0 Likes
Message 3 of 9

istan
Advisor
Advisor

Visual Studio / Solution / References / Add Reference: "3dsmax_path\Autodesk.Max.DLL"

Then use the object browser. There you'll find everything Max is exposing to dotNet.

There's another interesting one: MaxCustomControls.DLL

0 Likes
Message 4 of 9

denisT.MaxDoctor
Advisor
Advisor

it depends on the type of dotnet function you are using ... show your function definition to see the type of input data

0 Likes
Message 5 of 9

flyingc007
Explorer
Explorer

For example.

I have a point3 struct,and a sum function like this

 

public struct point3
    {
        public float x, y, z;
        public point3(float x1, float y1, float z1)
        {
            x = x1;
            y = y1;
            z = z1;
        }
    }
public static point3 sum(int num,point3[] pts)
        {
            
            for (int i = 1; i < num; i++)
            {
                pts[1].x += pts[i].x;
                pts[1].y += pts[i].y;
                pts[1].z += pts[i].z;

            }
            return pts[1];
        }

I want to call the function in MaxScript,so the problem is how to pass a points array to the sum() function.

 

 

 

0 Likes
Message 6 of 9

flyingc007
Explorer
Explorer

sorry ,I forgot to mention one thing.

I need to call the function in 3dsmax 2012 or below the version.

But "Autodesk.3dsmax.dll" is not availibale in these version.

0 Likes
Message 7 of 9

istan
Advisor
Advisor
arr=#( dotnetobject("mydotnetclass.point3") 1 2 3, dotnetobject("mydotnetclass.point3") 4 5 6)
local ret = dotnetclass("mydotnetclass").sum arr.count arr

I'd do it somehow like this under Max2020..

Message 8 of 9

flyingc007
Explorer
Explorer

Yes,it can work,but it seems a bit complex

 it will be much better if the array can be turn to pointer to a memory.

0 Likes
Message 9 of 9

denisT.MaxDoctor
Advisor
Advisor

@flyingc007 wrote:

it seems a bit complex...

 



pass it as a pointer to float's array... and cast in c# .. three floats per point

0 Likes