ModelObjectEnumerator Class |
The ModelObjectEnumerator class provides the means to iterate through model object instances in the
current model.
Inheritance Hierarchy
Namespace: Tekla.Structures.Model
Assembly: Tekla.Structures.Model (in Tekla.Structures.Model.dll) Version: 2024.0.0+a110b435391768740483e3032720a566518c9a63
Syntax
The ModelObjectEnumerator type exposes the following members.
Properties
Name | Description | |
---|---|---|
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
| |
Current |
The current model object instance active in the enumerator.
The value is null if there are no more objects left.
| |
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.
|
Methods
Name | Description | |
---|---|---|
GetEnumerator |
Gets the enumerator.
| |
GetSize |
Returns the total amount of items.
| |
MoveNext |
Moves to the next item in the enumerator.
| |
Reset |
Resets the enumerator to the beginning.
|
Examples
A model object enumerator can be used in a foreach loop:
Another way is to browse items "manually":
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 Objects = Model.GetModelObjectSelector().GetAllObjectsWithType(ModelObject.ModelObjectEnum.BEAM); foreach (Beam obj in Objects) { if(obj != null) { Solid Solid = obj.GetSolid(); } } } }
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(); } } } }
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