×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

export JPG with command line - NX journal

export JPG with command line - NX journal

export JPG with command line - NX journal

(OP)
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 http://www.eng-tips.com/viewthread.cfm?qid=335979#... 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 

RE: export JPG with command line - NX journal

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources