Imports System
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Namespace Examples
Partial Public Class Form1
Inherits Form
Private _application As SolidEdgeFramework.Application
Private _window As SolidEdgeFramework.Window
Private _view As SolidEdgeFramework.View
Private _animationEvents As SolidEdgeFramework.ISEAnimationEvents_Event
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
' Connect to a running instance of Solid Edge.
_application = DirectCast(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)
' A 3D document must be open.
_window = CType(_application.ActiveWindow, SolidEdgeFramework.Window)
_view = _window.View
' Connect to events using delegate event model.
_animationEvents = CType(_view.AnimationEvents, SolidEdgeFramework.ISEAnimationEvents_Event)
' Attach to specific events.
AddHandler _animationEvents.AnimationEvent, AddressOf _animationEvents_AnimationEvent
End Sub
Private Sub _animationEvents_AnimationEvent(ByVal AnimationEventType As SolidEdgeFramework.AnimationEventConstants, ByVal nFrame As Integer)
' Handle AnimationEvent.
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs)
If _animationEvents IsNot Nothing Then
' Dettach from specific events.
RemoveHandler _animationEvents.AnimationEvent, AddressOf _animationEvents_AnimationEvent
End If
_animationEvents = Nothing
_application = Nothing
End Sub
End Class
End Namespace
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Examples
{
public partial class Form1 : Form
{
private SolidEdgeFramework.Application _application;
private SolidEdgeFramework.Window _window;
private SolidEdgeFramework.View _view;
private SolidEdgeFramework.ISEAnimationEvents_Event _animationEvents;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// Connect to a running instance of Solid Edge.
_application = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");
// A 3D document must be open.
_window = (SolidEdgeFramework.Window)_application.ActiveWindow;
_view = _window.View;
// Connect to events using delegate event model.
_animationEvents = (SolidEdgeFramework.ISEAnimationEvents_Event)_view.AnimationEvents;
// Attach to specific events.
_animationEvents.AnimationEvent += _animationEvents_AnimationEvent;
}
private void _animationEvents_AnimationEvent(SolidEdgeFramework.AnimationEventConstants AnimationEventType, int nFrame)
{
// Handle AnimationEvent.
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (_animationEvents != null)
{
// Dettach from specific events.
_animationEvents.AnimationEvent -= _animationEvents_AnimationEvent;
}
_animationEvents = null;
_application = null;
}
}
}