Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

MOM_run_postprocess tips

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Someone asked about tips/techniques to use "MOM_run_postprocessor", so I thought I'd start a thread.

 

1) It is "MOM_run_postprocess", not ""MOM_run_postprocessor"  :-)

 

2) the .tcl & .def file you run may be created by post builder (or, I assume, PC) but if you know what you are doing, you can strip the files down a lot so (I think) it runs MUCH faster than a normal post.

 

3) as posted by [someone else] if you write the output file as tcl code, you can just "source" the output file into your main post & have all the variables defined.

 

4) the *only* thing you can pass (as an argument is the name of the output file.  But note that is info in an of itself.  So if you need to pass more info to the "MOM_run_postprocess" post, you can pass it in ANOTHER file (with a "similar" name) that can be read in by the sub-post & acted on...

 

Examples in replies...

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


5 REPLIES 5

Re: MOM_run_postprocess tips

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

5) There are things you can't do in "MOM_run_postprocess".  Remember, it only posts the operations you selected for the "main" post to run, so (for example) it won't find MCS objects that are not used by those operations (if you want to find all MCS objects in the part)

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


Re: MOM_run_postprocess tips

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

(4) - passing more info to the sub post

 

Say you have this line in your main post:

MOM_run_postprocess $local_folder\\My_Sub_Post.tcl $local_folder\\My_Sub_Post.def C:\\Temp\\My_output_file.Txt

I believe "My_output_file.Txt" is cleared as the sub post starts up (i..e any text in it is erased)

 

But there's nothing preventing you from doing something in the main post to write data (or tcl commands) to a file "C:\\Temp\\My_output_file.Txt_Parameters"

 

And then in the sub post doing something like:

global mom_output_file_full_name
set param_filename "${mom_output_file_full_name}_Parameters"
if {[file exists $param_filename]} {
	source $param_filename
	MOM_output_text "# reset params using file $param_filename"
	catch { file delete -force  $param_filename }
} else {
	MOM_output_text "# ERROR - unable to update parameters - file doesn't exist: $param_filename"
}

 

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


Re: MOM_run_postprocess tips

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

(4) - passing more info to the sub post

 

Say you have this line in your main post:

MOM_run_postprocess $local_folder\\My_Sub_Post.tcl $local_folder\\My_Sub_Post.def C:\\Temp\\My_output_file.Txt

I believe "My_output_file.Txt" is cleared as the sub post starts up (i.e. any text in it is erased)

 

But there's nothing preventing you from doing something in the main post to write data (or tcl commands) to a DIFFERENT file, e.g.  "C:\\Temp\\My_output_file.Txt_Parameters"

 

And then in the sub post doing something like:

global mom_output_file_full_name
set param_filename "${mom_output_file_full_name}_Parameters"
if {[file exists $param_filename]} {
	catch { source $param_filename }       ;# or process the file however you need to
	# MOM_output_text "# reset params using file $param_filename"  ;# for debugging
	catch { file delete -force  $param_filename }
} else {
	MOM_output_text "# ERROR - unable to update parameters - file doesn't exist: $param_filename"
}   

 

EDIT: forgot "catch"

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


Re: MOM_run_postprocess tips

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

6) How to make sure MOM_run_postprocess ran successfully

 

This is what I do:

 

global mom_output_file_directory
set Out_Filespec "${mom_output_file_directory}Something.txt"
catch { file delete -force $Out_Filespec }
set local_folder [MOM_ask_env_var UGII_CAM_POST_DIR] ;# or wherever you store the sub-post

set status [MOM_run_postprocess $local_folder\\Sub_post.tcl $local_folder\\Sub_post.def $Out_Filespec] if {$status != 1} { MOM_output_to_listing_device "ERROR: Created $Out_Filespec = $status" } elseif {[file exists $Out_Filespec]} { source $Out_Filespec ;# or however you want to parse the file if {0} { MOM_output_to_listing_device "DEBUG - not deleting $Out_Filespec" } else { catch { file delete -force $Out_Filespec } } }
Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP16/TC11.2
I'd rather be e-steamed than e-diseaseled


Re: MOM_run_postprocess tips

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

If you code the sub-post to write tcl commands, then "source" the file into the main post, you would (typically) want to:

catch { source $Out_Filespec }

However, then that will fail at the first error, and the remaining data would be ignored.

 

In the sub-post you can add "catch" around each line automatically using the following proc in the sub-post.

Note I still use "global ..." for global variables, instead of "::", so I don't write "catch" around the global variable declarations...

 

#=============================================================
# in case any random lines get out, catch each one individually
proc MOM_before_output { } {
#=============================================================
	# encapsulate ALL output lines with catch, if not starting with "#" or "global"
	global mom_o_buffer
	
	set loc [string first "global" $mom_o_buffer]
	if {$loc >= 0 &&
		$loc < 5} {
		return
	}
	
	if {[string index $mom_o_buffer 0] != "#"} {
		set mom_o_buffer "catch { $mom_o_buffer }"
	}
}

 

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


Learn online





Solution Information