Welcome to Our Community

Some features disabled for guests. Register Today.

How to use variables in openbuilds macro's?

Discussion in 'CAM' started by Erik HENDRIX 0X, Jan 22, 2022.

  1. Erik HENDRIX 0X

    Builder

    Joined:
    Jan 22, 2022
    Messages:
    7
    Likes Received:
    3
    Is there a way to use variables in an open builds macro, for example to make easy movement calculations based on a variable drill width?

    I have seen some gcode programs declaring variables with e.g. #101 = 8 using them later in e.g. G01 F500 X15+#101 but I can't make it work on my machine.
     
  2. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    15,224
    Likes Received:
    4,349
    You can use the Javacript macro functionality - with it you can even build UIs to enter the values into your variables. See Getting started with Javascript Macros in CONTROL / Library of Macros created by the community

    With string substitution and maths and all the tools you will ever need, much more power than plain gcode.
     
    Erik HENDRIX 0X likes this.
  3. Erik HENDRIX 0X

    Builder

    Joined:
    Jan 22, 2022
    Messages:
    7
    Likes Received:
    3
    Thanks Peter, helps me a lot. Do you happen to know a way to get user input in some way. Prompt() nor ReadLine() are being accepted.
     
  4. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    15,224
    Likes Received:
    4,349
    See the link above for examples using Metro.dialog to build UIs with input forms.
     
  5. Erik HENDRIX 0X

    Builder

    Joined:
    Jan 22, 2022
    Messages:
    7
    Likes Received:
    3
    Thanks again Peter. Took me a while to figure it out ... but it works. Appreciated.
     
    Peter Van Der Walt likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice