Enumerate Tekla Structures model and drawing objects

Updated: 13 May 2019

In this guide we explain how to iterate through model and drawing objects in the current model or drawing.

For models, use the class ModelObjectEnumerator and for drawings, DrawingObjectEnumerator.

Enumerate model objects

The ModelObjectEnumerator class provides the means to iterate through model object instances in the current model.

This example shows how to enumerate all selected objects of Beam type and get the solid information of the beams.

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

while(Enum.MoveNext()) 
{
    Beam B = Enum.Current as Beam; 
    if(B != null) 
    {
        Solid Solid = B.GetSolid(); 
    } 
}

Enumerate drawing objects

The DrawingObjectEnumerator class provides the means to iterate through drawing object instances. Drawing object enumerators are generated by the container view and they contain drawing objects that are children of the container view instance.

This example shows how to enumerate all selected objects in the current drawing and delete them.

DrawingObjectEnumerator AllObjects = CurrentDrawing.GetSheet().GetAllObjects(); 

while(AllObjects.MoveNext()) 
{ 
    if(AllObjects.Current is Line) 
    { 
        AllObjects.Current.Delete(); 
    }
}

 

Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.