Hello Guest it is April 19, 2024, 01:45:32 AM

Author Topic: Mach3 script conversion into macros for Mach4  (Read 1568 times)

0 Members and 1 Guest are viewing this topic.

Mach3 script conversion into macros for Mach4
« on: September 29, 2021, 06:01:22 PM »
as the title suggests I would need to convert these scrips into macros for Mach4.
it is possible to do?
thanks in advance for help!

Offline Bill_O

*
  •  563 563
    • View Profile
Re: Mach3 script conversion into macros for Mach4
« Reply #1 on: September 29, 2021, 06:07:43 PM »
Take some time and do it yourself.
In the long run you will probably want to change some things yourself.
Here is a link to a LUA for dummies for Mach4
It might help.
Use the one halfway down the page.

https://www.machsupport.com/forum/index.php?topic=43260.msg279695#msg279695
Re: Mach3 script conversion into macros for Mach4
« Reply #2 on: September 30, 2021, 03:55:38 AM »
I thank you for your advice, unfortunately I am not able, I work metal, I am not a programmer.
Re: Mach3 script conversion into macros for Mach4
« Reply #3 on: September 30, 2021, 04:14:13 AM »
Hi,
Bill_O is right, you really must learn the basics of Lua, when you do you'll realise just how powerful it is and therefore how powerful Mach4 is.

There are several areas which form the learning curve.

The first tip is to use various scripts and macros that are shipped with Mach4....they are examples of how things work. Often its a matter of selecting
one or more chunks of code and combining and editing them to meet your own particular need.

First there is Lua itself....and that is best researched and understood  with this:
https://www.lua.org/manual/5.3/

Take particular attention of the 'scope' of a function or variable, the principle of a 'function as a first class value', and the structure and use of
tables in Lua. Lua has ONLY one data structure, the table, and despite its apparent simplicity it can be extended to do things that are difficult
to do in much more powerful languages like C. A perfect example of this is the text functions of Lua. Most computer languages use some
variant of POSIX compliant text functions, whereas Lua has an apparently small set of such functions. Despite that you can combine what Lua functions
there are to achieve anything a POSIX compliant text function set can do, but instead of being 5Mbyte of code Lua's code is less than 500kByte.

'Function as a First Class variable' is another critically important concept, and is very cleverly used in Mach4. In addition it allows you to make a state
variable function, which is bloody hard to do in many other supposedly better languages.

The next area that might at first seem strange is Machs API, the full listing is in Mach4Hobby/Docs/MachCore4API.chm. Using the APIs contained therein you can
do almost anything in Mach. The APIs are each the means that a user can direct Machs core to do certain things......no SDK or other BS, just one complete
API. Note that all APIs have at least one output called 'rc' or return code, and that will signal the success or otherwise of the function (API) call.
It's tedious to test each and every rc but MAN does it help track down code bugs!

As an example take this API:
Code: [Select]
LUA Syntax:
value, rc = mc.mcCntlGetValue(
number mInst,
number valId,
number param)

Description:
Get the value of a core variable.

Note that the function has two outputs, 'value' and 'rc'. If you follow the Lua reference manual you'll see that multiple outputs of a function come
about because the function itself is a table. Notice also that the syntax of ALL APIs is prepended by a 'mc.', so ALL Machs APIs, ENUMS and more
are ALL entries in a mega table called 'mc'. Very clever indeed.

There are other namespaces like 'scr.' meaning screen, which is another table of function related to the screen GUI. Its not one I use a great deal,
there are usually superior mc. APIs that achieve the same goal.

There is one namespace or table that you will over time have to come to terms with and thats the 'wx.' table, short for wxWidgets. Its responsible for
all the screen text boxes, file dialogs and so on. I personally find wxWidgets to be difficult to follow. The reference manual is here:
https://www.wxwidgets.org/docs/
Its written by geeks, for geeks and written in geekese, despite being complete and accurate! I have found this is where I use built-in Mach scripts
to learn and understand wxWidgets. Another good tool is wxFormBuilder, its a software suite that allows you to generate good wxWidget code and
if you invest the hours you will come to appreciate its power and flexibility.

Quote
I thank you for your advice, unfortunately I am not able, I work metal, I am not a programmer.

You may not think of yourself as a programmer....that's why Lua was chosen as a scripting language....so that metal workers, and hey, metal workers
are skillful even if they don't believe in their own abilities as programmers, can customise their machine to do anything they want. If you choose NOT to learn
the rudiments of Lua, Machs API and structure you'll severely limit what Mach4 can do for you.

Craig

'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach3 script conversion into macros for Mach4
« Reply #4 on: September 30, 2021, 04:27:45 AM »
Again, I don't know anything about programming!
i am european, i like the sport of football.
Although I am aware that I will never be a footballer.
Re: Mach3 script conversion into macros for Mach4
« Reply #5 on: September 30, 2021, 04:43:31 AM »
Hi,
and yet you asked how to transform Mach3 scripts into Mach4 scripts...did you not think that might involve some programming?
Mach4 is great but its not magic.

99% of Mach4 is ready, complete and ready to use, and so if you choose to do no programming you can still do all the basics, but if you want a little
more, say an extra LED on screen to tell you if the pump is running, or maybe an alarm for each axis so you know where to look......then you'll
have to do a little coding of your own.

You might be tempted to imagine that because you need or want your machine to behave in this particular way that everyone wants the same....they
don't. The real power of Mach4 is that it can so simply be customized to your requirement. I use 'simple' to reflect that the extra code and/or code
edits are simple by and large, not that they are easy to contemplate and enact, at least at first.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach3 script conversion into macros for Mach4
« Reply #6 on: September 30, 2021, 06:38:59 AM »
I try to formulate the question differently ..
in MTC mode is it possible to have a master tool as an initial reference?
so that each subsequent tool references the first tool by updating the part zero?

Offline Bill_O

*
  •  563 563
    • View Profile
Re: Mach3 script conversion into macros for Mach4
« Reply #7 on: September 30, 2021, 08:45:21 AM »
daniba73,

I am not a programmer either.
I make machines.
That is why as I learned how to do things I made the Mach4 LUA for dummies.
It is for us non programmers.

If you want custom things in Mach3 or Mach4 you have to learn how to do it and write it.

Start with little things and learn how.

Bill

Offline smurph

*
  • *
  •  1,546 1,546
  • "That there... that's an RV."
    • View Profile
Re: Mach3 script conversion into macros for Mach4
« Reply #8 on: September 30, 2021, 03:52:31 PM »
I try to formulate the question differently ..
in MTC mode is it possible to have a master tool as an initial reference?
so that each subsequent tool references the first tool by updating the part zero?

If I understand you correctly, that depends entirely on how you setup your tool table.  No scripting required.  If every tool is an offset of tool #1, then that is what you get.  Even in manual tool change mode.  Remember, you still have to call out G43 after the tool change though. 

Steve
Re: Mach3 script conversion into macros for Mach4
« Reply #9 on: September 30, 2021, 04:12:37 PM »
I have already pointed out that I am unable to do this.
patience does not matter, it will mean that I stay at Mach3.
thanks anyway.