Cancel
Showing results for 
Search instead for 
Did you mean: 

Re: NX10 Incorporating "Notes" into either setup sheets or top of posts.

Phenom
Phenom

% time {bysort2} 1000
582 microseconds per iteration

 

As I read the tcl docs

 

"foreach" evaluates the [lsort -integer [array names test]] only once and iterates the result

 

whereas "for" evaluates the test each iteration

Re: NX10 Incorporating "Notes" into either setup sheets or top of posts.

PLM World Member Phenom PLM World Member Phenom
PLM World Member Phenom


We have found some real use for this and want to thank everyone involved.
I took this and added a proc and UDE to trigger it within an operation.
One of the isseus we have is inserting large notes or a bunch of commands into
a program.  With the below UDE and Proc you can choose if this is inserted or
a list of notes with or without seq numbers.  Since we are fortunate enough to
have Fanuc controls I did not bother to add the system defined control in and out string
just hard coded the ( parentheses )

 

 

# UDE

EVENT my_insert_notes
{
   UI_LABEL "Note Options"
  
   PARAM my_note_use
   {
      TYPE o
      DEFVAL "Note"
      OPTIONS "Note","Insert"
      UI_LABEL "Note"
   }
   PARAM my_note_seq
   {
      TYPE o
      DEFVAL "NO"
      OPTIONS "NO","YES"
      UI_LABEL "Seq Numbers?"
   }
}

 

 

proc MOM_my_insert_notes {} {
#  Output operation notes one line at a time.
#  Add this to the Start of Path event.
#
global mom_my_note_use
global mom_operation_notes
global mom_my_note_seq

if { $mom_my_note_use == "NOTE" && $mom_my_note_seq != "YES" } { MOM_set_seq_off }

  # If notes are defined, output each line of text from the array.
   if { $mom_my_note_use == "NOTE" && [info exists mom_operation_notes] && [array exists mom_operation_notes] } {
      foreach i [lsort -integer [array names mom_operation_notes]] {
         if [info exists mom_operation_notes($i)] {
         MOM_output_literal " \( [string toupper $mom_operation_notes($i)] \)"
         }
      }
   # Clear for next operation
      array unset mom_operation_notes
  }

if { $mom_my_note_use == "INSERT" && $mom_my_note_seq != "YES" } { MOM_set_seq_off }
# If notes are defined, output each line of text from the array.
   if { $mom_my_note_use == "INSERT" && [info exists mom_operation_notes] && [array exists mom_operation_notes] } {
      foreach i [lsort -integer [array names mom_operation_notes]] {
         if [info exists mom_operation_notes($i)] {
         MOM_output_literal "$mom_operation_notes($i)"
         }
      }
   # Clear for next operation
      array unset mom_operation_notes

   }

John Joyce, Manufacturing Engineer,
Senior Aerospace

NX 11.0.2.7 Vericut 8.0.3 - Statements and opinions are mine alone and do not reflect
the opinion of my employer or any other member of the human race

Re: NX10 Incorporating "Notes" into either setup sheets or top of posts.

Legend
Legend
The discussion of the thread shifted from shop docs to post output. Has anyone got it to sucessfully generate in the excel shop docs? I'm a TCL noob. Willing to pay someone for this functionality.

Dennis Rathi
Creations Unlimited

Re: NX10 Incorporating "Notes" into either setup sheets or top of posts.

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Well, the title of the post is "shop docs OR top of post" :-)

 

One thing in John's post - Most Fanuc controls I have dealt with can't handle embedded parentheses - the first "close" closes all, and the text after the first ")" is treated as G & M code.

 

I.e. if the programmer enters a note like:

"#80 (.0135) DRILL"

So output by post is:

(#80 (.0135) DRILL)

the control will choke (it won't understand "DRILL)").

 

some tcl code like this will strip them out (Note I may not use the best "foreach" clause, as discussed earlier...):

foreach i [array names mom_operation_notes] {
	# Ignore blank lines - comment out nxt line if you want them
	if {![string length $mom_operation_notes($i)]} { continue }

# OK if first or last character in string - just remove them # strip off any leading "control out" character set output_text0 $mom_operation_notes($i) set len_co [string length $mom_sys_control_out] if {[string range $mom_operation_notes($i) 0 [expr $len_co-1]] == $mom_sys_control_out} { set output_text0 [string range $mom_operation_notes($i) $len_co end] } if {![string length $output_text0]} { continue } # strip off any trailing "control in" character (if there is one) set output_text1 $output_text0 set length [string length $output_text0] set len_ci [string length $mom_sys_control_in] if {$len_ci} { if {[string range $output_text0 [expr $length-$len_ci] end] == $mom_sys_control_in} { set output_text1 [string range $output_text0 0 [expr $length-$len_ci-1]] } }
# As typical characters spaz regular expressions, do this by special cases # Note PB supports following characters as "control out/in": ()#*,;:/ # and the following ones (in quotes) spaz regsub "()*" switch $mom_sys_control_out { "(" { set status [regsub -all {\(} $output_text1 {} output_text2] } ")" { set status [regsub -all {\)} $output_text1 {} output_text2] } "*" { set status [regsub -all {\*} $output_text1 {} output_text2] } default { set status [regsub -all $mom_sys_control_out $output_text1 {} output_text2] } } switch $mom_sys_control_in { "(" { set status [regsub -all {\(} $output_text2 {} output_text] } ")" { set status [regsub -all {\)} $output_text2 {} output_text] } "*" { set status [regsub -all {\*} $output_text2 {} output_text] } default { set status [regsub -all {$mom_sys_control_in} $output_text2 {} output_text] } } if {$output_text != $output_text1} { MOM_output_to_listing_device "$mom_operation_name: WARNING - Operation Notes Output - Note $i - \"$output_text1\" - had embedded control characters removed" } MOM_output_literal "$mom_sys_control_out$output_text$mom_sys_control_in"
}

I *do* use the variables, so the above should be generic across all machines (unless you come across another control out/in code that chokes regsub).

 

Also, if they are the first/last chacter(s) in the line, that is OK (IMHO).

But if they are embedded within the text (like my example above) then I warn the user about the change I make

 

Ken "foreach as I say, not as I foreach" Akerboom

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: NX10 Incorporating "Notes" into either setup sheets or top of posts.

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

@Dstryr wrote:
Has anyone got it to sucessfully generate in the excel shop docs?

The Excel based shop docs are just supporting regular variables, no arrays.

 

You might be able to create a single variable containing the HTML code to display the contents of the array.

 

I haven't dealt with the Excel based docs, since I do too much Tcl voodoo in my custom shop docs.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.2, FBM, MRL 3.1.7 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 11.4
Development: C (ITK), .NET, Tcl/Tk Testing: NX12.0 | AWC 3.4 Preparing: NX12.0

Employees of the customers, together we are strong Smiley Wink
How to Get the Most from Your Signature in the Community
NX Customization - Best Practice Guide

Learn online





Solution Information