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: 2024.0.0+a110b435391768740483e3032720a566518c9a63
Syntax
[SerializableAttribute]
public sealed class ModelObjectEnumerator : IEnumerator

The ModelObjectEnumerator type exposes the following members.

Properties
  NameDescription
Public propertyStatic memberAutoFetch
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 propertyCurrent
The current model object instance active in the enumerator. The value is null if there are no more objects left.
Public propertySelectInstances
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
  NameDescription
Public methodGetEnumerator
Gets the enumerator.
Public methodGetSize
Returns the total amount of items.
Public methodMoveNext
Moves to the next item in the enumerator.
Public methodReset
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
Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.
Previous
Next