cancel
Showing results for 
Search instead for 
Did you mean: 

Unusual results with mom_tool_text variable

Hi all,

 

I'm getting inconsistent values when trying to use the mom_tool_text variable that comes from the Text field in the tool dialog.

mom_tool_text.jpg

 

During posting I get the expected value from this field when its populated.  However, if I clear the field, I don't get consistent results with every subsequent post.  See sample code below:

 

if {[info exists mom_tool_text]} {

   if {[string equal $mom_tool_text ""]} {

      MOM_output_literal “DEFINE TOOL CODE USING NX PARAMETERS”

   } else {

      MOM_output_literal "($mom_tool_text)"

} else {

   MOM_output_literal "(!ERROR! PLEASE RE-POST AGAIN TO REFRESH VARIABLES)"

}

 

Using the code above, the first time I post a program after clearing a value form the Text field I get the output:  (!ERROR! PLEASE RE-POST AGAIN TO REFRESH VARIABLES).  However, if I post again without making any changes to the CAM file I'll get the expected result: DEFINE TOOL CODE USING NX PARAMETERS.

 

My sense is that I shouldn't get a different result just by reposting.  BTW, I'm using NX version 9.0.3.4.   

 

Can anyone please explain/help?  Thanks!

 

-David

 

 

 

6 REPLIES

Re: Unusual results with mom_tool_text variable

Esteemed Contributor
Esteemed Contributor

Not a direct answer to your questions, but something to be aware of...


Note that NX does not (typically) clean up after itself.

So if you use tool 1 with text defined, then you use tool 2 and the text field is empty, tool 2 may list tool 1's text.

So at end of path (especially if there is a tool change in the next path) I would :

global mom_tool_text 
catch { unset mom_tool_text }

 

As to your problem, that is "interesting" - I'd report to GTAC

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: Unusual results with mom_tool_text variable

Phenom
Phenom

I had a similar issue when adding text field output from tools.

 

Here is what I found

Create 3 tools

MILL_TOOL_NO_TXT text field untouched 

MILL_TOOL_WITH_TXT add text

MILL_TOOL_TXT_DELETED add text OK, reopen tool and delete text

 

using the following

 

MOM_output_to_listing_device "-------------------------------------" 
MOM_output_to_listing_device "$mom_tool_name" 
if {[info exists mom_tool_text]} {
    MOM_output_to_listing_device " mom_tool_text exists." 
    if {[string length $mom_tool_text]} {
        MOM_output_to_listing_device " mom_tool_text = $mom_tool_text" 
    } else {
        MOM_output_to_listing_device " mom_tool_text has no length." 
    }
} else {
    MOM_output_to_listing_device " mom_tool_text does not exist." 
}

 

gives this

 

-------------------------------------
MILL_TOOL_WITH_TXT
 mom_tool_text exists.
 mom_tool_text = Text Field
-------------------------------------
MILL_TOOL_TXT_DELETED
 mom_tool_text does not exist.
-------------------------------------
MILL_TOOL_NO_TXT
 mom_tool_text exists.
 mom_tool_text has no length.

  however change tool used order and output changes.

 

-------------------------------------
MILL_TOOL_TXT_DELETED
 mom_tool_text exists.
 mom_tool_text has no length.
-------------------------------------
MILL_TOOL_WITH_TXT
 mom_tool_text exists.
 mom_tool_text = Text Field
-------------------------------------
MILL_TOOL_NO_TXT
 mom_tool_text does not exist.

 and

 

-------------------------------------
MILL_TOOL_NO_TXT
 mom_tool_text does not exist.
-------------------------------------
MILL_TOOL_WITH_TXT
 mom_tool_text exists.
 mom_tool_text = Text Field
-------------------------------------
MILL_TOOL_TXT_DELETED
 mom_tool_text does not exist.

 

the upshot is we dont trust  "info exists mom_tool_text" to mean anything and use the following

 

if { [info exists mom_tool_text] && [string length $mom_tool_text] } {
    MOM_output_literal " $mom_tool_text "
} else {
    MOM_output_literal " no tool text"
}

 

hope this helps

 

Alex

NX9.0.3.4

Win 7 pro 64

 

Re: Unusual results with mom_tool_text variable

Alex,

 

Thanks for the suggestion.  I like your syntax implementation better than mine (using the string length subcommand).  Unfortunately this doesn't yield an acceptable result.  After clearing text field I get the following error:

 

error.jpg

 

This is why I was outputting an else condition within the code to prevent this error.  I'll report to GTAC.

 

Ken - Thanks for pointing out the lack of clean up.  I was unaware.  What is the scope of the garbage collection (or lack thereof)?   Will NX not release the memory after posting is complete....or are you saying that it may not release the memory after the execution of a specific custom command?

Re: Unusual results with mom_tool_text variable

Phenom
Phenom

Thats why I use exist and then length

evaluation of if is left to right

in the case of && if the first condition fails the second is not evaluated

 

 

if { [info exists mom_tool_text] && [string length $mom_tool_text] } {

}

 

 

 

Re: Unusual results with mom_tool_text variable

Okay.  Got it.  Thanks Alex!

Re: Unusual results with mom_tool_text variable

Esteemed Contributor
Esteemed Contributor

RE: Cleanup

Within a run of  the post, for most (if not all) variables, they are not ever cleaned up.  They may get new values (when needed) but they aren't deleted.   E.g. at tool change, the old mom_tool_* variables are not deleted (e.g. for turning tools... groove tools can have mom_tool_right_radius/mom_tool_left_radius.  When changing to a single point tool, mom_tool_nose_radius gets defined correctly, but mom_tool_right_radius/mom_tool_left_radius do not get un-defined)

 

They should be cleaned up between post runs (i.e. each time you select something -> postprocess, you start from scratch)

 

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


Learn online





Solution Information