Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

how to filter duplicates from buffer


Recommended Posts

Hi,

i have two buffers and need to filter duplicates from them.

For example Buffer 1:

20 20 20 20 24 18 18 20

and buffer 2:

2 0 2 0 0 2 0 0

 

I want to filter from buffer 1 only values that match "2" in buffer 2. In this case it is only  numbers 20 and 18 and want to have theese numbers only once in buffer 3.

 

so i wrote this:

 

    zero = wbuf(3,wc3)  # put 0 to buffer 3, no null size buffer
     size1 = rbuf(1, 0)
    while rc1 <= size1,
  [
       toolnumber = rbuf(1, rc1)
    size2 = rbuf(2, 0)
    toolcomp = rbuf(2, rc2)
    if toolcomp = 2,
    rc3 = 1
    size3 = rbuf(3,0)
    while rc3 <= size3,
    [
        toolselect = rbuf(3,rc3)
        if toolnumber <> toolselect,
        toolnumber = wbuf(3,wc3)
    
      ]
    ]

 

and result of this in buffer 3 is : 0 20 20 18 18 18

 

I think, this reads values from buffer 1 and 2, if it match condition "2" than it scan buffer 3 if toolnumber is present, if not it write it to buffer 3 and than "rewind" buffer 3 (rc3 = 1)

 

What is wrong with this code or am i miss something?

Thanks for help.

Link to comment
Share on other sites

#variable definition:

tlpomnumber  : 0

 

#buffer definition:

tlnumber  : 0
size4     : 0
rc4       : 1
wc4       : 1
fbuf 4 0 1 0

tlcutcomp : 0
size5     : 0
rc5       : 1
wc5       : 1
fbuf 5 0 1 0

fmt "" 4 tlvyber     #buffer of non duplicated tool numbers
tlvyber   : 0
size6     : 0
rc6       : 1
wc6       : 1
fbuf 6 0 1 0

 

#new postblock

ptlvyber  #pick up tools with  "WEAR" comp, print into NC

    zero = wbuf(6,wc6)
    size4 = rbuf(4, 0)
    size5 = rbuf(5, 0)
    size6 = rbuf(6, 0)
    while rc4 <= size4,
    [
     tlnumber = rbuf(4, rc4)
    tlcutcomp = rbuf(5, rc5)
    tlpomnumber = tlnumber
    rc6 = 1
    if tlcutcomp = 2,
    [
         while rc6 <= size6,
        [
        tlvyber = rbuf(6,rc6)
        if tlpomnumber = tlvyber,
        tlpomnumber = 0
        ]
    if tlpomnumber <> 0,
    tlnumber = wbuf(6,wc6)
    size6 = rbuf(6, 0)
    ]
    ]
    
    size6 =    rbuf(6, 0)
    rc6 = 1
    while rc6 <= size6,
    [
    tlvyber = rbuf(6, rc6)
    if tlvyber <> 0,
    ";", "TOOL #." tlvyber "COMP. R=0, DR=?", e$       #print this into NC output.
    ]

 

 

 

pwrttparam$

 

    if prmcode$ = 15346,                #stores tzpe of comp into buffer 5
    [
        tlcutcomp = rparsngl(sparameter$,1)
        tlcutcomp = wbuf(5,wc5)
    ]
    if prmcode$ = 10002,                #stores tool number into buffer 4
    [
        tlnumber = rparsngl(sparameter$,1)
        tlnumber = wbuf(4,wc4)
    ]

 

 

 

psof$

 

ptlvyber   #add postblock ptlvyber call into psof$

 

 

This writes list of tools with wear compensation under tooltable...

 

result:

 

 ; T
 ; DATE - 31-03-16
 ; TIME - 09:39
 ; MCX FILE -D:\PRACE\T.MCX-9
 ; NC FILE - D:\NC\T.H
 ; Programmed by: Kominik
110 BLK FORM  0.1 Z X+0.000 Y+0.000 Z+0.000
120 BLK FORM  0.2   X+0.000 Y+0.000 Z+0.000
; T. 20 R:5.00 Cor.rad.:0.50 Overal:80 Code: V.20430049-120
; T. 24 R:1.00 Cor.rad.:1.00 Overal:15 L3=12 Code: 565.200.100.120
; T. 18 R:4.00 Cor.rad.:4.00 Overal:80 Code: V.20430046-120
;( X-MIN= -72.462 )
;( X-MAX= +77.872 )
;( Y-MIN= -96.157 )
;( Y-MAX= +48.642 )
;( Z-MIN= +0.000 )
;( Z-MAX= +50.000 )
; TOOL #20  COMP R=0, DR=?
; TOOL #18  COMP R=0, DR=?

130 TOOL CALL 20 Z S22000
140 TOOL DEF 24
150 L X-72.462 Y-3.720 R0 FMAX M03
160 L Z+25.000 R0 FMAX M9
170 L Z+10.000 R0 FMAX

.

.

.

.

  • Like 1
