The DataPair class is simply a wrapper around two values.
The values can be of any value type.
The class is available in 3ds Max 2008 and higher.
It was previously available in the Avguard Extensions.
Available in 3ds Max 2017.1 Update and higher: DataPair values can be specified in a persistent global variable. Both values in the DataPair must be specifiable as a persistent global variable in order for the DataPair to be fully restored on scene file load.
Constructors
DataPair ()
DataPair <value1> <value2>
DataPair <value1_name>:<value1> <value2_name>:<value2>
Properties
<dataPair>.v1 : Value
Get/set the first value in the DataPair.
<dataPair>.v2 : Value
Get/set the second value in the DataPair.
<dataPair>.<value1_name> : Value
Get/set the first value in the DataPair by name.
<dataPair>.<value2_name> : Value
Get/set the second value in the DataPair by name.
Methods
getPropNames <dataPair>
Returns array of names values where first two values are #v1 and #v2, remaining 2 values are <value1_name>
and <value2_name>
if that form of the constructor is used.
deepCopy <dataPair> [copyAllValuesAsUnique:<boolean>]
Creates a deep copy of the dataPair. Available in 3ds Max 2019 and higher. The dataPair is recursively traversed, and new copies are generated of all items it contains. Note that if the dataPair contains multiple references to a single value, the deep copy will contain multiple references to a single, new value.
NEW in 3ds Max 2024.1 Update:
The copyAllValuesAsUnique
keyword parameter can be specified as true if you know that all members are unique. This can significantly improve the performance of the copy operation.
EXAMPLES:
--Define a new value consisting of a Point3 value and an Integer
theVal = DataPair [10,20,30] 40
--> (DataPair [10,20,30] 40)
theVal.v1 --get the first value in the pair
--> [10,20,30]
theVal.v2 --get the second value in the pair
--> 40
--Define a new DataPair value with names values
theVal2 = DataPair question:"Life,Universe,And Everything" answer:42
-->(DataPair question:"Life,Universe,And Everything" answer:42)
theVal2.question
--> "Life,Universe,And Everything"
theVal2.answer
--> 42
--You can use the properties too:
theVal2.v1
--> "Life,Universe,And Everything"
theVal2.v2
--> 42
deepEqual <dataPair> <dataPair> [strictCompare:<bool>]
NEW in 3ds Max 2024.1 Update: Performs a comparison of equality between two DataPair values. Returns true if the names (if specified) and values compare as true.
The optional strictCompare
keyword parameter specifies whether to compare without type coercion. The default is false.
For example:
theVal = DataPair #(10,20,30) 40
theVal2 = DataPair #(10,20,30) 40
theVal3 = DataPair #(10.5,20,30) 40.9
theVal==theVal2
--> false, == not implemented for DataPair
deepEqual theVal theVal2
--> true
deepEqual theVal theVal3
--> also true because of type conversion of double to integer
deepEqual theVal theVal3 strictCompare:true
--> false