Converting DotNet values to MaxScript?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Display Modes
  06 June 2018
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?
 
  06 June 2018
You can't return a native maxcript Matrix3 from a dotnet object IMatrix3.
__________________
Andrés FC.
P3D_PathScripts

Last edited by aaandres : 07 July 2018 at 11:27 AM.
 
  06 June 2018
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!
 
  06 June 2018
I'm not sure but I think there's a direct casting since 3dsMax 2019.
__________________
Andrés FC.
P3D_PathScripts
 
  06 June 2018
Originally Posted by aaandres:

Matrix3 (Rows[1]) (Rows[1]) (Rows[1]) (Rows[1])


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.
__________________
Jorge Rodríguez
PolyTools3D

Last edited by PolyTools3D : 06 June 2018 at 12:48 PM.
 
  06 June 2018
Edited. Thanks.
__________________
Andrés FC.
P3D_PathScripts
 
  06 June 2018
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
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:41 AM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.