Export Image Macro
Export Image Macro
(OP)
I would like a macro that exports an image(jpeg or bitmap), and saves it as the file name on a folder on my desktop in the C: drive.
I am clueless on where I would start to do this and an im need of assistance.
I am clueless on where I would start to do this and an im need of assistance.





RE: Export Image Macro
thread561-327914: NX6 jpeg default directory
www.nxjournaling.com
RE: Export Image Macro
RE: Export Image Macro
I attepted to make a version of the jpeg macro with an output directory that could be chosen every time. If you click cancel it uses the last directory.
Or better yet, is there a way to go up a level in the folder path from where the root part it, and then back down a level to a named folder?
Here is what I have so far, the line below is giving me the issue.
ufs.Disp.CreateImage(strPartJpg, UFDisp.ImageFormat.Jpeg, UFDisp.BackgroundColor.original)
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 partName As String = Path.GetFileNameWithoutExtension(workPart.FullPath) 'turn triad off theSession.Preferences.ScreenVisualization.TriadVisibility = 0 'directory to output jpegs, change as needed 'Change the directory to where you would like the picture for now 'the next update will feature automatic storing into Vantage folders for that job Dim folderName As String = "C:" Dim outputDirectory As String = folderName Dim strPartJpg As String = "" Dim wpModelingView As ModelingView Dim strCurrentDate as String 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 folderBrowserDialog1.ShowNewFolderButton = False Dim result As DialogResult = folderBrowserDialog1.ShowDialog() If (result = DialogResult.OK) Then folderName = folderBrowserDialog1.SelectedPath End If 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 strCurrentDate = format(Today, "dd.MM.y") strPartJpg = Path.GetFileNameWithoutExtension(workPart.FullPath) & "_" & strCurrentDate & ".jpg" strPartJpg = Path.Combine(outputDirectory, strPartJpg) ufs.Disp.CreateImage(strPartJpg, UFDisp.ImageFormat.Jpeg, UFDisp.BackgroundColor.original) 'turn triad on theSession.Preferences.ScreenVisualization.TriadVisibility = 1 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: Export Image Macro
The following code fixes that and uses the work part's parent folder as the default directory choice in the folder browser.
CODE
www.nxjournaling.com
RE: Export Image Macro
Take out as PDF and JPEG images, to a specific folder.
RE: Export Image Macro
RE: Export Image Macro
CODE
www.nxjournaling.com