Basic window Operations in Creo VB API

Creo VB API provides functions to control Creo windows. Here I’m gonna show how to do the basic window operation such as clear window, close window, refresh window and repaint window.

Activate Window

To activate the window we can use Activate() function from Ipfcwindow class in VB API. This method only works in asynchronous graphics mode. It will throw IpfcXToolkitBadContext exception if called in the non-graphic mode. Since it also very basic operation in window control I’m just giving the intro of this. For detailed explanation of how to activate a specific window see the article How to list out and activate a specific window.

Clear Window

To clear everything in the required window we can use clear() function from Ipfcwindow class in  VB API. Here the sample code to clear the Current window

Clear the Current Window using VB API
' VARIABLE DECLARATION REQUIRED
	
Public AConnection As IpfcAsyncConnection
Public BSession As IpfcBaseSession

Try

' AConnection must be declared at the time of Creo Connect or Creo Start function

    BSession = AConnection.Session
    Dim SWinows As IpfcWindow = BSession.CurrentWindow
    SWinows.Clear()
Catch ex As Exception
    MessageBox.Show(ex.ToString, "FAILURE")
End Try

Repaint Window

To repaint the required window we can use Repaint() function from Ipfcwindow class in VB API. This is especially used to updated the views in Creo window

Repaint the Current Window using VB API
' VARIABLE DECLARATION REQUIRED

Public AConnection As IpfcAsyncConnection
Public BSession As IpfcBaseSession

 Try

 ' AConnection must be declared at the time of Creo Connect or Creo Start function
 
    BSession = AConnection.Session
    Dim SWindow As IpfcWindow = BSession.CurrentWindow
    SWindow.Repaint()
Catch ex As Exception
    MessageBox.Show(ex.ToString, "Failure")
End Try

Refresh Window

To refresh the window content we can use Refresh() function from  Ipfcwindow class in VB API

Refresh Window in Creo using VB API

' VARIABLE DECLARATION REQUIRED

Public AConnection As IpfcAsyncConnection
Public BSession As IpfcBaseSession

Try
 ' AConnection must be declared at the time of Creo Connect or Creo Start function
 
    BSession = AConnection.Session
    Dim SWindow As IpfcWindow = BSession.CurrentWindow
    SWindow.Refresh()
Catch ex As Exception
    MessageBox.Show(ex.ToString, "Failure")
End Try

Close Window

To remove a window from the Creo screen we can user Close() function from Ipfcwindow class. If it is the base window then Creo clears everything in the base window 

Caution: Any work done since the last save will be lost

Close Creo Window using VB API
' VARIABLE DECLARATION REQUIRED

Public AConnection As IpfcAsyncConnection
Public BSession As IpfcBaseSession

 Try
  ' AConnection must be declared at the time of Creo Connect or Creo Start function
  
    BSession = AConnection.Session
    Dim SWindow As IpfcWindow = BSession.CurrentWindow
    SWindow.Close()
Catch ex As Exception
    MessageBox.Show(ex.ToString, "Failure")
End Try

Hope I covered all the basic window operations. 

Thanks & Regards

Parthiban Kannan

Follow me in LinkedIn

 

Share Now
  • 1
  •  
  •  
  •  
  •  
  •  
    1
    Share

Leave a Reply