Tekla Open API

Detailed and full API reference helps you master Tekla Open API

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

ModelHistory Class

The ModelHistory class provides history information about the objects of the model that is currently open in Tekla Structures.
Inheritance Hierarchy
SystemObject
  Tekla.Structures.Model.HistoryModelHistory

Namespace:  Tekla.Structures.Model.History
Assembly:  Tekla.Structures.Model (in Tekla.Structures.Model.dll) Version: 2018.1.0.0 (2018.1.0.0)
Syntax
[SerializableAttribute]
public static class ModelHistory

The ModelHistory type exposes the following members.

Methods
  Name Description
Public methodStatic member GetCurrentModificationStamp Obsolete.
Gets the current modification stamp from the model.
Public methodStatic member GetDeletedObjects Obsolete.
Gets a list of the objects that have been deleted after the modification stamp.
Public methodStatic member GetDeletedObjectsWithType Obsolete.
Gets based on type a list of the objects that have been deleted after the modification stamp.
Public methodStatic member GetLocalChanges
Get changes which are not written out.
Public methodStatic member GetModifications(String, ModificationStamp)
Lookup modifications since previous call of TakeModifications() without resetting the modstamp
Public methodStatic member GetModifications(String, IEnumerableModelObjectModelObjectEnum, ModificationStamp)
Lookup modifications since previous call of TakeModifications() without resetting the modstamp, with object type filtering
Public methodStatic member GetModifiedObjects Obsolete.
Gets a list of the objects that have been added or modified after the modification stamp.
Public methodStatic member GetModifiedObjectsWithType Obsolete.
Gets based on type a list of the objects that have been added or modified after the modification stamp.
Public methodStatic member GetNotSharedObjects
Get object which are was created or modified since last ModelSharing WriteOut.
Public methodStatic member TakeModifications(String, ModificationStamp)
Take modifications since previous call.
Public methodStatic member TakeModifications(String, IEnumerableModelObjectModelObjectEnum, ModificationStamp)
Take modifications since previous call, with object type filtering.
Public methodStatic member UpdateModificationStampToLatest
Updates the modification stamp to latest.
Top
Examples
using Tekla.Structures.Model;
using Tekla.Structures.Model.History;
using System;
using System.Diagnostics;
using Tekla.Structures.Geometry3d;

public class Example1
{
    /// to be called before modifications
    private void Init()
    {
        ModelHistory.TakeModifications("Example1_ModStamp");
    }

    /// to be called when need to handle modifications
    private void Run_TakeModifications()
    {
        var Modifications = ModelHistory.TakeModifications("Example1_ModStamp");
        while (Modifications.Modified.MoveNext())
        {
            ModelObject mo = Modifications.Modified.Current;
            Console.WriteLine("Run_TakeModifications: Modified id: {0}", mo.Identifier.GUID);
        }
    }

    /// to be called when need to preview modifications without advancing modstamp
    private void Run_GetModifications()
    {
        var Modifications = ModelHistory.GetModifications("Example1_ModStamp");
        while (Modifications.Modified.MoveNext())
        {
            ModelObject mo = Modifications.Modified.Current;
            Console.WriteLine("Run_GetModifications: Modified id: {0}", mo.Identifier.GUID);
        }
    }

    /// this takes each modification only once
    public void ModificationProcessed()
    {
        this.Init();
        new Beam(new Point(), new Point(0, 0, 1000))
        {
            Name = "BEAM1",
            Profile = new Profile() { ProfileString = "HEA400" },
            Material = new Material() { MaterialString = "Steel_Undefined" }
        }.Insert();
        new Model().CommitChanges();
        this.Run_TakeModifications(); // prints BEAM1
        new Beam(new Point(), new Point(0, 0, 1000)) 
        {
            Name = "BEAM2",
            Profile = new Profile() { ProfileString = "HEA400" },
            Material = new Material() { MaterialString = "Steel_Undefined" }
        }.Insert();
        new Model().CommitChanges();
        this.Run_TakeModifications(); // prints BEAM2, but not BEAM1
    }

    /// this always returns all modifications since last TakeModifications()
    public void ModificationPreviewed()
    {
        this.Init();
        new Beam(new Point(), new Point(0, 0, 1000)) 
        {
            Name = "BEAM1",
            Profile = new Profile() { ProfileString = "HEA400" },
            Material = new Material() { MaterialString = "Steel_Undefined" }
        }.Insert();
        new Model().CommitChanges();
        this.Run_GetModifications(); // prints BEAM1
        new Beam(new Point(), new Point(0, 0, 1000)) 
        {
            Name = "BEAM2",
            Profile = new Profile() { ProfileString = "HEA400" },
            Material = new Material() { MaterialString = "Steel_Undefined" }
        }.Insert();
        new Model().CommitChanges();
        this.Run_GetModifications(); // prints both BEAM1 and BEAM2
    }
}
See Also