Cancel
Showing results for 
Search instead for 
Did you mean: 

Re: problem accessing mom_tool_axis

Pioneer
Pioneer

ok, please excuse my limited knowledge of tcl. what does the line

 

set global_vars ]

 

do? I don't know what that closing brace does. I'm asking because postbuilder is giving me errors when I try to copy and past the MOOG_Show_globals into a custom command

 

 

Re: problem accessing mom_tool_axis

Master
Master

These are from the old forum but sometimes it looks like NX loses its arrays! LOL I don't see any solutions in either of these threads and there may be more.

 

http://community.plm.automation.siemens.com/t5/NX-CAM/mom-cycle-rapid-to-pos-PB-6-0-3-2/m-p/231736/h...

 

http://community.plm.automation.siemens.com/t5/NX-CAM/Strange-problem-with-mom-out-angle-pos/m-p/212...

Shags72 Mfg. Eng.
Windows 10 Pro 64bit
NX 11.0.2.7 MP2 Teamcenter 11
Dell M7720 i7-6820HQ 16GB RAM,
NVIDIA Quadro P3000

Re: problem accessing mom_tool_axis

Pioneer
Pioneer

 

Hmmm is this a bug, or do I not know enough Tcl?

 

If I code 

upvar #0 mom_tool_axis test
MOM_output_literal [array get test]

the program works fine and I get a listing of the three values of mom_tool_axis.

but if I code

upvar #0 mom_tool_axis test
MOM_output_literal $test(0)

the compiler complains that test is not an array. 

 

Any thoughts?

Re: problem accessing mom_tool_axis

Pioneer
Pioneer

ok, the following code works, but why can't I just access the array elements?

 

upvar #0 mom_tool_axis test

set axis_values [array get test]
set a_val [lindex $axis_values 1]
set b_val [lindex $axis_values 3]
set c_val [lindex $axis_values 5]

MOM_output_literal "mom_tool_axis a: $a_val b: $b_val c: $c_val"

mom_tool_axis is a global that is available at tool change, I have verified this. But the compiler does not let you access it as an array. Weird.

 

Re: problem accessing mom_tool_axis

Phenom
Phenom

Are you talking about the syntax checking in the post builder interface or an error at posting? I have had the interface complain about a lot of stuff when I try to save. I haven't had this problem with arrays - but like shags shows - some have. If it is the inteface complaining - the catch may make the interface happy (though not needed at post time.) I code a lot in external source files which has it's own problems sometimes with debugging - but at least there are no complaints when saving. Worst of all is to get no complaints but when you reopen - postbuilder can't get through syntax checks.

NX12.02
Windows 10 Pro
ITC Inc.

Re: problem accessing mom_tool_axis

Pioneer
Pioneer

You may be cycling CAM objects during posting that have no tool axis (UDEs, program group, geo groups etc...).

 

This code works: (ignore the BNLxxxxxxx command)

 

#
# P.M. 09/12/08
# Check for an -X- axis vector change.
# Throw a warning if this is the case.
# NX will not always throw a warning.
global mom_tool_axis

global X_axis_vector
global mom_operation_name


if {[info exists mom_tool_axis(0)]} {

         set  mom_X_axis_vector [format %4.3f $mom_tool_axis(0)]

 

  if { $mom_X_axis_vector !=0} {

     set Message(0) "Operation: $mom_operation_name"
     set Message(1) "Not a 5 axis machine"
     set Message(2) "X axis vector is $mom_X_axis_vector. It should be zero \n"
     BNL_log_error_to_file SPINDLE Message


 }
 }

Re: problem accessing mom_tool_axis

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Note I would tend to code what you want this way:

global mom_tool_axis
if {[info exists mom_tool_axis(0)]} {
   MOM_output_literal "mom_tool_axis(0) = $mom_tool_axis(0)"
} else {
   MOM_output_literal "mom_tool_axis(0) not set"
}

 Now why PB is reporting it is (or isn't) an array and reporting errors - to me, that's a bug.

And that's why I write most/all my custom code in external tcl files that I "source" into the post - all that checking may be nice, but it always seems to get in my way.

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: problem accessing mom_tool_axis

Pioneer
Pioneer

Yep, I have to agree with you that it's a bug. It is the editor that is giving the error when you try to close the editor window. Obviously the editor doesn't know enough about the global variables. Somewhere there is a definition missing.

 

You can go behind postbuilder's back and hand edit the def file, and it works fine. The problem is not the syntax, the problem is the postbuillder editor.

 

This sucks, though, the whole idea behind postbuilder is that you DON'T need to code tcl by hand in text files. They should fix it.

 

Dan

Re: problem accessing mom_tool_axis

Pioneer
Pioneer

and I agree that I should use the [info exist var] construct, but I didn't want to complicate the example code.

 

 

Re: problem accessing mom_tool_axis

Pioneer
Pioneer

Ken:

 

if [info exists mom_tool_axis] ...

 

actually gets around the problem! the editor accepts the syntax, and it is the sensible way to program it anyways!

 

Thanks

 

 

Learn online





Solution Information