Tekla Open API

Detailed and full API reference helps you master Tekla Open API

This is the most recent version of Tekla Open API.
For older versions, please visit Tekla Warehouse.

ModelObjectEnumerator Class

The ModelObjectEnumerator class provides the means to iterate through model object instances in the current model.
Inheritance Hierarchy
SystemObject
  Tekla.Structures.ModelModelObjectEnumerator

Namespace:  Tekla.Structures.Model
Assembly:  Tekla.Structures.Model (in Tekla.Structures.Model.dll) Version: 2018.1.0.0 (2018.1.0.0)
Syntax
[SerializableAttribute]
public sealed class ModelObjectEnumerator : IEnumerator

The ModelObjectEnumerator type exposes the following members.

Properties
  Name Description
Public propertyStatic member AutoFetch
Indicates that the objects are fetched from the model when the enumerator is created. Object information is therefore not anymore fetched when 'Current' item is asked from the enumerator. Warning: changing of TransformationPlane after creation of enumerator or during the enumeration requires a separate selection of object for refreshing the values. Property value is used for all enumerators in application
Public property Current
The current model object instance active in the enumerator. The value is null if there are no more objects left.
Public property SelectInstances
Indicates that the instance Select() is called when the 'Current' item is asked from the enumerator. The user can set this to 'false' if no members are ever asked from the instance. This is the case when, for example, asking only a report property from the identifier. Warning: normally the user should not change this value.
Top
Methods
  Name Description
Public method GetEnumerator
Gets the enumerator.
Public method GetSize
Returns the total amount of items.
Public method MoveNext
Moves to the next item in the enumerator.
Public method Reset
Resets the enumerator to the beginning.
Top
Examples
A model object enumerator can be used in a foreach loop:
using Tekla.Structures.Model;

public class Example
{
       public void Example1()
       {
           Model Model = new Model();

           ModelObjectEnumerator Objects = Model.GetModelObjectSelector().GetAllObjectsWithType(ModelObject.ModelObjectEnum.BEAM);

           foreach (Beam obj in Objects) 
           {
               if(obj != null)
               {
                   Solid Solid = obj.GetSolid();
               }
           }
       }
}
Another way is to browse items "manually":
using Tekla.Structures.Model;

public class Example
{
       public void Example1()
       {
           Model Model = new Model();

           ModelObjectEnumerator Enum = Model.GetModelObjectSelector().GetAllObjects();

           while(Enum.MoveNext())
           {
               Beam B = Enum.Current as Beam;
               if(B != null)
               {
                   Solid Solid = B.GetSolid();
               }
           }
       }
}
A model object enumerator with AutoFetch set to true in a foreach loop:
using Tekla.Structures.Model;

public class Example
{
       public void Example1()
       {
           Model Model = new Model();

           ModelObjectEnumerator.AutoFetch = true;

           ModelObjectEnumerator Objects = Model.GetModelObjectSelector().GetAllObjectsWithType(ModelObject.ModelObjectEnum.BEAM);

           foreach (Beam obj in Objects) 
           {
               if(obj != null)
               {
                   Solid Solid = obj.GetSolid();
               }
           }
       }
}
See Also