|
 |  | MFValue
|
MFValue Collection
See also: Using collections, Using field value objects.
| |

 |
Add method, ( [Value], [Before] ) As Object.
Adds a new value to the specified MFValue collection. Returns a Node object that represents the node to be added for MFNode field type, or Nothing for all other field types.
Value (Optional) A Variant that represents the value you want to add.
The following table summarizes the results of using the Add property depending on a field type of the Field object.
| Type | Add Results |
 |
| SFImage | Adds an Integer (or compatible) number. |
 |
| MFColor | Adds an array of three Single (or compatible) numbers, that represents the Red, Green and Blue components of the value. |
 |
| MFFloat | Adds a Single (or compatible) value. |
 |
| MFInt32 | Adds a Long (or compatible) value. |
 |
| MFNode | Adds a String value, that represents the typename of a new node, or a Proto object, that represents a template for a new node, or a Node object, that represents the definition for a new node (by means of the DEF/USE syntax). |
 |
| MFRotation | Adds an array of four Single (or compatible) numbers, that represents the X, Y, Z and Angle components of the value. |
 |
| MFString | Adds a String value. |
 |
| MFTime | Adds a Double (or compatible) value. |
 |
| MFVec2f | Adds an array of two Single (or compatible) numbers, that represents the X and Y components of the value. |
 |
| MFVec3f | Adds an array of three Single (or compatible) numbers, that represents the X, Y and Z components of the value. |
Omitting the Value argument or adding Empty to the MFValue collection adds a default value, that is 0 0 1 0 for MFRotation, "" for MFString and so on.
Before (Optional) An index of a new item in the collection. The value to be added is inserted in the collection before the value identified by the Before argument.
If a numeric expression, Before must be a number from 1 to Count.
If an object expression, Before is a Node object from the collection.
By default, a new subvalue is inserted at the end of the collection.
The following VBScript macro adds a Shape node to the children field, adds reference to this node and then inserts reference to a parent node before the Shape node.
Set f = RootNodes.Add("Group")("children")
f.Add "Shape"
f.Add f(1)
f.Add f.Owner, 1
|
|

| |

 |
Array property, read-only, Variant.
Return an array of all subvalues in the specified collection. The largest available subscript for the first dimension of the array is one less than the value of the collection's Count property.
The following table summarizes the results of using the Array property depending on a field type of the Field object.
| Type | Results |
 |
| SFImage | Array of Integer numbers. |
 |
| MFColor | Two-dimensional array N x 3 of Single numbers, that represents the Red, Green and Blue components of the value. |
 |
| MFFloat | Array of Single numbers. |
 |
| MFInt32 | Array of Long numbers. |
 |
| MFNode | Array of Node objects. |
 |
| MFRotation | Two-dimensional array N x 4 of Single numbers, that represents the X, Y, Z and Angle components of the value. |
 |
| MFString | Array of String values. |
 |
| MFTime | Array of Double numbers. |
 |
| MFVec2f | Two-dimensional array N x 2 of Single numbers, that represents the X and Y components of the value. |
 |
| MFVec3f | Two-dimensional array N x 3 of Single numbers, that represents the X, Y and Z components of the value. |
The following example is a Visual C++ code snippet uses the Array property to iterate through all subvalues of a MFVec3f field and calculate a bounding box of the points.
VARIANT varVal, varArr, varElem;
VariantInit( &varVal );
pField->get_Value( &varVal );
MFValue *pValue;
varVal.pdispVal->QueryInterface( IID_MFValue, (void**) &pValue);
VariantClear( &varVal );
VariantInit( &varArr );
pValue->get_Array( &varArr );
pValue->Release();
VariantInit( &varElem );
float aMin [3] = { FLT_MAX, FLT_MAX, FLT_MAX };
float aMax [3] = { -FLT_MAX, -FLT_MAX, -FLT_MAX };
long lBound;
SafeArrayGetUBound( varArr.pArray, 1, &lBound );
for (long i = 0; i <= lBound; i++)
{
for (long j = 0; j < 3; j++)
{
long aInds [2] = { i, j };
SafeArrayGetElement( varArr.pArray, aInds, &varElem );
VariantChangeType( &varElem, &varElem, 0, VT_R4 );
aMin[j] = min( aMin[j], varElem.fltVal);
aMax[j] = max( aMax[j], varElem.fltVal);
VariantClear( &varElem );
}
}
VariantClear( &varArr );
|
|

| |

 |
Clear method.
Deletes all values from the specified collection and sets the Count property to 0.
|

| |

 |
Count property, read-only, Long.
Returns the number of items in the specified collection.
|

| |

 |
Item property, default, read/write, ( Index As Long ) As Variant.
Gets or sets a subvalue of the specified collection.
Index An index in the collection representing the appropriate subvalue (a number from 1 to the value of the collection's Count property).
The following table summarizes the results of using the Item property depending on a field type of the Field object.
| Type | Get Results | Set Results |
 |
| SFImage | Gets an Integer value. | Sets an Integer (or compatible) value. |
 |
| MFColor | Returns a SFColor object. | Sets an array of three Single (or compatible) numbers, that represents the Red, Green and Blue components of the value. |
 |
| MFFloat | Gets a Single field value. | Sets a Single (or compatible) value. |
 |
| MFInt32 | Gets a Long field value. | Sets a Long (or compatible) value. |
 |
| MFNode | Returns a Node object. | Sets a String value, that represents the typename of a new node, or a Proto object, that represents a template for a new node, or a Node object, that represents the definition for a new node (by means of the DEF/USE syntax). |
 |
| MFRotation | Returns a SFRotation object. | Sets an array of four Single (or compatible) numbers, that represents the X, Y, Z and Angle components of the value. |
 |
| MFString | Gets a String value. | Sets a String value. |
 |
| MFTime | Gets a Double value. | Sets a Double (or compatible) value. |
 |
| MFVec2f | Returns a SFVec2f object. | Sets an array of two Single (or compatible) numbers, that represents the X and Y components of the value. |
 |
| MFVec3f | Returns a SFVec3f object. | Sets an array of three Single (or compatible) numbers, that represents the X, Y and Z components of the value. |
Assigning Empty to the Item property sets a subvalue of the specified collection to the initial value, that is 0 0 1 0 for MFRotation, "" for MFString and so on.
|

| |

 |
Remove method, ( Index As Long ).
Removes a subvalue from the specified collection.
Index An index of the subvalue in the collection (a number from 1 to the value of the collection's Count property).
If the subvalue is a named node, all references to the node will be deleted. If the subvalue contains declarations that have references outside the subvalue, all such references will also be deleted.
|

| |

 |
_NewEnum property, read-only.
References subvalues in the specified collection.
With C++, you can browse a collection to find a particular item by using the _NewEnum or the Item properties. In Visual Basic and VBScript, you do not need to use the _NewEnum property, because it is automatically used in the implementation of For Each ... Next or in For ... in statement in JavaScript.
The following example replaces X and Y coordinates in a field of the MFVec2f type.
Dim Values As MFValue
Dim v As SFVec2f
Set Values = Document("TexCoords")("point").Values
For Each v In Values
v.Set v.y, v.x
Next
|
|

|
|
|