Hello Guest it is April 30, 2024, 01:05:42 PM

Author Topic: Running Mach3 via VB.NET  (Read 12511 times)

0 Members and 1 Guest are viewing this topic.

Running Mach3 via VB.NET
« on: October 19, 2009, 10:29:45 AM »
Good morning :-)

After a long run of extensive searching and finding great help through the forums, I've hit a roadblock.

I'm trying to control Mach3 through VB.net and have the basic foundation.  I'm able to do basically everything I want with the Mach4 COM API, but my problem is that every time I restart my vb.net program, I get an error that says "Cannot create ActiveX control" on the line that reads: mach = GetObject(, "Mach4.Document")

Here is some simple code:

Code: [Select]
Dim mach As Mach4.IMach4
Dim scriptObject As Mach4.IMyScriptObject

mach = GetObject(, "Mach4.Document")
scriptObject = mach.GetScriptDispatch()

scriptObject.LoadFile("11 CUX56.TXT")

scriptObject.RunFile()

While (scriptObject.IsMoving() <> 0)
    System.Threading.Thread.Sleep(1)
End While


If I close Mach3 and restart it after the error, the program runs fine.  The problem occurs when I close my vb.net program and reopen it (rebuild it, to be exact) without closing Mach3.

Am I not creating my object properly?  Is there a code to reset the control or to close the link to reopen it?  If I run the code with Mach3 closed, I get the same error.

I'm guessing it's related, but when I close Mach3 after getting the error, I get a popup box that says "Error Found  ,Art Code: 9991, Attempt Recovery?".

Any ideas?  Thank you very much in advance!
« Last Edit: October 19, 2009, 10:34:00 AM by andrewk »

melee

*
Re: Running Mach3 via VB.NET
« Reply #1 on: October 21, 2009, 12:55:45 PM »
Hi

I'm afraid all I can offer is WHY?

The intellectual challenge of making it work, I can understand.

The practicality of operating a program which requires real time data (despite the problems this already causes under Windoze),
through an abstraction framework which runs it within a 'virtual machine',  with no direct control of memory allocation or CPU time,
must be very limited.

I have had that error message when playing about with threading wizards, so not sure if it is specific to what you are doing or generic, memory problem say.

regards

Melee
Re: Running Mach3 via VB.NET
« Reply #2 on: October 21, 2009, 03:29:09 PM »
Thanks for the reply, but why what?

I'm creating a custom .net program to gather data from two Mitutoyo indicator gauges at specified locations along the X axis.  This data is then instantly and automatically plotted in 3D and is part of a potential closed loop that modifies other files on our network.  There is a very fine window for gathering of the data, and if the location is skipped, the program instructs Mach3 to turn around slowly, grab the missed data, and continue.  Luckily, the data transfer from the caliper and indicator, as well as the timing have worked out quite well on my barebones Windows machine.

I realize that most of this can be done with VB in Mach3, but I want to have my custom GUI with plotting, settings, etc.  There are a few more reasons for using Windows, and unfortunately I can't sway from this.

If I haven't answered you question as to why I'm doing it this way, I'm sorry.  Unfortunately this isn't a personal project, and I'm using what limited programming and architecture experience that I have to complete this project, meaning I'm already heavily time invested into my program (and it impresses my boss :-p )

Thank you,

Drew
Re: Running Mach3 via VB.NET
« Reply #3 on: November 11, 2009, 04:58:57 AM »
how can program for mach3 in .net?
do you write program in VS?
do can whitout run mach3 program it?
tanx
Re: Running Mach3 via VB.NET
« Reply #4 on: November 11, 2009, 09:42:42 AM »
Yea, I created a program in vb.net that runs Mach3 remotely, gathers and updates information constantly, and makes dynamic changes based on that info.

My program automatically open and minimizes a fresh session of Mach3 when it's executed and closes Mach3 when it closes.

It monitors the E-stop and limit switch states of Mach3 and uses a custom GUI to present all information.

I didn't do any programming in Mach3 itself, I did all of the programming in Visual Basic 2008 Express Edition (free).

If you have a specific question, just ask...but please try to write it in a coherent manner and in the English language.
Re: Running Mach3 via VB.NET
« Reply #5 on: November 11, 2009, 09:47:23 AM »
do user can see match3?
this is mean user donot know when runig mach3?
Re: Running Mach3 via VB.NET
« Reply #6 on: November 11, 2009, 09:48:58 AM »
The user can not see Mach3 running and doesn't need to know that it's running.  I immediately open, minimize, and hide Mach3 and perform all of my operations through the vb.net custom GUI.
Re: Running Mach3 via VB.NET
« Reply #7 on: November 11, 2009, 09:55:51 AM »
tanx for replay
do can send for me this code
 ""I immediately open, minimize, and hide Mach3 and perform all of my operations through the vb.net custom GUI""
Re: Running Mach3 via VB.NET
« Reply #8 on: November 18, 2009, 07:46:22 AM »
how run mach3 in vb.net?
Re: Running Mach3 via VB.NET
« Reply #9 on: November 18, 2009, 07:58:14 AM »
Have a nice day, guys.  This forum is littered with information on how to do just that.  If I figured it out, I'm sure you can too.  I simply don't have time to go through it all.

Thanks for the interest.  Goodbye.