cancel
Showing results for 
Search instead for 
Did you mean: 

.TCL assitance

Genius
Genius

Hello All,

 

I'm looking for a lttle help with some .tcl code, I have created a UDE for the programmer to define some custom information for tool datumning and have added it to the start events in the tool template. The problem that I have is as long as the information is present either in the template or just in the start events my code works fine and gives me the results I require but if a tool has no reference to it it picks one of the custom numbers and reuses that?

Hoping that some one can point me in the right direction with this problem.

 

Bitmap imagine.PNG

Posted out put below

(TOOL LENGTH OFFSETS)

#2001=123.000 (SLOT-10-HI-SPEED - A179)

#2002=115.000 (SPOT-6.0-HI-SPEED - C900)

#2003=110.000 (SLOT-6.0-HI-SPEED - A174L)

#2004=105.000 (HC-SL01-0300-01 - D491)

#2005=141.000 (HH-FM01-0120-01 - F263)

#2016=125.000 (HC-SP01-0300-01 - D446)

()

(TOOL DATUM BIT MAPS)

#601=777.7777

#602=221.0600

#603=111.1111

#604=121.0300

#605=111.1111

#616=888.8888

Code below is sections from the complete file

 

	#CUSTOM BITMAP INFO
	if {[info exists mom_ren_custom_bitmap] && $mom_ren_custom_bitmap == "TRUE" && $mom_ren_custom_number > 0.0} {
		 set temp_custom_bitmap 1
		 set temp_custom_bitmap_number [format "%3.4f" [expr $mom_ren_custom_number]]
	} else {
		set temp_custom_bitmap 0
		set temp_custom_bitmap_number 000.0000
	}
 #ONLY ADD FIRST OCCURANCE OF TOOL TO TOOL LIST
    #IGNORE PROBE AND MASTER TOOL (i.e. >= 27)
    if {![info exists mom_drive_point_diameter]} {
        set mom_drive_point_diameter 0
    }
    if {(![info exists ren_tool_list($mom_tool_number)] || [llength $ren_tool_list($mom_tool_number)] != 6) && $mom_tool_number < 27} {
        set ren_tool_list($mom_tool_number) [list $mom_tool_name $temp_gauge_length $temp_tool_tip $mom_tool_type $mom_tool_direction $mom_tool_diameter $temp_catalog_number $mom_drive_point_diameter $temp_custom_bitmap $temp_custom_bitmap_number]
    }
		# TOOL BITMAP HEADER
		set ren_tool_bitmap_blocks($temp_bitmap_count) "()"; incr temp_bitmap_count
		set ren_tool_bitmap_blocks($temp_bitmap_count) "(TOOL DATUM BIT MAPS)"; incr temp_bitmap_count
	}

	foreach tool [lsort -integer [array names ren_tool_list]] {
		set temp_tool $ren_tool_list($tool)
		set temp_name [lindex $temp_tool 0]
		set temp_gauge [format "%.3f" [expr [lindex $temp_tool 1]+0]]
		set temp_tip_angle [lindex $temp_tool 2]
		set temp_type [lindex $temp_tool 3]
		set temp_tool_direction [lindex $temp_tool 4]
		set temp_tool_diameter [lindex $temp_tool 5]
		set temp_vid [lindex $temp_tool 6]
		set temp_tp [lindex $temp_tool 7]
		set temp_custom_bitmap [lindex $temp_tool 8]
		set temp_custom_number [lindex $temp_tool 9]
		set temp_tool_bitmap 000.0000
		set temp_digit1 0
		set temp_digit2 0
		set temp_digit3 0
		set temp_custom_bitmap_value 0
		set temp_custom_bitmap_number 000.0000

set temp_tool_bitmap [format "%3.4f" [expr ($temp_digit1 * 100) + ($temp_digit2 * 10) + $temp_digit3 + ($temp_tool_diameter / 100)]]
			
			#CUSTOM BITMAP INFO
			if {[info exists temp_custom_bitmap] && $temp_custom_bitmap == 1 && $temp_custom_number > 0.0} {
				set temp_custom_bitmap_number [format "%3.4f" [expr $temp_custom_number]]
				set temp_tool_bitmap $temp_custom_bitmap_number
			}

				
			
			set ren_tool_bitmap_blocks($temp_bitmap_count) "#[expr 600 + $tool]=$temp_tool_bitmap"; incr temp_bitmap_count

Any help on this is greatly appreciated.

 

 

Regards

Dave
NX10.0.3MP13
NX11.0.1
Production
TC10
Vericut 7.3,7.4.1,8.0.2
3 REPLIES

Re: .TCL assitance

PLM World Member Valued Contributor PLM World Member Valued Contributor
PLM World Member Valued Contributor

I usually unset variables to avoid this.  Operation End in Post Builder is where I do it.  Try searching for unset in other posts for more ideas.  

Jeff Sauers, Lead CNC Programmer, Oberg Industries

Production: NX 10.0.3.5, Vericut 8.0


Re: .TCL assitance

Esteemed Contributor
Esteemed Contributor

As Jeff said, NX does not "clean up" after itself - you have to do this yourself..

 

For something like this (if you don't need it later in the operation) I have the proc that outputs the code "unset" all the variables (as I know they are or are not set)

If it is something I might need all the way thru the op, then use a proc that has code like this in the "end of path":

global my_variable_name
catch { unset my_variable_name}

The "catch" will allow the post to continue if the variable is not set.

 

 

Note when I create a UDE, I (almost always) create a "Moog_UDE_NAME_Cleanup" proc (in a "source"d in file) that does the unsets.  That way, when I add support for a UDE in the post, I know to add a call to the "cleanup" proc in end-of-path (or wherever appropriate).  Easy to modify later if I need to add a param to the UDE, I know I only need to edit one place to clean the added param up in all my posts.

 

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


Re: .TCL assitance

Genius
Genius

Thank you both that's perfect everything works nowSmiley Very Happy

 

Really appreciate you taking the time to reply thanks again.

Regards

Dave
NX10.0.3MP13
NX11.0.1
Production
TC10
Vericut 7.3,7.4.1,8.0.2

Learn online





Solution Information