NX How to have the post create a secondary text file of information

2019-05-15T15:35:56Z
NX for Manufacturing

Summary


Details

It may be nice to have the post create a secondary text file of information during post processing to record certain values during that run (ie. the name of the post used, the programmer doing the posting, etc).  This text file can be read/used later in other processes, such as shop docs, to populate a report with these details that otherwise would be unknown after the post processing completes.


How to make the post write out this extra file?



Solution

Writing a text file is a basic tcl function.  All that is required is a custom command with the proper logic and commands in it to collect the desired mom variable values and write them out to a file. 


A sample procedure is below.  This custom command creates the text file as an additional output.  The normal ptp code file is created in its normal location so the basic function of the post remains intact.  This is not limited to writing mom variables.  The 'puts' commands can be used to write anything, including literal text lines, just like the MOM_output_literal command in postbuilder. 


#============================================================= 
proc PB_CMD_write_file { } { 
#=============================================================


# Procedure to write a separate text file during post processing 
# import this custom command and place it in any event handler 
# where the desired variables have been defined and given values. 
# This sample writes out the name of the post being used and the 
# current user login from mom variable values.


global text_file_name 
global mom_event_handler_file_name 
global mom_logname


# Define the location and name of the output text file. Note 
# that this is a hard coded value for a specific name and folder. 
# This should be either customized or assembled with variables 
# to suit the need. Reference the proc "Open_Files" in the 
# OOTB file MACH\resource\shop_doc\shopdoc_header.tcl for one 
# way to handle this.


set text_file_name "D:\\test\\varb_file.txt"


# Look for any previous copy of this text file. If it exists, 
# delete it so this run of the post can create a fresh output file.


if {[file exists $text_file_name]} { 
 MOM_remove_file $text_file_name 
 }


# Open the channel to the text file, write the variable 
# values, and then close the channel to finalize the file.


set mychannel [open $text_file_name a] 
puts $mychannel "post in use: $mom_event_handler_file_name" 
puts $mychannel "programmer: $mom_logname" 
close $mychannel


}



Notes and References


Hardware/Software Configuration

Platform: all
OS: n/a
OS Version: n/a
Product: NX
Application: CAM
Version: V10.0.3
Function: POSTBUILDER

Ref: 001-7924412

KB Article ID# PL8010844

Contents

SummaryDetails

Associated Components

Manufacturing Post Builder