Hello Guest it is March 28, 2024, 07:30:14 AM

Author Topic: VBA Excel and Mach3  (Read 7748 times)

0 Members and 1 Guest are viewing this topic.

VBA Excel and Mach3
« on: August 11, 2011, 05:06:16 AM »
Hello,
 I made a small program in vba excel to reate a g-code.
 Excel creates a text file of the g-code.
 I want VBA Excel to automatically send the g-code in mach3.
 How can I do?
 Thank you.
Re: VBA Excel and Mach3
« Reply #1 on: August 11, 2011, 06:26:24 AM »
To make it fully automatic you would have to write a Mach3 Plugin DLL, at least to the best of my knowledge - not recommended unless you have experience with making DLLs or a strong desire to learn!

However, an easy solution could be to make the Excel VBA create the file in a predetermined place, then create a button on your screenset in Mach3 to load the file. e.g.
‘ Load the roadrunner demo file
LoadFile(“C:\Mach3\Gcode\roadrunner.tap”)

Or
‘ Load and run the roadrunner demo file
LoadRun(“C:\Mach3\Gcode\roadrunner.tap”)


Using a DLL you would export a function that could be called by the VBA. The function would use Mach3 plugin interface to automatically load the file and optionally start it automatically, if that's what you wish. However, as I said before, not for the faint-of-heart. I wouldn't recommend it unless you have a working knowledge of C++ or an iron will to learn from scratch (it won't be easy if you don't already know the language)! The plugin interface is not very well documented; you will find most information and examples pertain to motion control, as that is it's primary purpose.

I know this probably isn't what you wanted to hear, but hopefully this is of some help.

Chris

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: VBA Excel and Mach3
« Reply #2 on: August 11, 2011, 10:33:20 AM »
Create a macro inside MACH that calls Excell ,when you have completed your excell save the Gcode file to the MACH gcode DIR, then when it returns back to the macro control have the macro load the file into mach. You can even have it LOAD /RUN if needed. I have used this trick many times .

Just a thought, (;-) TP

Re: VBA Excel and Mach3
« Reply #3 on: August 12, 2011, 06:08:00 AM »
Thank you for your answers. I'll try the method of BR5 .. Good idea!
 PS: I estimated the editor vbmach not very friendly for help and keyboarding semiautomatic

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: VBA Excel and Mach3
« Reply #4 on: August 12, 2011, 06:13:26 AM »
I made a small program in vba excel to reate a g-code.
 Excel creates a text file of the g-code.
 I want VBA Excel to automatically send the g-code in mach3.

Not sure but arn't we missing the trick here?

If you have vba that creates gcode, then why not just put that vba in a macro (assuming it's translatable to CB) and use the teachfile functionality? Seems to me you're going around the world to get back home.

Ian

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: VBA Excel and Mach3
« Reply #5 on: August 12, 2011, 11:37:12 AM »
Actually as Stirling has stated you can do all the work in Mach CB. It is VERY powerfull in that respect. I have several CBmacros that take user input and create Gcode files for offset grinding crankshafts and create the Gcode program AND autoload it into Mach for you. All you do is answer some questions and press the Mach go button.

(;-) TP