API Reference

Detailed and full API reference helps you master Tekla development

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

DrawingEnumeratorBase Class

The DrawingEnumeratorBase class is a base class for DrawingObjectEnumerator and DrawingEnumerator.
Inheritance Hierarchy

Namespace:  Tekla.Structures.Drawing
Assembly:  Tekla.Structures.Drawing (in Tekla.Structures.Drawing.dll) Version: 2022.0.13611
Syntax
[SerializableAttribute]
public abstract class DrawingEnumeratorBase : IEnumerator

The DrawingEnumeratorBase type exposes the following members.

Properties
  NameDescription
Public propertyStatic memberAutoFetch
Indicates that the objects are fetched from the drawing when the enumerator is created. Object information is therefore not anymore fetched when 'Current' item is asked from the enumerator. Property value is used for all enumerators in application
Top
Methods
  NameDescription
Public methodGetEnumerator
Allows the usage of the foreach statement with DrawingObjectEnumerator.
Public methodGetSize
Returns the total amout of items.
Public methodMoveNext
Moves to the next item in the enumerator.
Public methodReset
Resets the enumerator to the beginning.
Top
Fields
  NameDescription
Public fieldSelectInstances
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
Examples
The following example gets all the drawings and the objects of the drawings.
using Tekla.Structures.Drawing;
using System.Windows.Forms;

public class Example
{
       TreeView drawingListTreeView = new TreeView();
       DrawingHandler DrawingHandler = new DrawingHandler();
       CheckBox ShowViews = new CheckBox();
       CheckBox ShowObjectsInViews = new CheckBox();

       private void AddDrawingInformationToDrawingListTreeView()
       {
           drawingListTreeView.Nodes.Clear();
           DrawingEnumerator DrawingList = DrawingHandler.GetDrawings(); // Get drawing list.

           while (DrawingList.MoveNext())
           {
               Drawing CurrentDrawing = DrawingList.Current;

               // Add the drawing name to the UI tree.
               TreeNode DrawingNode = new TreeNode();
               DrawingNode.Tag = CurrentDrawing;
               DrawingNode.Text = "" + CurrentDrawing.GetType();

               if (ShowViews.Checked)
                   AddChildDrawingObjectsToTreeNode(DrawingNode, CurrentDrawing.GetSheet()); // Add all the objects placed to the sheet to the UI tree.
               drawingListTreeView.Nodes.Add(DrawingNode);
           }
       }

       private void AddChildDrawingObjectsToTreeNode(TreeNode Node, Tekla.Structures.Drawing.IHasChildren CurrentContainer)
       {
           DrawingObjectEnumerator ObjectList = CurrentContainer.GetObjects(); // Gets the objects that are placed directly to the current container object.
           ObjectList.SelectInstances = false; // The instances don't need to be automatically selected, only whether the object exists or not has to be found out (objects properties are not used at all).

           while (ObjectList.MoveNext())
           {
               if(ShowObjectsInViews.Checked || ObjectList.Current is ViewBase)
               {
                   TreeNode CurrentNode = new TreeNode("" + ObjectList.Current.GetType());

                   CurrentNode.Tag = ObjectList.Current;

                   if (ObjectList.Current is Tekla.Structures.Drawing.IHasChildren)
                       AddChildDrawingObjectsToTreeNode(CurrentNode, ObjectList.Current as IHasChildren);

                   Node.Nodes.Add(CurrentNode);
               }
           }
       }
}
See Also