[Closed] Converting DotNet values to MaxScript?
Ive been trying to research this but my googlefu is lacking and im just getting mountains of results for converting MaxScript values to DotNet values.
However what im trying to achieve is the opposite.
I have a C# method that returns an IMatrix3 type, and when I call that from maxscript it just returns a <dotNetObject:Autodesk.Max.Wrappers.Matrix3> which isnt usable for anything.
Is there some type i could use in C# that would make it automatically return a native maxscript type? and if not, would there be some way of converting this DotNetObject to a maxscript Matrix3?
You can’t return a native maxcript Matrix3 from a dotnet object IMatrix3.
Damn… I was afraid i’d have to do that but I guess it cant be helped.
thanks for the example though, thatll be useful!
Matrix3 (Rows[1]) (Rows[2]) (Rows[3]) (Rows[4])
Alternatively, maybe easier to read (to me), you could do:
fn ConvertMatrix tm =
(
r1 = tm.GetRow 0
r2 = tm.GetRow 1
r3 = tm.GetRow 2
r4 = tm.GetRow 3
return (matrix3 [r1.x, r1.y, r1.z] [r2.x, r2.y, r2.z] [r3.x, r3.y, r3.z] [r4.x, r4.y, r4.z])
)
3ds Max 2018.4 Update
Conversion for Point2, Point3, Point4, Quat, EulerAngles and Matrix3 to .NET arrays.
I ended up going with
Row1 = dotnetMatrix.GetRow(0); Row2 = dotnetMatrix.GetRow(1); Row3 = dotnetMatrix.GetRow(2); Row4 = dotnetMatrix.GetRow(3)
matrix = Matrix3 (Point3 Row1.X Row1.Y Row1.Z) (Point3 Row2.X Row2.Y Row2.Z) (Point3 Row3.X Row3.Y Row3.Z) (Point3 Row4.X Row4.Y Row4.Z)
keeps the line count to a minimum… out of sight out of mind