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: 2023.0.3
Syntax
[SerializableAttribute]
public static class ModelHistory

The ModelHistory type exposes the following members.

Methods
  NameDescription
Public methodStatic memberGetCurrentModificationStamp Obsolete.
Gets the current modification stamp from the model.
Public methodStatic memberGetDeletedObjects Obsolete.
Gets a list of the objects that have been deleted after the modification stamp.
Public methodStatic memberGetDeletedObjectsWithType Obsolete.
Gets based on type a list of the objects that have been deleted after the modification stamp.
Public methodStatic memberGetLocalChanges
Get changes which are not written out.
Public methodStatic memberGetModifications(String, ModificationStamp)
Lookup modifications since previous call of TakeModifications() without resetting the modstamp
Public methodStatic memberGetModifications(String, IEnumerableModelObjectModelObjectEnum, ModificationStamp)
Lookup modifications since previous call of TakeModifications() without resetting the modstamp, with object type filtering
Public methodStatic memberGetModifiedObjects Obsolete.
Gets a list of the objects that have been added or modified after the modification stamp.
Public methodStatic memberGetModifiedObjectsWithType Obsolete.
Gets based on type a list of the objects that have been added or modified after the modification stamp.
Public methodStatic memberGetNotSharedObjects
Get object which are was created or modified since last ModelSharing WriteOut.
Public methodStatic memberTakeModifications(String, ModificationStamp)
Take modifications since previous call.
Public methodStatic memberTakeModifications(String, IEnumerableModelObjectModelObjectEnum, ModificationStamp)
Take modifications since previous call, with object type filtering.
Public methodStatic memberUpdateModificationStampToLatest
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
Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.
Previous
Next