587,006 active members*
2,899 visitors online*
Register for free
Login
Page 1 of 2 12
Results 1 to 20 of 25
  1. #1
    Join Date
    Apr 2018
    Posts
    45

    Scripting help

    Ive installed the new TNG2. I am very happy with everything so far although I do need some help with the scripts. Things have changed and I had to basically rewrite all the scripts I had for the previous TNG. I'm by no means an expert at scripting so some things are hard for me to understand. I need help with these things:
    I created new M codes for 2 park positions that were previously userdefined and had custom buttons. How do i make a button that executes an M code? Second, how do i display parameters on custom tabs. For example Tool info like tool diameter? I played around with the example dialog (guess number) and was working on creating my own dialog for a tool change. Ive managed to add an image to the dialog but id like the background to be transparent but my saved .png with a transparent background displays with a white box around it. Am I missing something? This new TNG2 version is going to be very nice as soon as i finish these few little things. Please help.

  2. #2
    Join Date
    Mar 2017
    Posts
    1327

    Re: Scripting help

    Tutorial for custom buttons is already updated:
    https://planet-cnc.com/adding-user-t...-tng-software/

    Note that instead of "cmd('Machine.Start_Code', 'M900')" you can use simpler "startcode('M900')" command.

    Tutorial for custom tabs is here:
    https://planet-cnc.com/create-custom...-tng-software/

    List of all parameters is in user manual (in know that only list is not enough but it is more that nothing).

    Transparent .png should work. You can send file to me and I'll check what is wrong.

  3. #3
    Join Date
    Apr 2018
    Posts
    45
    Ok, I'll give it a try. I carried over the stat tabs from TNG1 but the syntax appears to be different. Or maybe some of the old parameters do not exist anymore. Would you you be able to send me an example on how the line should be written?

    Also, is there a way to edit what happens on estop? For example i have an output that turns on when the spindle turns on. Its a coolant pump for my water cooled spindle. When a program is running and i hit the estop button in the software, all motion stops, spindle and mist stops but my one output stays on. I'd like estop to kill everything.

    I'll send my image over as soon as i get back to my shop tonight. I created it in inkscape and saved with a transparent background.

    Thank you for all your help.

  4. #4
    Join Date
    Mar 2017
    Posts
    1327

    Re: Scripting help

    Here is state tab that I use for tools:
    Attached Files Attached Files

  5. #5
    Join Date
    Apr 2018
    Posts
    45
    Thank you. This will help a lot. Do you have an answer for the e-stop question?

  6. #6
    Join Date
    Jun 2017
    Posts
    143

    Re: Scripting help

    Quote Originally Posted by yar20 View Post
    Thank you. This will help a lot. Do you have an answer for the e-stop question?
    See posts #12-16 in this thread. https://www.cnczone.com/forums/plane...ns-solved.html

    As that points out EStop is handled by the hardware so no user scripts can be run. I have the same problem as you since my spindle and coolant are all controlled by I2C, so for me estop only stops axis motion which is not ideal.

  7. #7
    Join Date
    Apr 2018
    Posts
    45

    Re: Scripting help

    This might be better under the TNG2 button thread. I am trying to assign a MCode to an output. For example if I want to use MDI to turn on an output which is really quick and easy. I've tried this code in a script file I named M106.gcode

    cmd: "Machine.Outputs.Output_6" "" image="Icons/IMG_Pump.svg" imagechange="true" stroke=1.1 tooltip="Pump"

    This does not work but it is the same line of code that works for my custom button tab.

  8. #8
    Join Date
    Mar 2017
    Posts
    1327

    Re: Scripting help

    You can not "push buttons" and use menu commands from g-code.
    To turn output 6 on use this g-code:
    M62 P6 Q1

  9. #9
    Join Date
    Mar 2017
    Posts
    1327

    Re: Scripting help

    I added EStop event "Outputs Off".
    But for I2C on EStop is there still no solution.

  10. #10
    Join Date
    Apr 2018
    Posts
    45
    Quote Originally Posted by PlanetCNC View Post
    You can not "push buttons" and use menu commands from g-code.
    To turn output 6 on use this g-code:
    M62 P6 Q1
    Ok great. That makes perfect sense now that you explained it that way. I'll give it a try.

  11. #11
    Join Date
    Apr 2018
    Posts
    45
    Quote Originally Posted by PlanetCNC View Post
    I added EStop event "Outputs Off".
    But for I2C on EStop is there still no solution.
    Is this available now? Or do i have to wait for the next update?

    Thank you for doing this, much appreciated.

  12. #12
    Join Date
    Mar 2017
    Posts
    1327

    Re: Scripting help

    You have to wait for update. But I already made and tested this change.

  13. #13
    Join Date
    Apr 2018
    Posts
    45

    Re: Scripting help

    This is the image I was trying to attach to a dialog for manual tool changing. I took the default .svg tool image and imported it into inkscape, saved as .png with a transparent background. Is there a better way?



    This is my code:

    (dlgname,Tool Change)
    (dlg,move to tool change position, typ=label, x=20, w=280, color=0xffa500)
    (dlg,./IMG_Tool_Change.png, typ=image, x=60)
    (dlg,Press OK to begin, typ=label, x=140, w=150, color=0xffa500)
    (dlgshow)

    G20
    M70
    G90 G15
    G53 G00 Z-.1
    G53 G00 X7 Y-18
    M72

    (dlgname,Tool Change)
    (dlg,Continue, typ=label, x=140, w=280, color=0xffa500)
    (dlgshow)



    I'm not finished with it yet, because I want to add the ability to skip the move to tool change position. I haven't figured out how to do this yet.
    Any help would be appreciated. Thanks.

  14. #14
    Join Date
    Mar 2017
    Posts
    1327

    Re: Scripting help

    This image has transparent black color and white is non transparent. Just opposite of what you want.

    I don't understand what you try to skip.

    Also take a look how you incorrectly use M70/M72.
    First I suggest you use just M73 so that you don't have to call M72.
    Second there is no point in storing modal state if you change it just before storing. See G20 before first M70.

  15. #15
    Join Date
    Apr 2018
    Posts
    45
    Im want to be able to have a dialog when a M6 is called that gives the user an option to continue and move to the manual tool change position in my case it is x7 y-18. Or be able to skip the tool change routine and just continue on through the program.

  16. #16
    Join Date
    Mar 2017
    Posts
    1327

    Re: Scripting help

    See "Measure Surface Height" script as an example. It asks for "cmd" parameter (param=cmd) and at the end prints different string based on selected option.

  17. #17
    Join Date
    Apr 2018
    Posts
    45

    Re: Scripting help

    I'm still working on my manual tool change script. It appears that the image is not loaded when called from inside a gcode program but when I enter M6 into the MDI it appears.
    This is my script:

    (dlgname,Tool Change)
    (dlg,./Icons/IMG_Tool_Change.png, typ=image, x=0)
    (dlg,Move to tool change position?, typ=label, x=20, w=280, color=0xffa500)
    (dlgshow)

    G53 Z-.1
    G53 G00 X7 Y-19


    (dlgname,Tool Change)
    (dlg,Continue?, typ=label, x=20, w=280, color=0xffa500)
    (dlgshow)

  18. #18
    Join Date
    Mar 2017
    Posts
    1327

    Re: Scripting help

    "./" in front of image filename means that filename is relative g-code file. This is used in "GuessNumber" example where image is in same folder as g-code file.

    Without "./" in front filename means that filename is relative to profile folder.
    (dlg,MyImages/blah.png...
    Assuming default windows installation blah.png is in folder "C:/Program Files/PlanetCNC/Profiles/Default/MyImages/




  19. #19
    Join Date
    Apr 2018
    Posts
    45

    Re: Scripting help

    A novice mistake. I got it figured out. Thank you.

  20. #20
    Join Date
    Oct 2017
    Posts
    45

    Re: Scripting help

    I also need help with scripts. I don't understand scripts at all. What interests me most is measurement scenarios. Do I need to learn any programming language, if so, which one?


    An example of my misunderstanding:
    o109 - Probe Check
    Checks probe settings


    Syntax
    G65 P109 Q
    Parameters
    Q 0 - Checks probe pins only.
    1 - Checks probe pins and probe type.




    o109 ;Probe Check
    #<_return> = NAN[]
    o<chk> if[LNOT[ACTIVE[]]]
    M99
    o<chk> endif


    o<chk> if[[#<_probe_pin_1> EQ 0] AND [#<_probe_pin_2> EQ 0]]
    (print,Probe pin is not configured)
    M99
    o<chk> endif


    o<chk> if [DEF[#<qvalue>,1] AND [#<_probe_use_tooltable> GT 0] AND [#<_tool_isprobe_num|#<_current_tool>>] EQ 0]
    (print,Current tool is not probe)
    M99
    o<chk> endif


    #<_return> = 0
    M99


    I don't understand how the program makes the choice? 0 — only the sensor contacts are checked.
    1 – Checks the contacts and type of sensor. (in which line?)
    +
    [DEF[#<qvalue>,1] I don't understand this post. What is #<qvalue>?

Page 1 of 2 12

Similar Threads

  1. Scripting
    By Koblenzer in forum BobCad-Cam
    Replies: 1
    Last Post: 12-07-2011, 03:01 PM
  2. V21 scripting help
    By ammfg in forum BobCad-Cam
    Replies: 3
    Last Post: 06-11-2010, 01:29 PM
  3. Scripting
    By Klox in forum BobCad-Cam
    Replies: 29
    Last Post: 10-03-2003, 04:11 AM

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
  •