Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

PDF Journal VB Script Problems

Status
Not open for further replies.

Hannah4Evr

Automotive
Jun 27, 2012
9
0
0
US
Hello,

I'm having an issue in modifying the export PDF journal a buddy of mine found on here, and I'm running into some issues. What I'm trying to do is add a save function into it, so that after it updates the views and exports the PDF, it saves the assembly.

I attached the file.

Basically, it does what I want it to already, but I don't want to have to use SendKeys to save. Does anyone here know how to save directly? What is the function?

Any help would be greatly appreciated!


 
Replies continue below

Recommended for you

The journal recorder is a great tool to generate some code to work with. The output of the journal recorder for a save operation looks like:

Code:
Dim partSaveStatus1 As PartSaveStatus
partSaveStatus1 = workPart.Save(BasePart.SaveComponents.True, BasePart.CloseAfterSave.False)
partSaveStatus1.Dispose()

These lines of code will save the work part along with any components that you have write access to, and it will leave the file open after the save operation. You can change these options by modifying the True/False values as necessary.

www.nxjournaling.com
 
Thank you sir! I actually did try that, but it wasn't seeming to work. I'm not exactly a pro on VBA, so that is probably why.

Thanks for your help!
 
Ok, I have done another rev on the file, and would like to add a Checkmate function directly into the journal. I recorded a journal while Checkmating, copied it to the PDF Export Journal, and replaced my save function with the Checkmate function. However, in line 135 it defines the file that it checkmates, under validators1. Can I not just replace the path that is there, and replace it with "currentFile"? It is already defined elsewhere in the journal.

The problem is, it's not working. What am I doing wrong?

Any help would be awesome!!
 
 http://files.engineering.com/getfile.aspx?folder=4fca3665-6989-4e61-a1a5-c40301fff8e1&file=pdfcmsave_0.0.1a_beta.vb
I replaced currentFile with workPart.FullPath and it still doesn't seem to be working. It does the same as before - flashes "Checking Complete" on the info bar, but doesn't actually checkmate.

Code:
' NX 7.5.4.4
' Journal created by kevin.wegner on Thu Jun 28 08:47:01 2012 Eastern Daylight Time
'
Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work

Dim displayPart As Part = theSession.Parts.Display

Dim validators1() As Validate.Validator
theSession.ValidationManager.FindValidator("Check-Mate", validators1)

validators1(0).ClearPartNodes()

Dim validators2() As Validate.Validator
theSession.ValidationManager.FindValidator("Check-Mate", validators2)

        validators1(0).AppendPartNode("workPart.FullPath.")

Dim validators3() As Validate.Validator
theSession.ValidationManager.FindValidator("Check-Mate", validators3)

Dim validatorOptions1 As Validate.ValidatorOptions
validatorOptions1 = validators1(0).ValidatorOptions

Dim validators4() As Validate.Validator
theSession.ValidationManager.FindValidator("Check-Mate", validators4)

Dim status1 As Validation.Result
status1 = validators1(0).Commit()

Dim parsers1() As Validate.Parser
theSession.ValidationManager.FindParser("Validation Gadget", parsers1)

parsers1(0).ClearResultObjects()

parsers1(0).DataSource = Validate.Parser.DataSourceTypes.MostRecentRun

parsers1(0).MaxDisplayObjects = 25

Dim parsers2() As Validate.Parser
theSession.ValidationManager.FindParser("Validation Gadget", parsers2)

parsers1(0).Commit()


End Sub
End Module
 
I tried that, and on MS Visual Studio it no longer highlights workPart.FullPath. I run it, and it does the same thing. It doesn't checkmate.
 
Status
Not open for further replies.
Back
Top