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: 2024.0.0+a110b435391768740483e3032720a566518c9a63
Syntax
public static bool SortObjectsByPresentationOrder(
	IList<DrawingObject> objects,
	out List<DrawingObject> objectsByPresentationOrder
)

Parameters

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

Return Value

Type: Boolean
True in case of success, false otherwise
Examples
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)
            {
                try
                {
                    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;
                    else
                        drawingObjects.Add(drawingObject as DrawingObject);
                }
                catch
                {
                    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..");
                }
                else
                {
                    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.
Previous
Next