Notifications
Clear all

[Closed] Max geometry esporter in C#

Ya, it’s copied from my other one that works

hae you take a look at http://forums.cgsociety.org/showthread.php?f=98&t=1020505&page=2&pp=15 ?
have you compiled in framework 2.0 ? the 3dstdio 64 bit have a lot of problem.

Hm… Yes, it is Dotnet 2.0 I’m pretty sure, compiled as 64bit for 64bit Max.

I could try to compile as 3.5 or something and see if it works?

1 Reply
(@johnwhile)
Joined: 1 year ago

Posts: 0

uhm, give me source code, because i think the problem is the 64bit version, i have max32 and 64 also, and 64 do a lot of problem with dll…

I have 32 and 64bit as well. I will try those later.

Hi i tried to build a kind of conversion from maxsript and csharp’s dll, passing a DotNet array of point can be in my opinion a good solution to exchange some basic geometry data.

fn main =
(
	clearlistener()
	dll = dotnet.loadAssembly "my.dll"
	Point3Class = dotnetclass "Test.Point3Class"
	VertexCont = 10
	Vertex = dotnetobject "Test.Point3Class[]" (dotNetObject "System.Int32" VertexCont)
	
	-- C# is zero based !
	for n=0 to VertexCont-1 do
	(
		local Pt = dotnetobject "Test.Point3Class" (n*3+1) (n*3+2) (n*3+3)
		local Idx = dotNetObject "System.Int32" n -- in max9 32bit using Idx = n is the same
		format "set>P% [%,%,%]
" n Pt.x Pt.y Pt.z
		Vertex.Set Idx Pt
	) 
	for n=0 to VertexCont-1 do
	(
		local Idx = dotNetObject "System.Int32" n
		local Pt = Vertex.Get Idx
		format "get<P% [%,%,%]
" n Pt.x Pt.y Pt.z
	)
	OK
)

main()

and this the C# code (compile as dll library with Visual C# 2005 express)


using System;
using System.Collections.Generic;
using System.Text;

namespace Test
{
    public class Point3Class
    {
        public static float x = 0;
        public static float y = 0;
        public static float z = 0;
        public Point3Class(float X ,float Y,float Z)
        {
            x = X;
            y = Y;
            z = Z;
        }
        public float length()
        {
            float sq = (x * x) + (y * y) + (z * z);
            return sq;
        }
    }
    public class TheClass
    {
        public float Test(Point3Class[] vertex)
        {
            float accum = 0;
            for (int i = 0; i < vertex.Length; i++)
            {
                accum += vertex[i].length();
            }
            return accum;
        }
    }
}

but don’t work because all Points printed have the same value ??? And i’m not sure that i’ve written is corect

Page 3 / 3