Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

seqnum variables - tool list

[ Edited ]

Good morning,

How can I catch / save my last value (in this case was "23" num_blok , attached in JPG) which is working in Mathematical sequence {n+1} ?

 

variable name added to tool list proc PB_CMD_list

global num_blok

set num_blok [expr {$num_blok+1}]

 

I need to pick up last value from tool list and paste it to new variable sequence starting .

new variable sequence  can be named as last_var

 

My idea was MOM_reset_sequence $last_var 1 1 and start with MOM_set_seq_on

 

Everything is shown in the illustration below :

 

Best regards ,

 

PS. My old heidenhain driver is weird and it need to have exact block number Smiley Happy

PS. The tool list proc. (TOOL DEF) complicates the situation..

========================================
Engineering >> NX10.0 Performance in the making
8 REPLIES

Re: seqnum variables - tool list

At the end of your code, try:

global mom_seqnum
set mom_seqnum $last_var
MOM_set_seq_on

 

You might need to increment the "last_var" value ("incr last_var")

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: seqnum variables - tool list

The last sequence number of the automatic count you find in $mom_seqnum.

Re: seqnum variables - tool list

[ Edited ]

Good morning , thanks for reply but this is not what iam looking for.

 

I know about mom_seqnum , which is equal current block number, yes, thats why I named forum topic "seqnum " Smiley Happy 

 

My problem is that I built long custom procedure that collects the tool data from NX and pastes it into the header H. code , but I have to count it all up in the sequence that is required on the machine. 

 

Ok, I will try to describe my problem again , sorry if I explained something wrong before.

 

; This is hard code counting from P1 till P10
; This a .H code header, it will apears only once

=============

P1     BEGIN PGM COUNT MM
P2     ; -------------------
P3     ; START AUTO BLK FORM
P4     BLK FORM 0.1 Z X-100 Y-100 Z-50
P5     BLK FORM 0.2 X100 Y100 Z0
P6     TOOL CALL 0 Z S
P7     LBL 1
P8     Z+110 R F4000 M06
P9     L X+0 Y+0 R0 F M09
P10   LBL 0

=============

; MOM_set_seq_OFF
; Now I need to stop AUTO counting, becouse TOOL LIST proc. is on


START TOOL LIST PROCEDURE

N12 TOOL DEF 4 L0 R+7.5    (tool data from nx with TRUE: 100 = $mom_seqnum)
N13 TOOL DEF 6 L0 R+7.5    (tool data from nx with TRUE: 235 = $mom_seqnum)
N14 TOOL DEF 2 L0 R+3       (tool data from nx with TRUE: 357 = $mom_seqnum)
N15 TOOL DEF 5 L0 R+4       (tool data from nx with TRUE: 457 = $mom_seqnum)

; If you see true block numbers in brackets , this is why I need to count it in another way

; After end of collecting procedure i still type MOM_set_seq_OFF,

; Ok, now In this case I get last value as N15

; I want to save this last value = 15 and put it into next variable (can be named as last_var)
; Problem is that i cant catch this value = 15 , It only remembers the start value
; In another case it can be N25 , or N32 , it depends how many tools are in use in NX operations


; This is my "little" part of the tool list procedure :

 

==== proc.tool.list.start

global num blok
set num_blok 11

==== proc.tool.list

global num_blok
set num_blok [expr {$num_blok + 1}]
MOM_output_literal "N$num_blok TOOL DEF $mom_tool_number $tool_data "

====proc.tool.list.end

 

Output is like a loop , N12 , N13 , N14 , N15 ..

HOW CAN I SAVE THIS LAST VALUE - N15 ??
I trying use Lappend/tcl , Lindex/tcl and Catch/tcl , but doesnt work Smiley Sad

......
......
......

; rest of Code below , actually started counting from 100 with frequency at 1
; MOM_reset_sequence 100 1 1
; MOM_set_seq_on

100 ; Path Name : INTERP_ZX
101 ; Tool Number: 4
102 ; Tool Name : FI16K Tool Diameter: 16.000 Tool Length: 75.000
103 ; Unactive : TOOL DEF T4 L0 R0
104 TOOL CALL 4 Z S2500
105 L X-164.873 Y-3 R0 F MAX M13
106 L Z9.56 F MAX
107 L Z-1.712 F MAX
108 CC X-157.006 Z-0.255
109 C X-155.549 Z-8.121 DR- F1500
110 CC X-77.015 Z-407.401
111 C X1.018 Z-8.023 DR+
112 L X1.55 Z-8.121
113 L Y-6
114 L X1.014 Z-8.022
115 L X-7.961 Z-6.37
.....

 

