Dynamically changing structure of a model
This topic describes how to modify hierarchy of objects in the model by
deleting or adding new objects to the model.
Array of objects in the model and arrays of child objects of a parent object
(entity) can be manipulated programmatically with IArray interface. When IArray
obtained from IModel interface it manages top level objects of the model. When
IArray is obtained from an ISection interface it manages array of child objects
of the object, which implements the ISection interface.
To delete an object call RemoveAt() method of the IArray. To add a new object
the object has to be created using correspondent Object Generator. See
Dynamic
object creation topic for details. Output of the object creation procedure is a
reference to
ISection interface, which can be supplied to Add() or
InsertAt() methods of IArray.
For example to add new top level 3DO object to the model:
- Obtain I3DSectionGenerator (See
Dynamic
object creation).
- Create new 3DO object using Create method of I3DSectionGenerator.
- Query IArray interface from IModel.
- Call Add() method of IArray, supplying the interface obtained in the step 2.
To add a new child object to an existing entity in step 3 query
IArray form the correspondent
ISection instead of IModel.
See also Object Array programming sample.
|