Submitted by DhanyZdeb on Fri, 07/26/2013 - 05:55
Forums:
Hi guys,
I am quite new to NX jurnaling and I strugle with (probably) an easy task. I would like to export an image of a displayed part to jpg file. I found method NXOpen.ModelingViewHighQualityImage.Save(Image file, compressImage) which I think should do it. However, I do not know how to use it. Does anyone have a simple example of using it? Thanks.
re: export jpg
Have a look at the CreateImage function.
Here is a quick journal to get you started. It outputs each of the saved views to a jpeg in the specified directory.
Option Strict Off
Imports System
Imports System.IO
Imports NXOpen
Imports NXOpen.UF
Module Module1
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim partName As String = Path.GetFileNameWithoutExtension(workPart.FullPath)
'directory to output jpegs, change as needed
Dim outputDirectory As String = "C:\temp"
Dim strPartJpg As String = ""
If Not Directory.Exists(outputDirectory) Then
MsgBox("The specified directory does not exist, journal will now exit", MsgBoxStyle.Exclamation, outputDirectory & " not found")
Exit Sub
End If
Dim wpModelingView As ModelingView
For Each wpModelingView In workPart.ModelingViews
workPart.Views.WorkView.Orient(wpModelingView.Name, View.ScaleAdjustment.Fit)
strPartJpg = partName & "_" & wpModelingView.Name & ".jpg"
strPartJpg = Path.Combine(outputDirectory, strPartJpg)
ufs.Disp.CreateImage(strPartJpg, UFDisp.ImageFormat.Jpeg, UFDisp.BackgroundColor.White)
Next
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 Module
Hi..
Hi..
This code is providing all the views in a model.
How can I get selected views only?
Parthasarathi Nayak
re: screenshot view
If you always want to use the same views, you could hardcode them into your journal. Otherwise, you could look at the preselected objects and use any views you find and/or prompt the user to select the desired views.
And what if I want those
And what if I want those images in an excel template?
Parthasarathi Nayak
re: screenshot view
http://nxjournaling.com/content/export-assembly-excel-pictures-0
The link above contains some code that exports screenshots to an excel sheet. It might give you a good starting point for your own code.
Thanks mate, its exactly what
Thanks mate, its exactly what I have needed.
Daniel Zdebski
Rolls-Royce
only the displayed bodies
What is the code for choosing only the displayed bodies?
re: displayed bodies
See answer here:
http://nxjournaling.com/comment/3577#comment-3577