Link to comment
Share on other sites

#variable definition:

tlpomnumber  : 0

 

#buffer definition:

tlnumber  : 0

size4     : 0

rc4       : 1

wc4       : 1

fbuf 4 0 1 0

 

tlcutcomp : 0

size5     : 0

rc5       : 1

wc5       : 1

fbuf 5 0 1 0

 

fmt "" 4 tlvyber     #buffer of non duplicated tool numbers

tlvyber   : 0

size6     : 0

rc6       : 1

wc6       : 1

fbuf 6 0 1 0

 

#new postblock

ptlvyber  #pick up tools with  "WEAR" comp, print into NC

 

    zero = wbuf(6,wc6)

    size4 = rbuf(4, 0)

    size5 = rbuf(5, 0)

    size6 = rbuf(6, 0)

    while rc4 <= size4,

    [

     tlnumber = rbuf(4, rc4)

    tlcutcomp = rbuf(5, rc5)

    tlpomnumber = tlnumber

    rc6 = 1

    if tlcutcomp = 2,

    [

         while rc6 <= size6,

        [

        tlvyber = rbuf(6,rc6)

        if tlpomnumber = tlvyber,

        tlpomnumber = 0

        ]

    if tlpomnumber <> 0,

    tlnumber = wbuf(6,wc6)

    size6 = rbuf(6, 0)

    ]

    ]

    

    size6 =    rbuf(6, 0)

    rc6 = 1

    while rc6 <= size6,

    [

    tlvyber = rbuf(6, rc6)

    if tlvyber <> 0,

    ";", "TOOL #." tlvyber "COMP. R=0, DR=?", e$       #print this into NC output.

    ]

 

 

 

pwrttparam$

 

    if prmcode$ = 15346,                #stores tzpe of comp into buffer 5

    [

        tlcutcomp = rparsngl(sparameter$,1)

        tlcutcomp = wbuf(5,wc5)

    ]

    if prmcode$ = 10002,                #stores tool number into buffer 4

    [

        tlnumber = rparsngl(sparameter$,1)

        tlnumber = wbuf(4,wc4)

    ]

 

 

 

psof$

 

ptlvyber   #add postblock ptlvyber call into psof$

 

 

This writes list of tools with wear compensation under tooltable...

 

result:

 

 ; T

 ; DATE - 31-03-16

 ; TIME - 09:39

 ; MCX FILE -D:\PRACE\T.MCX-9

 ; NC FILE - D:\NC\T.H

 ; Programmed by: Kominik

110 BLK FORM  0.1 Z X+0.000 Y+0.000 Z+0.000

120 BLK FORM  0.2   X+0.000 Y+0.000 Z+0.000

; T. 20 R:5.00 Cor.rad.:0.50 Overal:80 Code: V.20430049-120

; T. 24 R:1.00 Cor.rad.:1.00 Overal:15 L3=12 Code: 565.200.100.120

; T. 18 R:4.00 Cor.rad.:4.00 Overal:80 Code: V.20430046-120

;( X-MIN= -72.462 )

;( X-MAX= +77.872 )

;( Y-MIN= -96.157 )

;( Y-MAX= +48.642 )

;( Z-MIN= +0.000 )

;( Z-MAX= +50.000 )

; TOOL #20  COMP R=0, DR=?

; TOOL #18  COMP R=0, DR=?

130 TOOL CALL 20 Z S22000

140 TOOL DEF 24

150 L X-72.462 Y-3.720 R0 FMAX M03

160 L Z+25.000 R0 FMAX M9

170 L Z+10.000 R0 FMAX

.

.

.

.

 

Thank you for giving back to the community of Mastercam users worldwide. Have a great day. :thumbsup: :thumbsup: :thumbsup: :thumbsup:

Link to comment
Share on other sites

i just added new postblock to warn programmer when he uses different tool compensation on same tool. If i have already this information stored in buffer, why not to use them :-) It only compare wear vs. control/rev.wear. Not control vs.rev.wear

 

ptlkontrola  #controls if wear / (control | reverse wear) is used with same tool

    rc4 = 1    
    rc5 = 1
    size4 = rbuf(4, 0)
    size5 = rbuf(5, 0)
    size6 = rbuf(6, 0)
    while rc4 <= size4,
    [
    rc6 = 1
     tlnumber = rbuf(4, rc4)
    tlcutcomp = rbuf(5, rc5)
        while rc6 <= size6,
        [
             tlvyber = rbuf(6,rc6)
        if tlcutcomp = 1 & tlnumber = tlvyber,
        [
        result = mprint("WARNING, SAME TOOL USES DIFFERENT COMPENSATION!!!")
        rc4 = c9k
        rc5 = c9k
        ]
        if tlcutcomp = 3 & tlnumber = tlvyber,
        [
        result = mprint("WARNING, SAME TOOL USES DIFFERENT COMPENSATION!!!")
        rc4 = c9k
        rc5 = c9k
        ]
        ]
    ]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...