Showing results for 
Search instead for 
Do you mean 
Reply

How can I automatically have a tool list at the header of the program when I post?

 

Actually I would like to see more than that.  I would like to have the post make the program header format like this:

 

File name:

Part Number:

Material:

Run Time:

Max/Min X:

Max/Min Y:

Max/Min Z:

Tool list:

**Part origin:

**Setup notes:

 

 

**The Setup notes and Part origin should be entered at a prompt when I post.

 

Thanks for any insight!

Daniel

 

 

 

 

 

 

5 REPLIES

Re: How can I automatically have a tool list at the header of the program when I post?

[ Edited ]

Looks like this is freshly posted.

 

If you run NX9.x & up, you could use the new MOM command to pre-process the entire program and collect data for later use.

 

MOM_run_postprocess
- Post process same object(s) selected from within a post
- Preview entire program before regular posting


Syntax:
  MOM_run_postprocess <event_handler> <definition> <output>

 

Example:

#=============================================================
proc PB_CMD_create_sub_program { } {
#=============================================================
set out_file "${::mom_output_file_directory}sub_program.ptp"

MOM_run_postprocess "[file dirname $::mom_event_handler_file_name]/MORI_HORI_Sub.tcl“ \
"[file dirname $::mom_event_handler_file_name]/MORI_HORI_Sub.def“ "$out_file"

# Make use of results
# Loop thru entire output file in case multiple lines have been produced.
set src [open "$out_file" RDONLY]
while { [eof $src] == 0 } {
set local_line [gets $src]

# Do whatever is necessary with the data
}
close $src
file delete "$out_file"
}

Notes:

  • For your application, you probably want to call this custom command @ the Start-of-Program event marker.
  • It's always recommended to use a different post than the one that calls this command to avoid complication.
  • The place you can collect the max/min info is probably @ the MOM_before_motion with some global variables.
  • For the tool list, you can build it in the sub-post, or use the existing scheme with PB_CMD_create_tool_list (+ other commands imported from pb_cmd_tool_list.tcl).

 

You can bring up a simple Tk dialog (again, from the Start-of-Program) to enter the Part Origin & Setup Notes.

 

 

Mar-15-2015

Attached sample post

Re: How can I automatically have a tool list at the header of the program when I post?

What I would do in your case:

All but the max/min XYZ & toollist:

Use a VB "journal" with a GUI to get the values (the first time thru), then set part attributes based on the GUI (Note if you use Teamcenter you could use things like item name & item description for some of these).  Then in the post use these part attributes for output.

After the first run, have the journal read the existing attributes to set them in the GUI.  So you only have to enter all the data once, but can still edit it each posting.

 

Tool list : Can be done via the .tpl (shop docs) route - I believe there are examples out on uganswer.  Or (since I thnk you need to do this anyhow) via the "multiple output file" or "edit after posting" methods below.

 

max/min XYZ:

To me, you're goingto have to keep track of this data as you post, then output.  Some notes:

- Set arc & helix output to be "quadrant limited" (that way you don't have to check each arc to see if some intermediate point is actually the X/Y/Z max or min)

- drill cycles - check mom_rapid_to_pos and mom_feed_to_pos

 

to get everything in the output file HEADER:

"multiple output file" method

Use the main output file for the NC code.  Use standard tcl code to open (in your case) 1 other files.

 

As you post, store (in arrays or lists) the max/min XYZ values and tool info for the tool list

Then, in the "end of program" event...

- open this other file

- write info to it

- close it

Then exec a DOS "Copy" command to copy the header & gcode files into a single output file

(or other means to do the same thing) (i.e. append the Gcode file to the header file)

 

"edit after posting" method

Basically, you write evrythin as you go, EXCEPT you just write "placeholder" strings where you want the max/min data & tool list (e.g. "PLACE MAXMIN DATA HERE" and "PLACE TOOL LIST DATA HERE").  In the "end of program" event, you close the output file.  Then using normal tcl code, you open the file, and read thru it.  If not a "placeholder" line, write it out to the "final" file.  If it IS a placeholder line, write the data you want to the final file.

 

Ken

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: How can I automatically have a tool list at the header of the program when I post?

[ Edited ]

This new command MOM_run_postprocess opens up a lot of possibilities. Thanks Postino for the info.

NX10.03
Windows 7 Pro

Re: How can I automatically have a tool list at the header of the program when I post?

[ Edited ]

Study -

 

Yes indeed. Another command could be also of your interest:

 

  • MOM_post_oper_path

     - Post process (preview) an operation from within a post
     - Preview an operation for any reason

     - Similar to MOM_list_oper_path available in Shop Doc

 

Syntax:
   MOM_post_oper_path <oper_name> <output> <event_handler> <definition>

 

Example:



# Assuming the sub-post will be placed in the same directory as main (this) post.
# => User can set it otherwise.
global mom_event_handler_file_name
set CURRENT_POST_DIR [file dirname $mom_event_handler_file_name]

# Validate the sub-post and then run it.
set tcl_file "$CURRENT_POST_DIR/XYZBC_MILLTURN_SUB_IN.tcl"
set def_file "$CURRENT_POST_DIR/XYZBC_MILLTURN_SUB_IN.def"
if { [file exists $tcl_file] && [file exists $def_file] } {
# Specify the temporary output file
set out_file "${mom_output_file_directory}YAXIS_LIMIT.ptp"
set res [ MOM_post_oper_path $mom_operation_name "$out_file" "$tcl_file" "$def_file" ]
} else {
set res -1
}

# Process output file when sub-post ran OK
if { $res == 1 } {
# MOM_output_text "( SUBPOST RAN OK )"
# Loop thru entire output file in case multiple lines have been produced.
set src [open "$out_file" RDONLY]

while { [eof $src] == 0 } {
set local_line [gets $src]

# Do something with "local_line"
}

close $src
file delete "$out_file"
}

 

 

Re: How can I automatically have a tool list at the header of the program when I post?

Yes - that will help too. Like you say - limits can be prechecked and decisions made. I have a few machines with parallel axes where it would be nice to optimize setting the axis of the two (one case 3) with less travel based on running through the motion to see where it went as a whole. However - these facilities are still on 8.5 for now. I will try to talk them into moving forward.

Thanks.

NX10.03
Windows 7 Pro

Learn online





Solution Information