3ds MAX 2023 SDK .NET in C# Create a IPoint3 is always normalized!

3ds MAX 2023 SDK .NET in C# Create a IPoint3 is always normalized!

mmoraisdois
Participant Participant
370 Views
6 Replies
Message 1 of 7

3ds MAX 2023 SDK .NET in C# Create a IPoint3 is always normalized!

mmoraisdois
Participant
Participant

Hi 

In  3ds MAX 2023 SDK .NET using  C#   when Create a IPoint3 the value is always normalized!

 

Autodesk.Max.IPoint3 mypoint = Autodesk.Max.GlobalInterface.Instance.Point3.Create( 10.0f,  5.0f, 2.0f); 

when debugging the code the coordinates of myPoint are not the ones that were created,

but rather the same as the normalized vector!

if try to reassing like 
mypoint.X = 10.0f;  is the same! 

I'm missing something?

0 Likes
Accepted solutions (1)
371 Views
6 Replies
Replies (6)
Message 2 of 7

mmoraisdois
Participant
Participant

All  vars that use  IPoint3  the coordinates are normalized! 

 

IPoint3 midleSegment = spline.InterpBezier3D(0, 0.5f, SPLINE_INTERP_SIMPLE);
//return X= 0.25  , Y= 0.96, Z= -0.09

Is a bug in 3ds MAX 2023?

0 Likes
Message 3 of 7

istan
Advisor
Advisor

Have you also tested with MXS?

0 Likes
Message 4 of 7

mmoraisdois
Participant
Participant

I did this small code

public float[] GetPoint3()
{
    IGlobal Global = Autodesk.Max.GlobalInterface.Instance;
    IPoint3 mypoint = Global.Point3.Create(10.0f, 5.0f, 2.0f);
    float myX = mypoint.X;
    float myY = mypoint.Y;
    float myZ = mypoint.Z;
   
    float[] aPoint = new float[3];
    aPoint[0] = myX;
    aPoint[1] = myY;
    aPoint[2] = myZ;
   
    return aPoint; //return 0.880451, 0.440225, 0.17609
}

 In MSX not exist IPoint3  exist Point3 and works.

0 Likes
Message 5 of 7

mmoraisdois
Participant
Participant

I did more some test in MAX 2025 with .NET 4.8.1  and works!  when  get the coordinates to a float.


But the when add the IPoint3 variable to the debugger Watch,  show me the normalized values! 

2025-06-08 10_40_49-SKDtests (Debugging) - SKDTools.cs - Microsoft Visual Studio.jpg

0 Likes
Message 6 of 7

mmoraisdois
Participant
Participant

I found the problem! 
if run the code with  debugger step by step  I get normalized values (the IPoint3.Length set to 1!) 

But if run the code  normal and log the vars to listener  all works!!

public class SDKTools
{
    private static readonly IGlobal Global = Autodesk.Max.GlobalInterface.Instance;
    private static void LogToListener(string message, bool newLine = true)
    {
        if (Global != null)
        {
            IListener listener = Global.TheListener;
            IWindowStream editStream = listener.EditStream; // Declare and assign editStream here
            editStream.Wprintf(message + (newLine ? Environment.NewLine : string.Empty), null);
        }
    }
    private string Point3ToStr(IPoint3 point)
    {
        return $"[{point.X}, {point.Y}, {point.Z}]";
    }

