Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Sub Main()
If IsNothing(theSession.Parts.BaseWork) Then
'active part required
Return
End If
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
'change export location as needed
ExportScreenshot("C:\Temp\NX_screenshot.png")
lw.Close()
End Sub
Sub ExportScreenshot(ByVal filename As String)
Dim wcsVisible As Boolean = theSession.Parts.Display.WCS.Visibility
Dim triadVisible As Integer = theSession.Preferences.ScreenVisualization.TriadVisibility
Try
DeleteFile(filename)
theSession.Parts.Display.WCS.Visibility = False
theSession.Preferences.ScreenVisualization.TriadVisibility = 0
theUfSession.Disp.CreateImage(filename, UFDisp.ImageFormat.Png, UFDisp.BackgroundColor.White)
Catch ex As Exception
MsgBox(ex.Message & ControlChars.NewLine & _
"'" & filename & "' could not be created")
'Return
Finally
theSession.Parts.Display.WCS.Visibility = wcsVisible
theSession.Preferences.ScreenVisualization.TriadVisibility = triadVisible
End Try
End Sub
Sub DeleteFile(ByVal filePath As String)
'does file exist? if so, try to delete it (overwrite)
If IO.File.Exists(filePath) Then
IO.File.Delete(filePath)
End If
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module
Option Strict Off
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Sub Main()
If IsNothing(theSession.Parts.BaseWork) Then
'active part required
Return
End If
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
'change export location as needed
ExportScreenshot("C:\Temp\NX_screenshot.png")
lw.Close()
End Sub
Sub ExportScreenshot(ByVal filename As String)
Dim wcsVisible As Boolean = theSession.Parts.Display.WCS.Visibility
Dim triadVisible As Integer = theSession.Preferences.ScreenVisualization.TriadVisibility
Try
DeleteFile(filename)
theSession.Parts.Display.WCS.Visibility = False
theSession.Preferences.ScreenVisualization.TriadVisibility = 0
theUfSession.Disp.CreateImage(filename, UFDisp.ImageFormat.Png, UFDisp.BackgroundColor.White)
Catch ex As Exception
MsgBox(ex.Message & ControlChars.NewLine & _
"'" & filename & "' could not be created")
'Return
Finally
theSession.Parts.Display.WCS.Visibility = wcsVisible
theSession.Preferences.ScreenVisualization.TriadVisibility = triadVisible
End Try
'copy image to clipboard
Dim theImage As Bitmap = CType(Image.FromFile(filename), Bitmap)
Clipboard.SetImage(theImage)
End Sub
Sub DeleteFile(ByVal filePath As String)
'does file exist? if so, try to delete it (overwrite)
If IO.File.Exists(filePath) Then
IO.File.Delete(filePath)
End If
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module
zhengrong said:Is there any code for putting the screen shot image to clipboard?