admin@creocustomization.com

Get the Creo Window Information using VB API

Get the Creo Window Information using VB API

Creo VB API allows the user to get windows information such as window id, dimensions, location, graphics area dimensions, etc. To get these information follow these steps.

Declare the required variables

Declare the required variables

Public AConnection As IpfcAsyncConnection
Public BSession As IpfcBaseSession

Get the current session

Here the Aconnection is the variable declared at the time of Creo Connection or Creo Start function.

Get the current session

BSession = AConnection.Session

Get the current window

I’ve used the currently active window here. User can get any window using the window id

Get the Current Window

Dim SWindow As IpfcWindow = BSession.CurrentWindow

Get the window ID

SWindow.GetId

Get the window dimension

SWindow.Height
SWindow.Width

Get the graphics area dimension

SWindow.GraphicsAreaHeight
SWindow.GraphicsAreaWidth

Difference between window and graphic area dimension

Get window position

SWindow.XPos
SWindow.YPos

Here the consolidated code to get the window information & applyt o the predefined WPF Label

Get Window Informaiton

Try
'AConnection should be already connected in Creo Start or Creo Connect 
	
    BSession = AConnection.Session
    Dim SWindow As IpfcWindow = BSession.CurrentWindow
	
'APPLYING THE WINDOWS INFORMATION TO THE WPF LABELS
	
    lb_WinID.Content = "ID : " & SWindow.GetId.ToString
    lb_WinGraphHeight.Content = "GRAPHICS HEIGHT : " & SWindow.GraphicsAreaHeight.ToString
    lb_WinGraphWidth.Content = "GRAPHICS WIDTH : " & SWindow.GraphicsAreaWidth.ToString
    lb_WinXPos.Content = "X POSITION : " & SWindow.XPos.ToString
    lb_WinYPost.Content = "Y POSITION : " & SWindow.YPos.ToString
    lb_WinHeight.Content = "HEIGHT : " & SWindow.Height.ToString    
    lb_WinWidth.Content = "WIDTH : " & SWindow.Width.ToString
Catch ex As Exception
    MessageBox.Show(ex.ToString, "Failure")
End Try

Leave a Reply

Contact Us