post processor scripting variable output formatting


Results 1 to 15 of 15

Thread: post processor scripting variable output formatting

  1. #1
    Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    73
    Downloads
    0
    Uploads
    0

    Default post processor scripting variable output formatting

    Hi All,

    I'm trying to build a custom post processor to use with BobCad V30 for a machine that uses it's own g-code format. I'm having trouble getting some variables to output in the correct format.

    I need to output the variables in x.xxxx format, but the post processor keeps dropping the zeros and even the decimal point if the value is a whole number.

    Code:
    53. Line feed move XY.
       n," ",feed_move," XB",prev_x,"A"," YB",prev_y,"A"," ZR",zr,"A"," ZB",z_f,"A"," XE",x_f,"A"," YE",y_f,"A"," ZE",z_f,"A"," ",g_code_cc,cc," F",feed_rate," ",z_feed_rate," D",tool_diameter," ",t,program_block_8
    
    64. Arc move XY.
        n," ",g_arc_move,program_block_9," ZR",zr,"A"," ZB",z_f,"A"," XE",x_f,"A"," YE",y_f,"A"," ZE",z_f,"A"" ",xcenter,"A ",ycenter,"A ",zcenter,"I ",g_code_cc,cc," F",feed_rate," ",z_feed_rate," D",tool_diameter," ",t
    
    2008. Program Block 8. store x y end values from g101 moves
        xb = MILL_GetXFeed()
        
        yb = MILL_GetYFeed()
    
    2009. Program Block 9. Fix start of arc xy
        MILL_SetReturnString (" XB" & xb & "A" & " YB" & yb & "A")
    So the problem is actually line 64. I intended to use "prev_x" & "prev_y" instead of "program_block_9" (similar to line 53), but the output on arc moves was some insane value that made no sense (I assume background computations that overwrite the "prev" values). so I grab the x/y values from the last linear feed modes using program block 8 and output them in line 64 using program block 9.

    output needs to be
    Code:
    N5 G101 XB-0.5000A YB+1.0100A ZR+0.1000A ZB-0.5000A XE+0.5000A YE+1.0100A ZE-0.5000A TC2 F45.0 FZ22.5 D0.5000 T01;
    
    N6 G102 XB+0.5000A YB+1.0100A ZR+0.1000A ZB-0.5000A XE+0.5100A YE+1.0000A ZE-0.5000A XC+0.5000A YC+1.0000A ZC+0.0000I  F45.0 FZ22.5 D0.5000 T01;
    instead I get
    Code:
    N5 G101 XB-0.5000A YB+1.0100A ZR+0.1000A ZB-0.5000A XE+0.5000A YE+1.0100A ZE-0.5000A TC2 F45.0 FZ22.5 D0.5000 T01;
    
    N6 G102 XB0.5A YB1.01A ZR+0.1000A ZB-0.5000A XE+0.5100A YE+1.0000A ZE-0.5000A XC+0.5000A YC+1.0000A ZC+0.0000I  F45.0 FZ22.5 D0.5000 T01;
    which I think the control will accept, but when the variable equals a whole number I get
    Code:
    N30 G101 XB+1.0000A YB+0.5000A ZR+0.1000A ZB-0.5000A XE+1.0000A YE-0.7500A ZE-0.5000A TC2 F27.0 FZ13.5 D0.5000 T01;
    
    N31 G102 XB1A YB-0.75A ZR+0.1000A ZB-0.5000A XE+0.7500A YE-1.0000A ZE-0.5000A XC+0.7500A YC-0.7500A ZC+0.0000I  F27.0 FZ13.5 D0.5000 T01;
    which the control will not accept.

    Code:
    xb = MILL_GetXFeed()
    xb = round(xb,4)
    does nothing to help.

    Post processor attached.

    Can anyone help me figure this out? Also, Bobcad had a scripting "bible" they put out years ago, but I can't find any sign of it. Can anyone point me to any good resources that will help me better understand bobcad scripting.

    Thanks

    Similar Threads:
    Attached Files Attached Files


  2. #2
    Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    73
    Downloads
    0
    Uploads
    0

    Default Re: post processor scripting variable output formatting

    I might have found an answer:
    Code:
    2008. Program Block 8. store x y end values from g101 moves
        xb = MILL_MakeXString(MILL_GetXFeed())
        
        yb = MILL_MakeYString(MILL_GetYFeed())
    seems to have fixed the problem.

    I'm still going to need help eventually so please stay tuned.



  3. #3
    Member
    Join Date
    Oct 2008
    Location
    United States
    Posts
    65
    Downloads
    0
    Uploads
    0

    Default Re: post processor scripting variable output formatting

    Look up Formatting Post Variable Output. It goes something like this:

    '[3.2L]'post_variable_name or in your case '[.4T]'prev_x

    If prev_x = 8.2
    Then '[5.4T]'prev_x will output 8.2000, '[5.4L]'prev_x will output 00008.2

    I can't remember all the particulars, but this is how it was used in Ver 28 and possible Ver 29.

    Hope this helps!

    Steve
    V28/29 4x Pro, Haas VF-3SSYT, Haas SL-30


  4. #4
    Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    73
    Downloads
    0
    Uploads
    0

    Default Re: post processor scripting variable output formatting

    Quote Originally Posted by Alf0412 View Post
    Look up Formatting Post Variable Output. It goes something like this:

    '[3.2L]'post_variable_name or in your case '[.4T]'prev_x

    If prev_x = 8.2
    Then '[5.4T]'prev_x will output 8.2000, '[5.4L]'prev_x will output 00008.2

    I can't remember all the particulars, but this is how it was used in Ver 28 and possible Ver 29.

    Hope this helps!
    Thanks for the suggestion,

    I had read that before asking my question, but it didn't work. So I later read through all the post processors I have and found an example showing this usage:
    Code:
    "[3T]"variable
    The only difference is the double quotes, but V30 likes it and not the documented method.

    I also found an API called
    Code:
    MILL_MakeRealString()
    that formats the variable output according to the number of decimal places in post settings 414 & 415.
    I have found it to be very useful in that it will automatically account for metric or inch mode.
    Also, I have learned how to use the round command properly.

    My post processor is coming along nicely. It's putting out usable G-code, but still need a lot of refinement.



  5. #5
    Member
    Join Date
    Oct 2008
    Location
    United States
    Posts
    65
    Downloads
    0
    Uploads
    0

    Default Re: post processor scripting variable output formatting

    I did notice in their examples that they use spaces as in ' [3.2L] 'post_variable_name. That's ' [3.2L] ', not '[3.2L]'. I have attached a pic of the Formatting Post Variable Output page I have, hope it helps?post processor scripting variable output formatting-img_2079-jpg

    Attached Thumbnails Attached Thumbnails post processor scripting variable output formatting-img_2079-jpg  
    Steve
    V28/29 4x Pro, Haas VF-3SSYT, Haas SL-30


  6. #6
    Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    73
    Downloads
    0
    Uploads
    0

    Default Re: post processor scripting variable output formatting

    Thanks, I have a PDF of that page. I never noticed the spaces. I assumed it was the font type spacing. I tried it, but I still can't make it work. It also seem the version I mentioned with the double quotes only works with post variables in the regular posting blocks. It doesn't appear to work in scripting blocks.

    You don't happen to know how to update sequence (line) numbers without outputting any code do you?



  7. #7
    Member
    Join Date
    Oct 2008
    Location
    United States
    Posts
    65
    Downloads
    0
    Uploads
    0

    Default Re: post processor scripting variable output formatting

    I suspect your correct that it may only work in regular posting blocks and not scripting blocks, however, the double quote (") should output as straight text, "[3T]" should output [3T] and not be interpreted as formatting a post_variable_name. Not sure how to increment block number without outputting a line unless the n, n_forced and/or seq_only can be used on the left side of equations as in n=n+1.

    Steve
    V28/29 4x Pro, Haas VF-3SSYT, Haas SL-30


  8. #8
    Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    73
    Downloads
    0
    Uploads
    0

    Default Re: post processor scripting variable output formatting

    Quote Originally Posted by Alf0412 View Post
    ...however, the double quote (") should output as straight text, "[3T]" should output [3T] and not be interpreted as formatting a post_variable_name.
    I would think you're correct, but I have for an example is this drilling cycle presumably written by BOBCAD that I found in a post processor for a TRAK DPM milling machine.
    Code:
        n,g_canned_cycle,g98_g99,x_f, y_f,drill_depth,reference_plane,peck_drill_increment,"[1T]"dwell,canned_feed_rate




  9. #9
    Member
    Join Date
    Oct 2008
    Location
    United States
    Posts
    65
    Downloads
    0
    Uploads
    0

    Default Re: post processor scripting variable output formatting

    I have attached a post we use for the HAAS VF3SSYT with HRT-210P3 4th Axis. All references to double quotes output raw text as typed. Could be their code interprets the double quotes differently within a canned_cycle, but I would doubt that.

    Attached Files Attached Files
    Steve
    V28/29 4x Pro, Haas VF-3SSYT, Haas SL-30


  10. #10
    Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    73
    Downloads
    0
    Uploads
    0

    Default Re: post processor scripting variable output formatting

    This line in the post processor
    Code:
    82. Standard drill canned cycle with dwell.	
    	n,g_canned_cycle,g98_g99,x_f, y_f,drill_depth,reference_plane,"[3T]"dwell,canned_feed_rate
    Created this program.
    Code:
    G82 X0. Y0. Z-.25 R.1 P079 F9.2
    1000 = 1 second so 079 = .079 seconds

    Notice the lack of a comma between "[3T]" and dwell. I think that might be the trick. I'm just guessing.
    I still can't figure out how to force a scripting block variable to output to a specific number of decimal places. They seem to ignore all of the rules. I can round up, but I cannot force trailing zeros or even the decimal point if the number is whole.



  11. #11
    Member
    Join Date
    Oct 2008
    Location
    United States
    Posts
    65
    Downloads
    0
    Uploads
    0

    Default Re: post processor scripting variable output formatting

    Yes, absolutely, no comma between '[3T]' or "[3T]" and program_variable_name.

    You will need to format your xb and yb variables in program_block_9 to strings with the proper leading/trailing places you desire. I believe this because you are using the MILL_SetReturnString() function, so your numbers are being passed by vbscript defaults.

    Take a look at the VBScript FormatNumber Function, this may help you format your numbers correctly. Follow this link, https://www.w3schools.com/asp/func_formatnumber.asp, good source for vbscript information.

    Steve
    V28/29 4x Pro, Haas VF-3SSYT, Haas SL-30


  12. #12
    Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    73
    Downloads
    0
    Uploads
    0

    Default Re: post processor scripting variable output formatting

    Take a look at the VBScript FormatNumber Function
    Believe it or not, I didn't know until last night that Bobcad was using Visual Basic Scripting. I was just poking around using what shell scripting commands I could remember from years ago when I tried to learn, that, and from looking at the post processor examples I could get my hands on. Now that I know it's VBS I have the internet full of tutorials to learn from. It's like I'm a child with blurry vision getting my first pair of glasses.

    FormatNumber was the right answer, Thank you.

    I've been spending most of my free time working on this post processor, and it's coming along great. I've been using it all week at work to machine parts. It's fairly reliable at this point, but I do find a bug or two every day. I fix those at home and go back to work and test the next day.

    I've also been working with Advance Posting with custom files. I didn't understand the documentation that came with bobcad until I found this thread posted by aldepoalo. https://www.cnczone.com/forums/bobca...-software.html
    I needed the G98/G99 switch for one of the parts I was making so al's thread saved a tone of time.

    Now that I have the right tools I'm going to see what I can build.



  13. #13
    Member
    Join Date
    Oct 2008
    Location
    United States
    Posts
    65
    Downloads
    0
    Uploads
    0

    Default Re: post processor scripting variable output formatting

    Great, I was getting a little confused because I assumed you realized they were using VB. Your on the right track now, while VB is old it's still able to accomplish whatever your willing to learn. As you can see by the program_block_#'s in the post for our Haas, most are for housekeeping functions, program numbers, filenames, etc.

    Good luck

    Steve
    V28/29 4x Pro, Haas VF-3SSYT, Haas SL-30


  14. #14
    Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    73
    Downloads
    0
    Uploads
    0

    Default Re: post processor scripting variable output formatting

    If I try to run a program block from a script block like this
    Code:
    2030. Program Block 30. Insert G119 Helix to ramp into pocket    opp_type1 = MILL_GetOperationType()
    
    
        if opp_type1 = 202 and hlx_flg = 1 then
            chk_Helix = MILL_GetUserCheckBoxVariable(0)    'Get checkbox 1 setting 0=off 1=on
            Select Case chk_Helix
                Case 1    'if ON build helix & post
                    
                    MILL_ProcessPostLine("n,' ','G119',program_block_31,' D',tool_diameter,' ',s,' ',t")
                hlx_flg = "0"
            End Select
        end if
    
    2031. Program Block 31.
        x_abs = MILL_GetUserEditRealVariable(2)        'Get helix X center
        y_abs = MILL_GetUserEditRealVariable(3)        'Get helix Y center
        zr_abs = MILL_GetUserEditRealVariable(4)    'Get helix Z Rapid
        zb_abs = MILL_GetUserEditRealVariable(5)    'Get helix Z Begin
        ze_abs = MILL_GetUserEditRealVariable(6)    'Get helix Z End
        h_rad = MILL_GetUserEditRealVariable(7)        'Get helix radius
        hs_ang = MILL_GetUserEditRealVariable(8)    'Get helix start angle
        num_rot = MILL_GetUserEditRealVariable(9)    'Get helix number of rotations
        h_dir = MILL_GetUserSelectComboVariable(10) 'Get combobox 11 setting
            h_dir = h_dir + 1    '1=CW 2=CCW
        t_comp = MILL_GetUserSelectComboVariable(11) 'Get combobox 12 setting 0=center 1=right 2=left
        h_zf = MILL_GetUserEditRealVariable(12)        'Get Z feed inches per minute
        h_xyz_f = MILL_GetUserEditRealVariable(13)    'Get XYZ feed inches per minute
    
    
        MILL_SetReturnString(" XC" & x_abs & "A YC" & y_abs & "A ZR" & zr_abs & "A ZB" & zb_abs & "A ZE" & ze_abs & "A R" & h_rad & " A" & hs_ang & " NR" & num_rot & " DR" & h_dir & " TC" & t_comp & " FZ" & h_zf & " F" & h_xyz_f)
    I get redundant output

    Code:
    N2 G119 XC0.6A YC-0.5A ZR0.1A ZB0.03A ZE-0.125A R0.125 A45 NR6.25 DR1 TC0 FZ0.001 F0.003 D0.2500 S4500 T02;
    XC0.6A YC-0.5A ZR0.1A ZB0.03A ZE-0.125A R0.125 A45 NR6.25 DR1 TC0 FZ0.001 F0.003;
    My guess is that calling a program block from inside a program block creates a loop? I don't know.

    any ideas?



  15. #15
    Member
    Join Date
    Oct 2008
    Location
    United States
    Posts
    65
    Downloads
    0
    Uploads
    0

    Default Re: post processor scripting variable output formatting

    Not seeing the entire post processor I can only make the following suggestions:

    1. Make sure that program_block_30 and program_block_31 are only being called up in the appropriate places, this eliminates the possibility that program_block_31 is being inadvertantly called from somwhere else in the post.
    2. I can not determine in program_block_30 where hlx_flg is being passed from.
    3. In program_block_30 alter hlx_flg = "0" to hlx_flg = 0, can't remember if VBScript handles converting string "0" to numerial 0 automatically.
    4. Copy all lines in program_block_31, except the MILL_SetReturnString line and paste into program_block_30 between the Case 1 line and the MILL_ProcessPostLine.
    5. Alter in program_block_30 the MILL_ProcessPostLine to include the variables from the program_block_31 MILL_SetReturnString line.
    6. Now program_block_31 is not needed.
    7. Finally, I'm pretty sure you can now eliminate in program_block_30 the Case statement and use just an If-Then statement.
    8. Don't be afraid to use the MILL_OutputText function if needed (see post processor sent earlier).

    Regards

    Steve
    V28/29 4x Pro, Haas VF-3SSYT, Haas SL-30


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

post processor scripting variable output formatting

post processor scripting variable output formatting