Author Topic: VB6 Automation Sample  (Read 5861 times)

0 Members and 1 Guest are viewing this topic.

Offline dz32

  • Active Member
  • Posts: 14
    • View Profile
VB6 Automation Sample
« on: February 08, 2016, 10:35:52 AM »
Hi, I didnt see any samples of automating mach3 from VB6,
but I was able to put one together see attached example

hopefully others will add to it as they need more features
and probe the api more

Offline dz32

  • Active Member
  • Posts: 14
    • View Profile
Re: VB6 Automation Sample
« Reply #1 on: February 08, 2016, 12:12:12 PM »
the git repository where you can find any updates for this is here:

https://github.com/dzzie/home_automation/tree/master/mach3_vb6

Offline dz32

  • Active Member
  • Posts: 14
    • View Profile
Re: VB6 Automation Sample
« Reply #2 on: February 09, 2016, 01:03:21 PM »
One other note I will put in here. I have seen it mentioned allot that after the first time you use the Mach4.CMach4Doc object, then close your program, that you have to restart Mach in order to get a hold of it again.

This is a COM reference counting issue. It must not be properly calling Addref().

If you make an extra call to it manually, then it wont be unloaded from memory when your plugin exits. With this you can start up your plugin and do testing as many times as you want without having to restart Mach each time.

Offline stirling

  • Global Moderator
  • *
  • Posts: 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: VB6 Automation Sample
« Reply #3 on: February 10, 2016, 06:02:23 AM »
Welcome to the forum dz32.

Just had a quick look but this looks like it could be fun.

Thanks for sharing.

Offline dz32

  • Active Member
  • Posts: 14
    • View Profile
Re: VB6 Automation Sample
« Reply #4 on: February 10, 2016, 07:17:37 PM »
Thanks for the welcome :)

Another file of interest will be a dump of the (192!) function names and prototypes supported by the IMyScriptObject interface.
For some reason they would not show up in the VB6 IDE so I had to dump them with another tool.

They are syntax color highlighted with VB6 prototypes in the attached rtf.
A listing of just the function names is at the bottom which may be easier to scan.

Offline dz32

  • Active Member
  • Posts: 14
    • View Profile
Re: VB6 Automation Sample
« Reply #5 on: February 11, 2016, 05:13:31 AM »
found the documentation on the IMYScriptObject functions and OEM codes:

http://www.machsupport.com/wp-content/uploads/2013/02/Mach3_V3.x_Macro_Prog_Ref.pdf

Offline stirling

  • Global Moderator
  • *
  • Posts: 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: VB6 Automation Sample
« Reply #6 on: February 11, 2016, 06:01:19 AM »
Was just going to send you that - you beat me to it.

You might want to take a look at this http://www.machsupport.com/forum/index.php/topic,6657.0.html

and this http://www.machsupport.com/Mach3Wiki/index.php?title=Main_Page

section 4 and 9 for things like symbolic constants and param strings etc.

Couple of questions:

I see in your readme you say that Mach3 versions after 3.042.020 dont properly register the COM objects in the registry.

As it happens I use 3.042.020 but is there any way to fix things for later versions? Otherwise although this is interesting to play with I'm wondering if it's of practical use as I guess most?/a lot? of folks will be using later versions.

Offline dz32

  • Active Member
  • Posts: 14
    • View Profile
Re: VB6 Automation Sample
« Reply #7 on: February 11, 2016, 06:52:47 AM »
Awesome thanks for the links. There is definitely allot of information to take in !

Assuming that the registry keys were not removed for a reason, we will be able to manually add them back in
so that it will work for latter versions. This is on my to-do list and should not be to hard.

For the project I am working on I really want the Mach integration.
It might be nice to be able to use the most current version.

For those curious here is the idea I am working torwards, (trainable CNC paths vrs conventional programming through manual, cam, or scanned/converted paths)

http://sandsprite.com/blogs/index.php?uid=13&pid=377

Offline stirling

  • Global Moderator
  • *
  • Posts: 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: VB6 Automation Sample
« Reply #8 on: February 11, 2016, 08:21:59 AM »
Assuming that the registry keys were not removed for a reason, we will be able to manually add them back in
so that it will work for latter versions. This is on my to-do list and should not be to hard.

I think that would certainly give it more legs

For the project I am working on I really want the Mach integration.

Thanks for the link of what you're up to. I'm not quite sure I understand why you need Mach-automation though.
Once you have your PC program create the gcode - why not just load and run in Mach normally? What am I missing?

Offline dz32

  • Active Member
  • Posts: 14
    • View Profile
Re: VB6 Automation Sample
« Reply #9 on: February 11, 2016, 10:19:56 AM »
Quote

Thanks for the link of what you're up to. I'm not quite sure I understand why you need Mach-automation though.
Once you have your PC program create the gcode - why not just load and run in Mach normally? What am I missing?


The first thing that caught my eye was using the integration to make the testing and calibration
stages easier. The first test will be something like:

set 0,0 on a parts corner, manually move the gantry around to the various hole centers. hit a button
to record the spot this builds a list in the pc program. go back to 0,0.power steppers, then click another button
to send first point in list to mach, click to send next point and cycle through the list.

This should also be useful latter for quickly transferring hole patterns from parts to mounting plates without
really having to measure.

Other ideas to build on top of it. Maybe I could also break out of the gcode a bit.
Add a layer of logic on top where I can take physically separate gcode files, stack them in a que to run.

still fleshing out ideas but it seems super useful.