    public float[] GetPoint3()
    {
        IPoint3 mypoint = Global.Point3.Create(8f, 6f, 4f);
        float myX = mypoint.X;
        float myY = mypoint.Y;
        float myZ = mypoint.Z;
        float pLen = mypoint.Length;
        LogToListener($"mypoint: [{myX}, {myY}, {myZ}]  Lenght: {pLen}"); 
        IMatrix3 myMatrix = Global.Matrix3.Create();
        myMatrix.SetRow(3, mypoint); 
        IPoint3 row3 = myMatrix.GetRow(3);
        LogToListener($" myMatrix Row3: {Point3ToStr(row3)}"); 
        float[] aPoint = new float[3];
        aPoint[0] = myX;
        aPoint[1] = myY;
        aPoint[2] = myZ;
        LogToListener($" aPoint: {aPoint} "); 
        IPoint3 mypoint2 = Global.Point3.Create();
        //get values again 
        mypoint2.X = 10.0f;
        mypoint2.Y = 5.0f;
        mypoint2.Z = 2.0f;
        LogToListener($" mypoint2: {Point3ToStr(mypoint2)}");
        IPoint3 sum = mypoint2.Add(mypoint); //mypoint2+mypoint = 18.0f, 11.0f, 6.0f
        LogToListener($" Sum = mypoint2 + mypoint: {Point3ToStr(sum)} ");
        IPoint3 point3 = myMatrix.PointTransform(sum); // Point3 = [26, 17, 10] 
        float[] SumPoints = new float[3];
        SumPoints[0] = point3.X;
        SumPoints[1] = point3.Y;
        SumPoints[2] = point3.Z;
        LogToListener($" point3 = myMatrix * sum: {Point3ToStr(point3)} ");
        return SumPoints; 
    }
    
}

 

Output
mypoint: [8, 6, 4] Lenght: 10.77033
myMatrix Row3: [8, 6, 4]
aPoint: System.Single[]
mypoint2: [10, 5, 2]
Sum = mypoint2 + mypoint: [18, 11, 6]
point3 = myMatrix * sum: [26, 17, 10]  

0 Likes
Message 7 of 7

mmoraisdois
Participant
Participant
Accepted solution

the problem is the debugger! if you run the code without the debugger everything works fine, but if I use the debugger step by step all the variables like IPoint3 the coordinates are normalized.

did this sample code to log to listener

 

public class SDKTools
    {
        private static readonly IGlobal Global = Autodesk.Max.GlobalInterface.Instance;
        private static void LogToListener(string message, bool newLine = true)
        {
            if (Global != null)
            {
                IListener listener = Global.TheListener;
                IWindowStream editStream = listener.EditStream; // Declare and assign editStream here
                editStream.Wprintf(message + (newLine ? Environment.NewLine : string.Empty), null);
            }
        }
        private string Point3ToStr(IPoint3 point)
        {
            return $"[{point.X}, {point.Y}, {point.Z}]";
        }

        public float[] GetPoint3()
        {
            IPoint3 mypoint = Global.Point3.Create(8f, 6f, 4f);
            float myX = mypoint.X;
            float myY = mypoint.Y;
            float myZ = mypoint.Z;
            float pLen = mypoint.Length;
            LogToListener($"mypoint: [{myX}, {myY}, {myZ}]  Lenght: {pLen}"); 
            IMatrix3 myMatrix = Global.Matrix3.Create();
            myMatrix.SetRow(3, mypoint); 
            IPoint3 row3 = myMatrix.GetRow(3);
            LogToListener($" myMatrix Row3: {Point3ToStr(row3)}"); 
            float[] aPoint = new float[3];
            aPoint[0] = myX;
            aPoint[1] = myY;
            aPoint[2] = myZ;
            LogToListener($" aPoint: {aPoint} "); 
            IPoint3 mypoint2 = Global.Point3.Create();
            //get values again 
            mypoint2.X = 10.0f;
            mypoint2.Y = 5.0f;
            mypoint2.Z = 2.0f;
            LogToListener($" mypoint2: {Point3ToStr(mypoint2)}");
            IPoint3 sum = mypoint2.Add(mypoint); //mypoint2+mypoint = 18.0f, 11.0f, 6.0f
            LogToListener($" Sum = mypoint2 + mypoint: {Point3ToStr(sum)} ");
            IPoint3 point3 = myMatrix.PointTransform(sum); // Point3 = [26, 17, 10] 
            float[] SumPoints = new float[3];
            SumPoints[0] = point3.X;
            SumPoints[1] = point3.Y;
            SumPoints[2] = point3.Z;
            LogToListener($" point3 = myMatrix * sum: {Point3ToStr(point3)} ");
            return SumPoints; 
        }
        
    }

 

0 Likes