MAXScript will automatically convert its native values to DotNet values and DotNet values to MAXScript values.
In addition, value conversion can be performed explicitly using a dedicated function in 3ds Max 2010 and higher.
The following table shows the native MAXScript value types and the converted DotNet value types in 3ds Max 9 and higher.
MAXScript type | DotNet type |
---|---|
Integer, Integer64, IntegerPtr, | |
Float, Double, MSTime | Byte, SByte, Decimal, |
Int16, UInt16, Int32, UInt32, | |
IntPtr, UIntPtr, Int64, UInt64, | |
Single, Double | |
Boolean | Boolean |
String | String, Char array |
The following table shows the DotNet value types and the converted native MAXScript value types.
DotNet type | MAXScript type |
---|---|
Byte, SByte, Decimal, | |
Int16, UInt16, Int32, UInt32 | Integer |
Int64, UInt64 | Integer64 |
IntPtr, UIntPtr | IntegerPtr |
Single | Float |
Double | Double |
Boolean | Boolean |
String, Char array | String |
The following method performs a conversion of a MAXScript value to a DotNet value.
Available in 3ds Max 2010 and higher.
dotNet.ValueToDotNetObject <value> { <dotNetClass> | <dotNetObject> }
Returns a dotNetObject value where the MAXScript value passed as first argument is converted to a DotNet object of the type specified by the second argument.
Available in 3ds Max 2018.2 Update and higher: Some native MAXScript types are converted into .NET arrays, as some .NET libraries do not support these types natively. Point2, Point3, Point4, Quat, EulerAngles, and Matrix3 types are all converted into float\[\]
or double\[\]
arrays.
This allows for the easy creation of DotNet arrays from MAXScript arrays:
<value> dotnet.DotNetArrayToValue <dotNetObject> <Matrix3 | Point2 | Point3 | Point4 | Quat | EulerAngles>
Available in 3ds Max 2018.2 Update and higher: Converts the .net array to a value of the specified mxs value type. The .net arrays must be of type float or double. For Matrix3, the .net array must be of size [4,4] , for Point2 it must be of size [2] , for Point3 and EulerAngles it must be of size [3] , and for Point4 and Quat it must be of size [4] .
<value> dotnet.DotNetObjectToValue <dotNetObject>
Available in 3ds Max 2018.2 Update and higher: Converts the .NET object to a MAXScript value.
EXAMPLES
type = dotNetClass "System.Int32[]" --> dotNetClass:System.Int32[] res = dotnet.ValueToDotNetObject #(11,12,23) type --> dotNetObject:System.Int32[] res.length --> 3 res.getvalue 2 --DotNet arrays are zero-based. --> 23
typef = dotnetclass "System.Single[]" --> dotNetClass:System.Single[] vf = dotnet.ValueToDotNetObject x_axis typef --> dotNetObject:System.Single[] vf.get 0 --> 1.0 typed = dotnetclass "System.Double[]" --> dotNetClass:System.Double[] vd = dotnet.ValueToDotNetObject x_axis typed --> dotNetObject:System.Double[] vd.get 0 --> 1.0d0 typefa = dotnetclass "System.Single[][]" --> dotNetClass:System.Single[][] vfa = dotnet.ValueToDotNetObject #([1,2], [1,2,3], [1,2,3,4], (quat 0.854433 0.00437304 0.0050751 0.519518), (eulerAngles -117.399 -0.757267 0.126046) ) typefa --> dotNetObject:System.Single[] vfa0 = vfa.get 0 --> #(1.0, 2.0) vfa1 = vfa.get 1 --> #(1.0, 2.0, 3.0) vfa2 = vfa.get 2 --> #(1.0, 2.0, 3.0, 4.0) vfa3 = vfa.get 3 --> #(0.854433, 0.00437304, 0.0050751, 0.519518) vfa4 = vfa.get 4 --> #(-2.049, -0.0132168, 0.00219992)
typef2 = dotnetclass "System.Single[]" vfa2 = dotnet.ValueToDotNetObject (matrix3 [0.99991,0.0127462,0.00412892] [0.00219972,-0.460163,0.887832] [0.0132164,-0.887743,-0.46015] [90,0,-45]) typef2 --> dotNetClass:System.Single[,] vfa2.get 0 0 --> 0.99991