Hello Guest it is April 23, 2024, 02:43:21 AM

Author Topic: Script da mach3 a mach4  (Read 892 times)

0 Members and 1 Guest are viewing this topic.

Re: Script da mach3 a mach4
« Reply #10 on: March 23, 2023, 06:00:54 PM »
Hi,
when you want a macro or script to stop and get either a response or data from the operator you are required to use wxWidgets dialogs.
Talk about starting at the hard place first!!!!

wxWidgets is an open source software library that gives you 'windows' type functions. For instance you might want a file  dialog, that is to say a window
that opens with a file directory so you can choose a file to operate on. There are a huge variety of such functions....but I find wxWidgets the hardest thing to
use in Mach4. Note that wxWidgets is not written into Mach4, but rather that Mach4 uses wxWidgets as an imported library. wxWidgets is used by an absolutely huge number
of programs, of which Mach4 is just one....and a small one at that.

The documentation for wxWidgets is superb, it's written for geeks, by geeks and in 'geekese'....you'll come to hate it as I do. If you really want to build your own forms
the best tool to use is called wxFormBuilder. Its an Integrated Development Environment (IDE) and allows you to compose code....but is in itself quite a learning curve.

There are three approaches to this problem:
1) Roll your sleeves up and get stuck into wxWidgets documentation and download and install wxFormBuilder and learn the software as well as is required to achieve the result.
2) Cheat! Find another Mach4 macro that has a wxWidgets dialog that is similar to what you want and copy it. Then you'll have to modify it to match what you want, still a learning curve
but is exactly where I started.
3) Change the macro such that you do not require a wxWidget dialog, of if you do make sure its the exact same as some other dialog that you can copy verbatim.

https://www.wxwidgets.org/

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Script da mach3 a mach4
« Reply #11 on: March 24, 2023, 04:39:40 PM »
Thank you. But I'm terribly frightened by all of this. To hook up a key I have to study a program :(. They could have created at least one team to which to make paid script requests.... too bad!!!.
Re: Script da mach3 a mach4
« Reply #12 on: March 24, 2023, 05:17:30 PM »
HI,
as I said you chose the hardest thing to start with....why? Can you not avoid having to use a wxWidget?
Can you not find an existing wxWidget that does what you want that you can copy?

Presumably if you include an m6() macro call in your Gcode file you want to change tools? Why then do you need to stop and ask the operator?
Is it not redundant?

As it turns out wxWidgets, at least the simple ones that we Mach hobbyists are likely to use, are actually fairly simple....but, and this is the big but......
they still have to be learned. With a concerted effort and some coaching you could be up and running crafting your own widgets in 6 to 10 hours or
so. Most people get really pissed off and walk away long before they learn what needs be learnt and seem to imagine that developing CNC software
should be a s easy as falling off a log. Spoiler....ITS NOT!! Ask yourself the question 'am I the sort of person who gets 'stuck in' and masters challenges or am I the sort
of person who whinges because it does not fall into place automatically?'

As I have said before and I will repeat it, 'the simplest way to include a widget in your code is to find an existing widget which is close and then modify it.'
That is exactly what I did and started from there. I have used wxFormBuilder a few times since then, but still have only a sketchy understanding of it....but I can
with care and patience use it to craft some bloody nifty widgets, even if I do say so myself. Total investment of my time ......guessing 20 hours.

May I suggest you think about an m6() macro that does not require a widget. That is not to say that operator input cannot be used. For instance you might wish to
manually jog to a tool change location, Mach can do that, and all it requires is a <Cycle Start> button press to resume its automatic operation once you have jogged to the required location.

Quote
They could have created at least one team to which to make paid script requests.... too bad!!!.

They do, NFS do write code for people and get paid for it including Mach4Hobby and Mach4Industrial.

If you have paid for Mach4Industrial you'll find that NFS roll out the red carpet for you, the extra support is the most substantial extra cost of Industrial.

Unless I'm much mistaken you don't really need that sort of help...you just need to start writing your own code, but do yourself a favor and leave out wxWidgets to start with!

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Script da mach3 a mach4
« Reply #13 on: March 27, 2023, 08:09:32 AM »
ok thank you
Re: Script da mach3 a mach4
« Reply #14 on: March 27, 2023, 03:58:17 PM »
Hi,
you may like to think about this API:

Code: [Select]
LUA Syntax:
rc = mc.mcFileHoldAquire(
number mInst,
string reason,
number JogAxisBits)

Description:
Used to hold G code processing.

When you are running a Gcode file you cannot jog. The trajectory planner can only have one master, and when the Gcode interpreter is consuming
a Gcode file the it is the master. If you want to jog say....you cannot, as that would require the GUI to be the master so as to allow the jogging.
Just pausing the Gcode will not do....you have to release the planner.

It is for this reason that the API exists. If you are sailing through a Gcode file file and you have a m6() macro or similar that you want to execute but requires
that the operator manually jog somewhere, you can put the Gcode file on hold and release the planner. Then operator can jog and/or do whatever needs be done.

Code: [Select]
LUA Syntax:
rc = mc.mcFileHoldRelease(
number mInst)

Description:
Used to exit a file hold state.

This is the API that releases the file hold and so the Gcode interpreter becomes the planner master again.

This technique uses the <CycleStart> button. This avoids the need to use a wxWidgets dialog.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'