NX Extracting some of the Text in the Part File Name to use as the Program Name in Post Builder

2021-10-06T23:27:37Z
NX for Manufacturing

Summary


Details

What TCL code can be used to extract the first characters of the part file name and then output that text as the program name when posting an NC file? For example, the name of a manufacturing part file is 2534_6541_MILL_005.prt. The program name for the G-code output would be the character O followed by the characters before the first underscore. In this case, the name would be O2534.



Solution

The code below can be used to read the part file name and then output the text before the first underscore character (_). Additionally, code was added to the procedure to display a message if there is no underscore in the file name, as seen at the bottom of this article.


global mom_output_file_basename
set tmp [expr [string first "_" $mom_output_file_basename]-1]
if { $tmp > 0 } {
MOM_output_text "O[string range $mom_output_file_basename 0 $tmp]"
} else {
set txt1 "File Name Needs an \"_\" Character"
set txt2 "Warning: Header Line Not Output"
set response [MOM_display_message $txt1 $txt2 E OK]
}



Notes and References

Please be aware that any code provided by GTAC is intended to be used for sample purposes only. It is the user's responsibility to determine whether the code is suitable for the purpose.

Hardware/Software Configuration

Platform: all
OS: n/a
OS Version: n/a
Product: NX
Application: CAM
Version: V1938
Function: POSTBUILDER

Ref: 001-9730522

KB Article ID# PL8018012

Contents

SummaryDetails

Associated Components

Manufacturing Post Builder