I will be very grateful for some hint, best regards

========================================
Engineering >> NX10.0 Performance in the making

Re: seqnum variables - tool list

You already have it - "num_blok"

You might need to increment it by one.

 

Is the tool list procedure run at the place where the tool list is inserted ("Start of program" event) or is it run after the posting is done ("end of program" event)?

 

Is it run as a separate post, or just run as a function?

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: seqnum variables - tool list

[ Edited ]

Hello Ken, thanks for tip  Smiley Happy

 

Yes, TOOL_LIST proc. is inserted in start event, and in end of program event - it works as loop (watch attached JPG). All data is generated to external file (PTP) and finaly output to target .H

 

I attach a picture of the post schematic from PB - how it works .

 

Now the problem is when I try to load $num_blok after loop  - it always output the first count of tool list, so if mathematic sequence is {n+1}  , when {n} start value is 11 , he puts 12 when PB_CMD_LOAD_numblok work.

 

Still cant get last value of last tool . This is not so easy but possible to achieve Smiley Happy

 

Best regards

========================================
Engineering >> NX10.0 Performance in the making
Solution
Solution
Accepted by topic author CamExplorer
‎07-06-2017 06:42 PM

Re: seqnum variables - tool list

OK, so if I understand correctly...

- PB_CMD_TOOL_LIST

writes something to the output file to say "put the tool list here"

- while the post runs thru the operations, it accumulates data for the tool list (output to .ptp file)

- in "end of prorgram", PB_CMD_TOOL_LIST_END inserts the data from the PTP to the H file

 

If  this is the case, then (as you know) PB_CMD_TOOL_LIST does NOT know the number of tools, hence the number of lines (PB_CMD_TOOL_LIST_END does, but that doesn't help you at "PB_CMD_LOAD_numblok")

 

If you keep this architecture, you would have to manually re-assign blck numbers to the rest of the program (not a good option)

 

There are a couple options

1) Create the tool list using a "Shop Docs" tpl file
2) Create the tool list using a separate "tool list only" post

 

Personal preference is to use (2), as option (1) can cause issues with (mom_* variables get changed/reset by the shop docs code).  If run as a separate post, the mom_* variables do not get altered.

 

To implement (2)

A) create a SEPARATE post (I started w/ post builder, then strip out as much as I could using PB, then, eventually, just editing the .def & .tcl files).  This post should ONLY output the "tool list" lines (WITHOUT block numbers), and NOTHING else.

B) "set mom_seqnum 11"     ;# or maybe 10 or 12?

C) "MOM_set_seqno_ON"

D) Use MOM_run_postprocess (in PB_CMD_TOOL_LIST) to run the post & create the "PTP" file

E) After that runs, use "regular" tcl code to open the "PTP" file, and loop thru the lines

F) ---for each line in PTP file, use "MOM_output_literal" to write that line to H file

G) use regular code to close & delete the "PTP" file

 

Block numbers should be output in correct number sequence, and later output will be correct.

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: seqnum variables - tool list

[ Edited ]

Hello again,

Ken - many thanks for valuable tips about MOM_run_postprocess, mayby this will be a solution for this problem.

 

Iam thinking about next idea to achieve proper sequence Smiley Happy Mayby this will be easier

 

{L0} is output in tool list as you see before:

 

12 TOOL DEF 4 L0 R+8
13 TOOL DEF 5 L0 R+8
14 TOOL DEF 3 L0 R+12.5
15 TOOL DEF 22 L0 R+4
16 TOOL DEF 23 L0 R+4
17 TOOL DEF 0 L0 R+3

 

In PB_CMD_before_output , how can i count repeated words named as {L0} ? ? ?

I tried to use 

regexp -all {\yL0\y} 

 

if I would know how many times {L0} will be outputed I could set {L0} count number to: mom_seqnum

And I would have a solution ofc. Smiley Happy

 

Best regards

 

 

 

========================================
Engineering >> NX10.0 Performance in the making
Solution
Solution
Accepted by topic author CamExplorer
‎07-06-2017 06:41 PM

Re: seqnum variables - tool list

The problem (with your current architecture) is that at "PB_CMD_num_blok", the DATA YOU NEED DOES NOT EXIST. (if you can't count the sequence numbers, you can't count the "L0"s either).

 

It is not available until "end of program" event.

 

So you either have to:

- reset all sqeuence numbers once you know what they are (end of program event, when you know the data you need)

or...

- do something else (shop docs, separate post, etc.) so the required data exists when you need it.

 

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