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: 2023.0.3
Syntax
[SerializableAttribute]
public sealed class Events : MarshalByRefObject

The Events type exposes the following members.

Constructors
  NameDescription
Public methodEvents
Creates an empty events instance.
Top
Methods
  NameDescription
Public methodInitializeLifetimeService
Initializes the lifetime service.
(Overrides MarshalByRefObjectInitializeLifetimeService.)
Public methodOnInterrupted
Called when uesr interrupts.
Public methodOnModelSaveInfo
Called when model is saved.
Public methodRegister
Registers the instance to listen to the specified events. More event delegates should not be added without calling UnRegister first.
Public methodUnRegister
Unregisters the instance from listening to events.
Top
Events
  NameDescription
Public eventClashCheckDone
The ClashCheckDone event is raised just after clash check is completed.
Public eventClashDetected
The ClashDetected event is raised just after the detection of each clash. The clash information is saved before the event is triggered.
Public eventCommandStatusChange
The CommandStatusChange event is raised when a command is started/ended.
Public eventInterrupted
Occurs when user interrupts.
Public eventModelChanged 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 eventModelLoad
The ModelLoad event is raised just after a model has been loaded.
Public eventModelLoadInfo
The ModelLoadInfo event is raised just after a model has been loaded with the model load information as a string parameter.
Public eventModelObjectChanged
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 eventModelObjectNumbered
The ModelObjectNumbered event is raised when model object is numbered.
Public eventModelSave
The ModelSave event is raised just after a model has been saved.
Public eventModelSaveAs
The ModelSaveAs event is raised just after a model has been saved using save as.
Public eventModelSaveInfo
The ModelSave event is raised just after a model has been saved with the model save information as a string parameter.
Public eventModelUnloading
The ModelUnloading event is raised just before the model is unloaded.
Public eventNumbering
The Numbering event is raised just after a model has been numbered.
Public eventProjectInfoChanged
The ProjectInfoChanged event is raised just after some changes have been made to the project info.

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

Public eventSelectionChange
The SelectionChange event is raised when the user changes the current selection inside Tekla Structures.
Public eventTeklaStructuresExit
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.
Public eventViewCameraChanged
Occurs when view camera is changed.
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
Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.
Previous
Next