Trouble intercepting OnCreateInPlacePartUI in VB

Solution Partner Experimenter Solution Partner Experimenter
Solution Partner Experimenter

Does anyone have any experience with intercepting the OnCreateInPlacePartUI event from Solid Edge?

 

I am not able to get the event to fire in my VB app,

It uses:

Imports SolidEdgeFramework

 

The Class has:

Dim WithEvents seDocEvents As SolidEdgeFramework.DISEFileUIEvents_Event

 

And the function is:

Function B4CIP(ByRef Filename As String, ByRef AppendtoTitle As String, ByRef Template As String) Handles seDocEvents.OnCreateInPlacePartUI

 

'Other code here---

End Function

 

Any ideas?

1 REPLY

Re: Trouble intercepting OnCreateInPlacePartUI in VB

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Hi Tom,

Below is the code to hookup "ISEFileUIEvents".

Just create a Form based application in VS, add references and paste below code.

After that you should be able to hookup to "OnCreateInPlacePartUI" when "Create Part In-Place" command is fired from SE.

 

 

 

Option Infer On

Imports System
Imports System.Runtime.InteropServices
Imports System.Runtime.InteropServices.ComTypes
Imports System.Windows.Forms

Public Class Form1
    Inherits Form
    Implements SolidEdgeFramework.ISEFileUIEvents

    Private _application As SolidEdgeFramework.Application
    Private _connectionPoint As IConnectionPoint
    Private _cookie As Integer

    Public Sub New()
        InitializeComponent()
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try

            ' Connect to Solid Edge.
            _application = DirectCast(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)
            ConnectEvents()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs)
        DisconnectEvents()
    End Sub

    Private Sub ConnectEvents()
        ' Get the event GUID.
        Dim typeGuid = GetType(SolidEdgeFramework.ISEFileUIEvents).GUID

        ' Get a reference to the IConnectionPointContainer.
        Dim container As IConnectionPointContainer = DirectCast(_application, IConnectionPointContainer)

        ' Lookup the IConnectionPoint.
        container.FindConnectionPoint(typeGuid, _connectionPoint)

        ' Advise the sink.
        _connectionPoint.Advise(Me, _cookie)
    End Sub

    Private Sub DisconnectEvents()
        ' Unadvise the sink.
        _connectionPoint.Unadvise(_cookie)

        ' Clear variables.
        _cookie = 0
        _connectionPoint = Nothing
    End Sub


    Public Sub OnCreateInPlacePartUI(ByRef Filename As String, ByRef AppendToTitle As String, ByRef Template As String) Implements SolidEdgeFramework.ISEFileUIEvents.OnCreateInPlacePartUI

    End Sub

    Public Sub OnFileNewUI(ByRef Filename As String, ByRef AppendToTitle As String) Implements SolidEdgeFramework.ISEFileUIEvents.OnFileNewUI

    End Sub

    Public Sub OnFileOpenUI(ByRef Filename As String, ByRef AppendToTitle As String) Implements SolidEdgeFramework.ISEFileUIEvents.OnFileOpenUI

    End Sub

    Public Sub OnFileSaveAsImageUI(ByRef Filename As String, ByRef AppendToTitle As String, ByRef Width As Integer, ByRef Height As Integer, ByRef ImageQuality As SolidEdgeFramework.SeImageQualityType) Implements SolidEdgeFramework.ISEFileUIEvents.OnFileSaveAsImageUI

    End Sub

    Public Sub OnFileSaveAsUI(ByRef Filename As String, ByRef AppendToTitle As String) Implements SolidEdgeFramework.ISEFileUIEvents.OnFileSaveAsUI

    End Sub

    Public Sub OnPlacePartUI(ByRef Filename As String, ByRef AppendToTitle As String) Implements SolidEdgeFramework.ISEFileUIEvents.OnPlacePartUI

    End Sub
End Class