Application of a UG CAM API: UF_SETUP_generate_program
Beck (BAI Tusi)
Email/MSN:begtostudy@gmail.com
Defined in: uf_setup.h
Overview
This function generates the NC program for all the operations contained in the specified group of the specified setup. It will use the Post (i.e., the Definition File and Event Handler) specified by 'post_name'. It will write the generated NC Program to a file with name 'output_filename'. If 'output_filename' exists the output will be appended to the existing file. If the behavior wanted is to overwrite the exsiting file, then the user has to delete the file before calling this function.
See the Note in the File Description regarding the relationship between the 'post_name' and the CAM resource files.
Environment
Internal and External
History
Originally released in V16.0
Required License(s)
cam_base
int UF_SETUP_generate_program
(
tag_t setup,
tag_t group,
const char * post_name,
const char * output_filename,
UF_SETUP_output_units_t output_units
)
setup | Input | - the setup object to process | |
group | Input | - the program group to process | |
const char * | post_name | Input | - the name (as found in a resource file) of the post instructions to use. This name specifies the Definition File and Event Handler file to use |
const char * | output_filename | Input | - the name of the file to write the output to |
output_units | Input | - the output units for the Post to use |
Before using this function, we must setup something as follows:
Firstly, we should find the folder from the NX setup folder as shown in Figure 1: \UGS\NX 6.0\MACH\resource\postprocessor
And then, copy three post-process files into this folder, as shown in Figure 3:
图 1
Open template_post.dat in Figure 1 by notepad (Figure 2).
Append a line in the file:
begtostudy,${UGII_CAM_POST_DIR}begtostudy.tcl,${UGII_CAM_POST_DIR}begtostudy.def
It specifies the name, tcl file and def file, divided by ‘;’ respectively.
${UGII_CAM_POST_DIR} is the special the folder, of course, you could use a full path name.
图 2
After restarted UG, it would display the configuration in the post-processor dialog (Figure 3).
图 3
At last, we could use the api, UF_SETUP_generate_program, in our program:
UF_CALL(UF_SETUP_generate_program(setup_tag,pro_tag/*Program group*/,”begtostudy”,filename/*output the NC file*/, UF_SETUP_OUTPUT_UNITS_INCH ));
Note: You must ensure you can generate nc file by hand in NX.
End.