Showing results for 
Search instead for 
Do you mean 
Reply

Can you create a lookahead using TCL in a PostBuilder Custom Command

Can you create a lookahead using TCL in a PostBuilder Custom Command?  I am new to PostBuilder but was able to do this in the past with other post processor generators and found it very useful. 

5 REPLIES

Re: Can you create a lookahead using TCL in a PostBuilder Custom Command

There are some options. One would be using MOM_run_postprocess. Below would be a couple of related threads (recent ones)

 

http://community.plm.automation.siemens.com/t5/Discussion-Forum-NX/MOM-run-postprocess/m-p/319450#M4...

 

http://community.plm.automation.siemens.com/t5/Discussion-Forum-NX/Postprocessor-with-multiple-file/...

 

With this method you could create a post that saves data or writes it out while posting for use by your main one for lookahead information. I haven't needed to do this but can see where it would be nice.

NX10.03
Windows 7 Pro

Re: Can you create a lookahead using TCL in a PostBuilder Custom Command

Thanks for the suggestion Study.  My previous experience was working with a CLDATA file prior to MOM and from within the post I could stop at a particular point and continue looking ahead in the CLDATA file reading the attributes of each line pulling out the relevant information I required.  Then jump back to where I stopped and use the information gathered to either put out to the NC tape or use within a logical decision making process.  I typically found this to be a very useful feature so just wondered if I could do the same.  It may be that this function is not required or relevant now if I can access ALL the information from the MOM file some other way?  For instance can I find out the number of the last tool to be used, all the tool number in the whole tape, next spindle speeds and feeds ......etc.  Look ahead’s may now be redundant but it was a very useful feature that got me out of a lot of issues.

 

Re: Can you create a lookahead using TCL in a PostBuilder Custom Command

A "cycle objects" pass through the navigators can get some information - it is not all of the same information you get from a post run through (event generator playing through in posting) but tool data and sequence things can be discovered/saved. The difference with taking a cl text file and posting it vs posting in UG post real time is that there is a lot more data available, it is only available until it is written over, and it is all in memory (not in a file.) It would be possible to save all events fired and all data when it changes in a file (or in memory) and then you could work forward and back as much as you want. It would be a bit of a development project. The review tool related events will alert you to when values change. Take a look at the text file the review tool uses (writes - then brings it up in the tk inteface.) This would be a format similar to what could be done.

NX10.03
Windows 7 Pro

Re: Can you create a lookahead using TCL in a PostBuilder Custom Command

There are a few ways to do this.

 

1) Add this code to a custom command in the "Start of program" event

	global mom_kin_read_ahead_next_motion
	set mom_kin_read_ahead_next_motion 1
	MOM_reload_kinematics

It will only read ahead *1* block, and it isn't really usable until at (or maybe after) the initial & first move events, but it is something (data is in mom_nxt_* variables)

 

 

2) (as suggested) use the MOM_do_template_file to cycle thru "shop docs" code to get what you need.

The good thing about this method, is that any tcl "global" variables you define in the "shop docs" code will be available in the rest of the post.  Then bad thing about this method is that the shop docs code will define a lot of variables that over-ride the current settings before you called MOM_do_template_file.  So you may have to save a bunch of variables & restore them after.

 

3) (as suggested) use MOM_run_postprocess to run a separate post.

The good news is that this doesn't hose all the current mom variables.  The bad news is the ONLY way to get data back to the main post code is to use (or parse) the file output by that postprocessor.

 

4) If the data you need is not available when you need it, you can (at the end of posting - at the end of the "end of program" event) close the output file, then (using regular tcl code) open it, parse thru, and write the data you want where you want it.  There are examples around showing how to do this with a tool list at the "start of program".  Note one help is to write a unique line (e.g. "PUT TOOL DATA HERE LATER") in the first post pass, and search for that line as you are processing the file in the second pass.

 

5) A variant of (4) - just write the data to separate files. (i.e. program header to 1 file, tool list to another file, workshift offsets to a 3rd, actual code to a 4th, etc.) and then (in "end of program") close them all and append them together in the appropriate order.

 

What kinds of things do you need to "look ahead" for?

It could be there's another way to get what you want.

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: Can you create a lookahead using TCL in a PostBuilder Custom Command

Hi,
Using "look ahead" may have good effect only in some situations when you need move/replace/insert/etc any SINGLE data from-next-to-old.
If you are going to change whole LOGIC of output depending on future data, you'll get a lot of problems with TCL because of the need to develop many additional procedures for manipulation with files or with memory. This work would be comparable to recoding CLDATA files as you did in other CAM products.

Learn online





Solution Information