OperationSortObjectsByPresentationOrder Method

Sorts objects relatively by presentation order from active drawing. Result is used to define relative drawing order of objects which are on top of each other. Last object from the list is drawn on top of all objects.

Namespace:  Tekla.Structures.Drawing.Operations
Assembly:  Tekla.Structures.Drawing (in Tekla.Structures.Drawing.dll) Version: 2023.0.3
public static bool SortObjectsByPresentationOrder(
	IList<DrawingObject> objects,
	out List<DrawingObject> objectsByPresentationOrder


Type: System.Collections.GenericIListDrawingObject
Contains the objects layers are asked from
Type: System.Collections.GenericListDrawingObject
Contains objects sorted by presentation order

Return Value

Type: Boolean
True in case of success, false otherwise
The following example enumerates through all objects in all views and gets relative layers of objects.
using System;
using System.Collections.Generic;
using Tekla.Structures.Geometry3d;
using Tekla.Structures.Drawing;
using TSD = Tekla.Structures.Drawing;

class Example
    public void MergeMarksTest()
        DrawingHandler drawingHandler = new DrawingHandler();

        var drawing = drawingHandler.GetActiveDrawing();
        if (drawing != null)
            List<DrawingObject> drawingObjects = new List<DrawingObject>();

            // pick marks to be merged
            ViewBase pickedView;
            DrawingObject drawingObject;
            var picker = drawingHandler.GetPicker();
            bool continuePicking = true;
            while (continuePicking)
                    var message = "Pick object " + (drawingObjects.Count + 1).ToString() + " layer to be asked. Press Esc to finish..";
                    picker.PickObject(message, out drawingObject, out pickedView);
                    if (drawingObject == null || pickedView == null || !(drawingObject is DrawingObject))
                        continuePicking = false;
                        drawingObjects.Add(drawingObject as DrawingObject);
                    continuePicking = false;

            if (drawingObjects.Count > 1)
                List<DrawingObject> sortedObjects = new List<DrawingObject>();
                TSD.Operations.Operation.SortObjectsByPresentationOrder(drawingObjects, out sortedObjects);
                if (layers.Count > 0)
                    Console.WriteLine("SortObjectsByPresentationOrder operation successful with " + layers.Count.ToString() + " layers..");
                    Console.WriteLine("SortObjectsByPresentationOrder operation failed..");
See Also
Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.