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:

Peter - Avivi CNC Solutions

Verified Members
  • Posts

    292
  • Joined

  • Last visited

Posts posted by Peter - Avivi CNC Solutions

  1. 1 hour ago, Zaffin_D said:

    Use a stack?

    Yeah, stack(s)! Just forgotten, even if I used them :)

    AFAIK stack is limited to numbers only (no strings), but still they very useful.

     

    1 hour ago, Zaffin_D said:

    But, to write a stack to a file you need a buffer so it may not work for your application.

    No, stack is a standalone stuff and you can define as many as you wish.

     

    1 hour ago, Zaffin_D said:

    I’m not sure why stacks aren’t used more often by post developers.

    I did! :) I use stacks to collect tool H/D numbers.

  2. Without knowing what your C-Hook does, I have the feeling that you have way more tools to manipulate text/NC file via C-Hook instead of a simple buffer. I've developed a NET-Hook for CIMCO MachSim and it has the option to manipulate everything outside of post, but still injects lines into NC code.

    JM2C

     

    Or you can try to figure out which buffer is a string buffer and re-use it for your purposes. Perhaps.

  3. On 5/27/2020 at 4:00 PM, Roger Martin from CNC Software said:

    A simple C++/CLI project that creates an interop DLL that your NET-Hook add-in can use would be simple to create.
    I have such a project.

    It appears you are looking for these data items in each operation -
    Operation Name (comment)
    Operation ID (number)
    Operation Type ("type" code)
    Operation Tool Number (and probably also the Tool Slot Number)
    “Toolpath Visibility” status
    “IsDirty” status
    “Selected” status
    “Posting” status (Is the operation ghosted?)
    *Are there more?

    Hi Roger,

    are you passing all the data as an array from C++/CLI to managed NET-Hook? I use similar approach to expose some Chook functions which are not available in NET-Hook, but I only pass some values, strings. I use Text.StringBuilder in one case to receive a list of Stock Model (operations) names.

    Is there a better approach and/or better for multiple data like this example above?

    TIA, Peter

  4. 7 minutes ago, machineimpossible said:

    Thank you. I will look into this more in the future. What I find strange is that using Manual entry "as comment" already works as I like, starting a new comment in the code for each end of line in the input box. But I can't seem to find in the .pst why it is treating the group comment box differently than the manual entry box

    Manual entry and group comment are different animals. If you OK with Manual Entry as first OP, go for it.

    It might will be mixed up if your first (technically second in the OP list) machining operation has a comment, then it might will be mixed with first Manual Entry OP...

  5. Just came across in this topic, so...

    Use semicolon ";" or "enter/EOB" in group comments as "separator"

    pGroupComment
    		sav_spc = spaces$
    		spaces$ = zero
    		sTL_Name = groupinfo(19111)
    		sTL_String = sTL_Name
    		#
    		#"Input:", *sTL_Name, e$
    		#
    		while zero <> strstr(";", sTL_Name) | zero <> strstr(no2asc(13), sTL_Name),
    		[
    			if zero <> strstr(";", sTL_Name), sTL_HolderName = brksps((strstr(";", sTL_Name)), sTL_Name)
    			else, sTL_HolderName = brksps((strstr(no2asc(13), sTL_Name)), sTL_Name)
    			sTL_String = sTL_Name
    			sTL_Name = sTL_HolderName
    			
    			#Remove semicolon
    			if strstr(";", sTL_Name) = one,
    			[
    				sTL_Name = brksps(two, sTL_HolderName)
    				sTL_HolderName = sTL_Name
    			]
    			
    			#Remove EOB
    			if strstr(no2asc(13), sTL_Name) = one,
    			[
    				sTL_Name = brksps(three, sTL_HolderName)
    				sTL_HolderName = sTL_Name
    			]
    			
    			#Output current line from Group comment
    			sopen_prn, sTL_String, sclose_prn, e$
    		]
    		#Output last line
    		if strlen(sTL_Name) <> zero, sopen_prn, sTL_Name, sclose_prn, e$
    		spaces$ = sav_spc

     

    Or check my Note2Post stuff: https://www.youtube.com/watch?v=SBOgD3HoV60

    • Like 1
  6. 9 minutes ago, 5th Axis CGI said:

    Peter, it is good to see you around. I hope your doing well. Thanks for getting Jeff to share more information.

    Jeff, thank for coming and and filling in more blanks. Now if I can every find time to decipher all of this then that would be great. 🙄

    Thank you Ron ;) I would hangin' around more here, but... :S 

     

    5 minutes ago, jeff.D said:

    Under some circumstances (the enhanced tool table being one of them) populating a parameter table uses opinfo; so rather then typing opinfo a bunch of times, you can use a parameter table to minimize typing.

    The NCI line should be your last resort.  The parameters are stored in a table and that makes it very quick to obtain the data.  When you query an NCI line you are starting the the top of the file and reading every line until the data is found.  On top of searching the NCI file, in most cases you need to parse the resulting string, adding more overhead to the process.

    Thank you Jeff, great added infos. Well, you know, I would expect that CNC doing some improvements and new functions for a (good) reason, like speed up posting :) As we both see, it not always the case ;)

    Processing time is on the second place for me, very close right after the first place :) 

    • Like 1
  7. 27 minutes ago, jeff.D said:

    Why write everything to buffer one?  It would be much more efficient to handle all the output in the ptooltable$ post block.

    I'm outputting all "D" and "H" values for each tool (if more than 1 D/H value used, like  T1 - D1, D51, H1, H51), that's one of the reasons. ;) ptooltable$ is limited for me, it "runs" only once.

    At the end of your post I've got lost :) So what should I use to achieve the same? Parameter table, opinfo query or parameter read?

    What's the difference between opinfo(20001, 0) and opinfo(10094, 0)? The "invalid" return has been tested (also for string return), it returns "-99999" if something goes wrong.

    z_min$ and z_max$ works well, I dunno' why you wouldn't expect that. I use this tooltable setup more than 70 posts, zero issue until now.

     

    Thank you for your notes and all input,

    Peter

  8. Mastercam 2019 tooltable, using x_tooltable$ function, buffers, stacks and postblocks with parameters.

     

    Region of buffer, stack and variables declaration:

    #region Buffers and variables for new tooltable
    #--------------------------------------------------------------------------
    # Buffer - 1 TOOL DATA BUFFER
    #--------------------------------------------------------------------------
    b1_Index            : 1     # Buffer 1 - Index
    b1_ToolNo           : 0     # Buffer 1 - Tool number
    b1_ToolDia            : 0        # Tool diameter
    b1_ToolCornerRad    : 0        # Tool corner radius
    b1_ToolTipAngle        : 0        # Tool tip angle
    b1_ToolType            : 0        # Tool type (mill, drill)
    b1_ToolStickOut        : 0        # Tool stickout from holder
    b1_ToolLenOffs      : 0     # Buffer 1 - Tool length offset
    b1_ToolDiaOffs      : 0     # Buffer 1 - Tool diameter offset
    b1_ToolCompType     : 0     # Buffer 1 - Cutter compensation - 0=Computer, 1=Control, 2=Wear, 3=Reverse Wear, 4=Off
    b1_PlaneOffsetNo    : 0        # Buffer 1 - Tool plane number
    b1_Zmax                : 0        # Buffer 1 - Tool Z maximum value by operation
    b1_Zmin                : 0        # Buffer 1 - Tool Z minimum value by operation
    rc1                 : 1
    wc1                 : 1
    size1               : 0
    fbuf 1 0 13 0 0
    sbufname1$ = "D:\buffer_file_ToolData.txt"
    
    # --------------------------------------------------------------------------
    # Buffer - 3 TOOL NAME
    # --------------------------------------------------------------------------
    rc3             : 1
    wc3             : 1
    size3           : 0
    fbuf 3 0 255 0 1
    sbufname3$ = "D:\buffer_file_ToolName.txt"
    
    
    # TooNumber follow up stack #1
    t_1    : 0            # first field in record
    fstack 1 1 0      # define stack #1 with 1 field per record
    
    # LengthOffset follow up stack #2
    h_1    : 0            # first field in record
    fstack 2 1 0      # define stack #2 with 1 field per record
    
    # DiameterOffset follow up stack #3
    d_1    : 0            # first field in record
    fstack 3 1 0      # define stack #3 with 1 field per record
    
    
    # --------------------------------------------------------------------------
    s_ToolName        : ""
    fszamlalo        : 0
    b1_MaxZout        : 0
    b1_MinZout        : 0
    temp_size        : 0
    temp_s_size        : 0
    temp_counter    : 0
    temp_s_counter    : 0
    temp_counter_2    : 0
    prev_ToolNumber    : 0
    ToolOut            : yes$
    OffsOut            : yes$
    FirstOffs        : yes$
    sspace            : " "
    separatorline    : "---------------------------------------------------------"
    
    fmt    "T"        4    b1_ToolNo
    fmt    "H"        4    b1_ToolLenOffs
    fmt    "D"        4    b1_ToolDiaOffs
    fmt    "Zmax:"    2    b1_MaxZout
    fmt    "Zmin:"    2    b1_MinZout
    fmt    "Dia:"    2    b1_ToolDia
    fmt    "Rad:"    2    b1_ToolCornerRad
    fmt    "L:"    2    b1_ToolStickOut
    fmt    "Ang:"    2    b1_ToolTipAngle
    #endregion

     

    Region of al tooltable postblocks:

    #region NEW Tool table output
    # --------------------------------------------------------------------------
    # Tool Table
    # --------------------------------------------------------------------------
    ptooltable$
            #
            b1_ToolNo = tt_tool$
            sparameter$ = opinfo(1013, 0)
            b1_ToolDia = rparsngl(sparameter$, 2)
            b1_ToolCornerRad = rparsngl(sparameter$, 3)
            sparameter$ = opinfo(20007, 0)
            b1_ToolStickOut = rparsngl(sparameter$, 12)
            b1_ToolLenOffs = tt_tlngno$
            sparameter$ = opinfo(20004, 0)
            b1_ToolType = rparsngl(sparameter$, 2)
            b1_ToolTipAngle = rparsngl(sparameter$, 8)
            b1_ToolDiaOffs = tt_offset$
            b1_ToolCompType = tt_cc_pos$
            b1_PlaneOffsetNo = tt_workoffs$
            b1_Zmax = z_max$
            b1_Zmin = z_min$
            b1_Index = wbuf(one, wc1)
            b1_Index = b1_Index + one
            #
            if opinfo(20001, 0) <> -99999, s_ToolName = opinfo(20001, zero)
            s_ToolName = wbuf(three, wc3)
            #
    
    
    pToolTable_NEW
            size1 = rbuf(one, zero)
            rc1 = one
            rc3 = one
            prev_ToolNumber = m_one
            #
            no_spc$, sopen_prn, no_spc$, separatorline, no_spc$, sclose_prn, e$
            #
            #Write tool table
            while rc1 <= size1,
            [
                b1_Index = rbuf(one, rc1)
                s_ToolName = rbuf(three, rc3)
                #
                #Check tool output (toolnumber in stack)
                pCheckToolInList(b1_ToolNo, !ToolOut)
                #
                if ToolOut,
                [
                    if b1_ToolType > 9, no_spc$, sopen_prn, *b1_ToolNo, pToolNoSpace, no_spc$, ":", *s_ToolName, pToolCommSpace, *b1_ToolDia,
                                pCornRadOut(b1_ToolCornerRad), pZminOut(b1_ToolNo, rc1), pAllHOut(b1_ToolNo, rc1), pAllDOut(b1_ToolNo, rc1), sclose_prn, e$
                    else, no_spc$, sopen_prn, *b1_ToolNo, pToolNoSpace, no_spc$, ":", *s_ToolName, pToolCommSpace, *b1_ToolDia,
                                pZminOut(b1_ToolNo, rc1), pAllHOut(b1_ToolNo, rc1), pAllDOut(b1_ToolNo, rc1), sclose_prn, e$
                    #Put toolnumber into #1 stack
                    t_1 = b1_ToolNo
                    t_1 = push(one, result)
                ]
            ]
            #
            no_spc$, sopen_prn, no_spc$, separatorline, no_spc$, sclose_prn, e$
    
    
    pCheckToolInList(ToolNo, OutPutTool)
            temp_size = pop(one, result, zero)
            temp_counter = one
            OutPutTool = yes$
            #
            while temp_counter <= temp_size,
            [
                t_1 = pop(one, temp_counter, five)
                if ToolNo = t_1, [OutPutTool = no$, temp_counter = c9k]
                temp_counter = temp_counter + one
            ]
    
    
    pZminOut(ToolNo, ResetCounter)
            temp_size = rbuf(one, zero)
            temp_counter = one
            b1_MinZout = c9k
            #
            while temp_counter <= temp_size,
            [
                b1_Index = rbuf(one, temp_counter)
                if ToolNo = b1_ToolNo, if b1_MinZout > b1_Zmin, b1_MinZout = b1_Zmin
            ]
            #
            *b1_MinZout
            #
            #Reset buffer values by re-read them:
            b1_Index = rbuf(one, (ResetCounter - one))
    
    
    pAllHOut(ToolNo, ResetCounter)
            temp_size = rbuf(one, zero)
            result = pop(two, m_one, four)
            temp_counter = one
            FirstOffs = yes$
            #
            sdelimiter,
            #
            while temp_counter <= temp_size,
            [
                b1_Index = rbuf(one, temp_counter)
                if ToolNo = b1_ToolNo,
                [
                    pCheckStack(b1_ToolLenOffs, two, !OffsOut)
                    #
                    if not(OffsOut),
                    [
                        if not(FirstOffs), [no_spc$, ","]
                        #
                        *b1_ToolLenOffs,
                        #
                        h_1 = b1_ToolLenOffs
                        h_1 = push(two, result)
                        FirstOffs = no$
                    ]
                ]
            ]
            #Reset buffer values by re-read them:
            b1_Index = rbuf(one, (ResetCounter - one))
    
    
    pAllDOut(ToolNo, ResetCounter)
            temp_size = rbuf(one, zero)
            result = pop(three, m_one, four)
            temp_counter = one
            FirstOffs = yes$
            #
            while temp_counter <= temp_size,
            [
                b1_Index = rbuf(one, temp_counter)
                if ToolNo = b1_ToolNo & b1_ToolCompType > zero,
                [
                    pCheckStack(b1_ToolDiaOffs, three, !OffsOut)
                    #
                    if not(OffsOut),
                    [
                        if FirstOffs, sdelimiter
                        if not(FirstOffs), [no_spc$, ","]
                        #
                        *b1_ToolDiaOffs,
                        #
                        d_1 = b1_ToolDiaOffs
                        d_1 = push(three, result)
                        FirstOffs = no$
                    ]
                ]
            ]
            #Reset buffer values by re-read them:
            b1_Index = rbuf(one, (ResetCounter - one))
    
    
    pCheckStack(OffsNo, StackNo, StackValue)
            temp_s_size = pop(StackNo, result, zero)
            temp_s_counter = one
            StackValue = no$
            #
            while temp_s_counter <= temp_s_size,
            [
                result = pop(StackNo, temp_s_counter, five)
                if OffsNo = result, [StackValue = yes$, temp_s_counter = c9k]
                temp_s_counter = temp_s_counter + one
            ]
    
    
    pZmaxOut(ToolNo, ResetCounter)
            temp_size = rbuf(one, zero)
            temp_counter = one
            b1_MaxZout = c9k * m_one
            #
            while temp_counter <= temp_size,
            [
                b1_Index = rbuf(one, temp_counter)
                if ToolNo = b1_ToolNo, if b1_MaxZout < b1_Zmax, b1_MaxZout = b1_Zmax
            ]
            #
            *b1_MaxZout
            #
            #Reset buffer values by re-read them:
            b1_Index = rbuf(one, (ResetCounter - one))
    
    
    pCornRadOut(Rad)
            if Rad > zero, *b1_ToolCornerRad
    
    
    pToolNoSpace
            sav_spc = spaces$
            spaces$ = zero
            if b1_ToolNo < 10, sspace
            spaces$ = sav_spc
    
    
    pToolCommSpace
            sav_spc = spaces$
            spaces$ = zero
            temp_counter_2 = strlen(s_ToolName)
            temp_counter = one
            while temp_counter <= (30 - temp_counter_2),
            [
                sspace
                temp_counter = temp_counter + one
            ]
            spaces$ = sav_spc
            sdelimiter
    
    #endregion

     

    Add these lines to pheader$ postblock:

    pheader$         #Call before start of file
          x_tooltable$ = one
          x_tooltable$
          pToolTable_NEW
        

     

    • Like 2
  9. 16 hours ago, jeff.D said:

    If you use Mastercam 2017 or later, there is a much better (easier/cleaner/faster) way to do this. 

    I would recommend you explore the new options CNC Software has introduced before implementing the code snippet in this thread.

    Yepp, my original post is from 2012. Mastercam X7, I think.

     

    15 hours ago, opcode said:

    Hi,Jeff,

           Thanks,I will study 2017 .

     

    Go for 2019 if you can. See my next post here:

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...