NX Journal Jpg Exports / Graphics Window Question
NX Journal Jpg Exports / Graphics Window Question
(OP)
Over the last few days I've been looking into how to export framed images of the graphics windows to jpeg files through NX journaling in NX 7.5. The 'CreateFramedImage' method allows for the export of a rectangular window of the graphics window. Additionally, the function allows for you to specify this rectangular box in pixels. Unfortunately, I can see no way of identifying the pixel size (width x height) of the NX graphics window from within the journal or in the NX menus either. My ultimate goal is to export an image of the entire model (solid bodies) that is as small as possible while still containing all of the model within the image. Any help at all will be appreciated.





RE: NX Journal Jpg Exports / Graphics Window Question
CODE --> vb
' NX 7.5.5.4 'http://www.eng-tips.com/viewthread.cfm?qid=327914&tmac=fav&val=1,327914 Option Strict Off Imports System Imports System.IO Imports System.Windows.Forms Imports NXOpen Imports NXOpen.UF Imports NXOpen.Assemblies Imports NXOpen.Utilities Imports NXOpen.Layer Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim ufs As UFSession = UFSession.GetUFSession() Dim workPart As Part = theSession.Parts.Work Dim background_color As UFDisp.BackgroundColor = UFDisp.BackgroundColor.original Dim DisplayPart As Part = theSession.Parts.display Dim partName As String = Path.GetFileNameWithoutExtension(workPart.FullPath) 'turn triad off theSession.Preferences.ScreenVisualization.TriadVisibility = 0 'turn WCS off DisplayPart.WCS.Visibility = False Dim folderName As String = "C:" Dim strPartJpg As String = "" Dim strCurrentDate As String = Format(Today, "dd.MM.y") Dim s As Session = Session.GetSession() Dim ui As UI = UI.GetUI() Dim lw As ListingWindow = s.ListingWindow Dim root As Component = s.Parts.Work.ComponentAssembly.RootComponent Dim folderBrowserDialog1 As New FolderBrowserDialog With folderBrowserDialog1 .Description = "Specify folder for screenshot output" .ShowNewFolderButton = False .RootFolder = Environment.SpecialFolder.Desktop 'use folderName as default directory .SelectedPath = folderName End With Dim result As DialogResult = folderBrowserDialog1.ShowDialog() If (result = DialogResult.OK) Then folderName = folderBrowserDialog1.SelectedPath Else 'user pressed cancel, exit the journal Exit Sub End If If Not Directory.Exists(folderName) Then MsgBox("The specified directory does not exist, journal will now exit", MsgBoxStyle.Exclamation, folderName & " not found") Exit Sub End If Dim partLoadStatus2 As PartLoadStatus Dim status1 As PartCollection.SdpsStatus status1 = theSession.Parts.SetDisplay(displaypart, False, True, partLoadStatus2) 'workPart = theSession.Parts.Work 'displayPart = theSession.Parts.Display partLoadStatus2.Dispose() strPartJpg = Path.GetFileNameWithoutExtension(workPart.FullPath) & "_" & strCurrentDate & ".jpg" strPartJpg = Path.Combine(folderName, strPartJpg) ufs.Disp.CreateImage(strPartJpg, UFDisp.ImageFormat.Jpeg, background_color) 'turn triad on theSession.Preferences.ScreenVisualization.TriadVisibility = 1 'turn WCS off DisplayPart.WCS.Visibility = true End Sub Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image when the NX session terminates GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination End Function End ModuleRE: NX Journal Jpg Exports / Graphics Window Question
I appreciate your quick feedback. However, I am able to export the entire graphics window without any issues. My main issue still remains to be specifying a rectangular box within the graphics window that will be exported. Additionally, I still have no way of identifying the window size in pixels from within the journal.
RE: NX Journal Jpg Exports / Graphics Window Question
Option Strict Off
Imports System
Imports System.IO
Imports System.Text
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Assemblies
Imports System.Xml
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim pixel_x As Integer
Dim pixel_y As Integer
theSession.Preferences.HighQualityImageVisualization.GetImageSize(size_dummy, pixel_x, pixel_y)
End Sub
Where pixel_x and pixel_y contain the number of pixels of the graphics window. However, an issue arises when the nx window is resized without executing an action that redetermines the graphics window size. This can easily be achieved by the following lines (renders the current viewing window):
workPart.ModelingViews.WorkView.HiqhQualityImage.Generate()
workPart.ModelingViews.WorkView.HiqhQualityImage.Erase()
RE: NX Journal Jpg Exports / Graphics Window Question
www.nxjournaling.com