Cancel
Showing results for 
Search instead for 
Did you mean: 

Post Builder - Create an Output Condition

Solution Partner Pioneer Solution Partner Pioneer
Solution Partner Pioneer

Hi,

 

I'm working on a postprocessor that before the Auto Tool Change it has to output a code depending on which operation it will run. For example if there's a Cavity Mill it should be:

 

#149 = 3

TXX M06

 

or if it's a Contour Area:

 

#149 = 1

TXX M06

 

And the same for more operations, I believe that I can achieve this with putting and output condition to the block of code, but I have never worked with conditions before, how can I create the condition or what other solution could I try?

 

thanks!

9 REPLIES

Re: Post Builder - Create an Output Condition

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

What does the #149 specify?

There are a couple options for this:

1) Use different methods (Method view) to let the user select what they want.  Use a UDE (or just the method parent of the operation) to set the value, and output "#149=xx"

 

2) Use the "mom_operation_type" variable to filter & assign the value as appropriate.

e.g. something like:

global mom_operation_type
if {![info exists mom_operation_type]} {
	MOM_output_to_listing_device "ERROR - mom_operation_type not yet set ?!?!"
	return
} elseif {[string match "Point to Point" $mom_operation_type] ||
[string match "Drilling" $mom_operation_type]} { set output_value 1 } ;# additional "elseif" here for all operation types { } else { MOM_output_to_listing_device "ERROR - this mom_operation_type ($mom_operation_type) not yet handled?!?!" return } MOM_output_literal "#149 = $output_value "
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: Post Builder - Create an Output Condition

Solution Partner Pioneer Solution Partner Pioneer
Solution Partner Pioneer
the #149 is a variable that I need to put before the tool change in order to do a measurement of the tool before the operation, the thing is that I have to do a different #149 for each operation, only in a few it has the same value.

I think an UDE would be something tedious to do because I need to set it for every operation. I'll try to do the 2nd option.

Thanks!

Re: Post Builder - Create an Output Condition

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

When is it the same?

- when you re-use a tool?

- something else?

 

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: Post Builder - Create an Output Condition

Gears Phenom Gears Phenom
Gears Phenom

You can use mom operation type, template subtype and more variables, or combination of them.

Just see their output  and decide your rule what and when should be outputed.

---------------------------------------------
#♫ PB, 5ax, itnc, nx, vericut ♫ #

Re: Post Builder - Create an Output Condition

Solution Partner Pioneer Solution Partner Pioneer
Solution Partner Pioneer

this is what I have set on a Custom Command:

 

global mom_operation_type
if {![info exists mom_operation_type]} {
    MOM_output_to_listing_device "ERROR - mom_operation_type not yet set ?!?!"
    return
} elseif {[string match "Fixed-axis Surface Contouring" $mom_operation_type] ||
      [string match "Drilling" $mom_operation_type]} {
        set output_value 1
} elseif {[string match "Cavity Milling" $mom_operation_type] ||
          [string match "Z-Level Milling" $mom_operation_type]} {
                set output_value 3
} else {
    MOM_output_to_listing_device "ERROR - this mom_operation_type ($mom_operation_type) not yet handled?!?!"
    return
}
MOM_output_literal "#149 = $output_value "

 

I did it that way because I needed for Fixed Axis, Drilling to set the output value to 1 and then on Cavity Mill and Z level the output needs to be 3. But now I have a problem that I also need for a Point to Point operation to have an output_value of 1, so I did this:

 

global mom_operation_type
if {![info exists mom_operation_type]} {
    MOM_output_to_listing_device "ERROR - mom_operation_type not yet set ?!?!"
    return
} elseif {[string match "Fixed-axis Surface Contouring" $mom_operation_type] ||
      [string match "Drilling" $mom_operation_type]} {
        set output_value 1
}
elseif {[string match "Point to Point" $mom_operation_type] }
{
set output_value 1
}
 elseif {[string match "Cavity Milling" $mom_operation_type] ||
          [string match "Z-Level Milling" $mom_operation_type]} {
                set output_value 3
} else {
    MOM_output_to_listing_device "ERROR - this mom_operation_type ($mom_operation_type) not yet handled?!?!"
    return
}
MOM_output_literal "#149 = $output_value "

 

but when I postprocess I get an error that comes from the MOM_first_tool event

 

what can I do to fix this?

 

Re: Post Builder - Create an Output Condition

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

...
} elseif {[string match "Fixed-axis Surface Contouring" $mom_operation_type] ||
      [string match "Drilling" $mom_operation_type]} {
        set output_value 1
}
elseif {[string match "Point to Point" $mom_operation_type] }
{    <========this one
set output_value 1
}
 


You have a tcl syntax error - the indicated "brace" character needs to be at the end of the previous line:

(EDIT - also the "elseif" command needs to be moved up to the end of the previous line!)

} elseif {[string match "Point to Point" $mom_operation_type] } {  
set output_value 1
}

 

If you get an error when posting, look in the syslog (File -> Help -> log file) - scroll to the bottom, then work your way up to the start of the "crash dump" to see what the real tcl error is.

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: Post Builder - Create an Output Condition

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

and the next "elseif" needs to be moved up after the brace as well...

 

Note tcl is NOT like C/C++ in how braces work. 

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: Post Builder - Create an Output Condition

Solution Partner Pioneer Solution Partner Pioneer
Solution Partner Pioneer

I corrected the syntax, still got the error.

On the syslog this is what I found,

***TCL_ERROR***: Event Handler: P:\Clientes\Escorial\Postprocesador\Fresa\POST KITAMURA ULTIMO\FANUC_16i_120310.tcl, Event: MOM_first_tool, Error: invalid command name "elseif"
while executing
"elseif {[string match "Point to Point" $mom_operation_type] } {
set output_value 1
}"

 

EDIT: now I read your second post about the syntax, you are right. I wrote it like it was C or some coding language but tcl is different and more sensitive on the position of the braces. I corrected again the syntax and now it works properly! Thanks for your help Ken_A

Re: Post Builder - Create an Output Condition

Phenom
Phenom

Consider using "switch" as it handles the "String Match" and "OR" cases with easier to read code

it will also do glob and regex matches

 

global mom_operation_type
if {![info exists mom_operation_type]} {
    MOM_output_to_listing_device "ERROR - mom_operation_type not yet set ?!?!"
    return
}

switch $mom_operation_type {
    "Fixed-axis Surface Contouring" -
    "Drilling" -
    "Point to Point" {
        set output_value 1
    }
    "Cavity Milling" -
    "Z-Level Milling" {
        set output_value 3
    }
    default {
        MOM_output_to_listing_device "ERROR - this mom_operation_type ($mom_operation_type) not yet handled?!?!"
        return
    }
}

MOM_output_literal "#149 = $output_value "

Learn online





Solution Information