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.

Events Class

The Events class allows the user to register event listeners for model events.
Inheritance Hierarchy

Namespace:  Tekla.Structures.Model
Assembly:  Tekla.Structures.Model (in Tekla.Structures.Model.dll) Version: 2019.0.0.0 (2019.0.0.0)
Syntax
[SerializableAttribute]
public sealed class Events : MarshalByRefObject

The Events type exposes the following members.

Constructors
  Name Description
Public method Events
Creates an empty events instance.
Top
Methods
  Name Description
Public method InitializeLifetimeService
Initializes the lifetime service.
(Overrides MarshalByRefObjectInitializeLifetimeService.)
Public method OnInterrupted
Called when uesr interrupts.
Public method Register
Registers the instance to listen to the specified events. More event delegates should not be added without calling UnRegister first.
Public method UnRegister
Unregisters the instance from listening to events.
Top
Events
  Name Description
Public event ClashCheckDone
The ClashCheckDone event is raised just after clash check is completed.
Public event ClashDetected
The ClashDetected event is raised just after the detection of each clash. The clash information is saved before the event is triggered.
Public event CommandStatusChange
The CommandStatusChange event is raised when a command is started/ended.
Public event Interrupted
Occurs when user interrupts.
Public event ModelChanged Obsolete.
The ModelChanged event is raised just after some changes have been made to the model.

Note, this event is however not triggered when UNDO or REDO are performed.

Public event ModelLoad
The ModelLoad event is raised just after a model has been loaded.
Public event ModelObjectChanged
The ModelObjectChanged event is raised just after some changes have been made to the model objects.

Note, this event is triggered when UNDO or REDO are performed!!

Public event ModelObjectNumbered
The ModelObjectNumbered event is raised when model object is numbered.
Public event ModelSave
The ModelSave event is raised just after a model has been saved.
Public event ModelSaveAs
The ModelSaveAs event is raised just after a model has been saved using save as.
Public event ModelUnloading
The ModelUnloading event is raised just before the model is unloaded.
Public event Numbering
The Numbering event is raised just after a model has been numbered.
Public event SelectionChange
The SelectionChange event is raised when the user changes the current selection inside Tekla Structures.
Public event TeklaStructuresExit
The TeklaStructuresExit event is raised just before Tekla Structures exits. After this event has been called the user will no longer be able to perform any calls to Tekla Structures.
Top
Remarks
Asynchronous event handling

Registered event handlers are called asynchronously so that many handlers may be running simultaneously. Event handlers are not guaranteed to be run in the same thread where they were registered. The asynchronous nature of the events requires the use of synchronization constructs on objects and data structures that are not defined to be thread safe.

  • Microsoft's documentation about the lock statement: http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx
  • Microsoft's documentation about delegates: http://msdn.microsoft.com/en-us/library/900fyy8e.aspx
  • Microsoft's documentation about managed threading: http://msdn.microsoft.com/en-us/library/1c9txz50.aspx
Examples
The following example shows how to make sure that only one selection event handler is running at a time.
 using Tekla.Structures.Model;

 public class Example
 {
     private Tekla.Structures.Model.Events _events = new Tekla.Structures.Model.Events();
     private object _selectionEventHandlerLock = new object();
     private object _changedObjectHandlerLock = new object();

     public void RegisterEventHandler()
     {
         _events.SelectionChange += Events_SelectionChangeEvent;
         _events.ModelObjectChanged += Events_ModelObjectChangedEvent;
         _events.Register();
     }

     public void UnRegisterEventHandler()
     {
         _events.UnRegister();
     }

     void Events_SelectionChangeEvent()
     {
         /* Make sure that the inner code block is running synchronously */
         lock(_selectionEventHandlerLock)
         {
             System.Console.WriteLine("Selection changed event received.");
         }
     }

     void Events_ModelObjectChangedEvent(List<ChangeData> changes)
     {
         /* Make sure that the inner code block is running synchronously */
         lock (_changedObjectHandlerLock)
         {
             foreach(ChangeData data in changes)
                 System.Console.WriteLine("Changed event received " + ":" + data.Object.ToString() + ":" + " Type" + ":" + data.Type.ToString() + " guid: " + data.Object.Identifier.GUID.ToString());
             System.Console.WriteLine("Changed event received for " + changes.Count.ToString() + " objects");
         }
     }
}
See Also