Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations The Obturator on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

export JPG with command line - NX journal

Status
Not open for further replies.

duonghoang

Automotive
Dec 23, 2013
4
Dear all,

I am trying to export the JPG from my part with different views with a journal using commandline "run_journal.exe". I follow this post and have my journal (as below) successfully run with NX UI open. However, when I try to run it from the commandline, it does not work anymore since there is no rendering window to create image. Anyone has idea how to resolve it?

Many thanks!

Duong

Code:
Option Strict Off
Imports System  
Imports NXOpen  
Imports NXOpen.UF

Module NXJournal
Sub Main (ByVal args() As String) 

Dim theSession As Session = Session.GetSession()
Dim theUI As UI = UI.GetUI()
theSession.ListingWindow.Open
' ----------------------------------------------
'   Menu: File->Open...
' ----------------------------------------------
Dim basePart1 As BasePart
Dim partLoadStatus1 As PartLoadStatus
basePart1 = theSession.Parts.OpenBaseDisplay("D:\personal\hoangd\Desktop\SDCTWQ0173_C38080808080808034A7\TankOnlyForNXtest.prt", partLoadStatus1)
theSession.ListingWindow.WriteLine("File opened sucessfully.")

Dim workPart As Part = theSession.Parts.Work

Dim displayPart As Part = theSession.Parts.Display

partLoadStatus1.Dispose()
' ----------------------------------------------
'   Menu: View->Operation->Rotate...
' ----------------------------------------------
Dim matrix1 As Matrix3x3
matrix1.Xx = 0.707106781186548
matrix1.Xy = 0.707106781186548
matrix1.Xz = 0.0
matrix1.Yx = -0.408248290463863
matrix1.Yy = 0.408248290463863
matrix1.Yz = 0.816496580927726
matrix1.Zx = 0.577350269189626
matrix1.Zy = -0.577350269189626
matrix1.Zz = 0.577350269189626
workPart.ModelingViews.WorkView.Orient(matrix1)
workPart.ModelingViews.WorkView.Fit()
' ----------------------------------------------
'   Export images...
' ----------------------------------------------
Dim ufs As UFSession = UFSession.GetUFSession()  
Dim background_color As UFDisp.BackgroundColor = UFDisp.BackgroundColor.white
displayPart.WCS.Visibility = True
ufs.Disp.CreateImage("D:\personal\hoangd\Desktop\SDCTWQ0173_C38080808080808034A7\isometric.jpg", UFDisp.ImageFormat.Jpeg, background_color)  
' ----------------------------------------------
'   Menu: View->Operation->Rotate...
' ----------------------------------------------
Dim matrix2 As Matrix3x3
matrix2.Xx = 1.0
matrix2.Xy = 0.0
matrix2.Xz = 0.0
matrix2.Yx = 0.0
matrix2.Yy = 1.0
matrix2.Yz = 0.0
matrix2.Zx = 0.0
matrix2.Zy = 0.0
matrix2.Zz = 1.0
workPart.ModelingViews.WorkView.Orient(matrix2)
workPart.ModelingViews.WorkView.Fit()
' ----------------------------------------------
'   Export images...
' ----------------------------------------------
ufs.Disp.CreateImage("D:\personal\hoangd\Desktop\SDCTWQ0173_C38080808080808034A7\top.jpg", UFDisp.ImageFormat.Jpeg, background_color)  
' ----------------------------------------------
'   Menu: View->Operation->Rotate...
' ----------------------------------------------
Dim matrix3 As Matrix3x3
matrix3.Xx = 1.0
matrix3.Xy = 0.0
matrix3.Xz = 0.0
matrix3.Yx = -0.0
matrix3.Yy = 0.0
matrix3.Yz = 1.0
matrix3.Zx = 0.0
matrix3.Zy = -1.0
matrix3.Zz = 0.0
workPart.ModelingViews.WorkView.Orient(matrix3)
workPart.ModelingViews.WorkView.Fit()
' ----------------------------------------------
'   Export images...
' ----------------------------------------------
ufs.Disp.CreateImage("D:\personal\hoangd\Desktop\SDCTWQ0173_C38080808080808034A7\front.jpg", UFDisp.ImageFormat.Jpeg, background_color)  
' ----------------------------------------------
'   Menu: View->Operation->Rotate...
' ----------------------------------------------
Dim matrix4 As Matrix3x3
matrix4.Xx = 0.0
matrix4.Xy = -1.0
matrix4.Xz = 0.0
matrix4.Yx = 0.0
matrix4.Yy = 0.0
matrix4.Yz = 1.0
matrix4.Zx = -1.0
matrix4.Zy = 0.0
matrix4.Zz = 0.0
workPart.ModelingViews.WorkView.Orient(matrix4)
workPart.ModelingViews.WorkView.Fit()
' ----------------------------------------------
'   Export images...
' ----------------------------------------------
ufs.Disp.CreateImage("D:\personal\hoangd\Desktop\SDCTWQ0173_C38080808080808034A7\side.jpg", UFDisp.ImageFormat.Jpeg, background_color)  
' ----------------------------------------------
'   Menu: File->Close->All Parts
' ----------------------------------------------
theSession.Parts.CloseAll(BasePart.CloseModified.CloseModified, Nothing)

workPart = Nothing
displayPart = Nothing

End Sub
End Module
 
Replies continue below

Recommended for you

I don't think it is possible to export a 'screenshot' graphic file from NX if there is no visible display. Perhaps it would be possible to export a rendering from NX when it is running in batch mode, but I have not tried it yet.

www.nxjournaling.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor