Author Topic: Automation with C# VS2013  (Read 5962 times)

0 Members and 1 Guest are viewing this topic.

Offline havingfun

  • Active Member
  • Posts: 8
    • View Profile
Automation with C# VS2013
« on: January 19, 2014, 10:41:52 AM »
Anybody know how to automate Mach3 R3.043.066 from C# VS2013?

Code below compiles fine then gives: "An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll" 

The application was built for X86 and both Mach3 and the app are running as admin.  Also, I reinstalled Mach3.

Thanks in advance.

using System.Runtime.InteropServices;

namespace AutomationTest
{
    public partial class Form1 : Form
    {
        private Mach4.IMach4 Mach = null;
        private Mach4.IMyScriptObject Script = null;
       
        private void button1_Click(object sender, EventArgs e)
        {
            Mach = (Mach4.IMach4)Marshal.GetActiveObject("Mach4.Document");   <<<== ERROR HERE
            Script = (Mach4.IMyScriptObject)Mach.GetScriptDispatch();
            Script.Code("G1 X2 Y2 F400");

Offline Jayawarden

  • Holding
  • Posts: 1
    • View Profile
Re: Automation with C# VS2013
« Reply #1 on: January 08, 2016, 03:56:06 PM »
Hello.

I think you have to start Mach3 before you build it in Visual Studio.

Greetings from Germany, Martin

Offline duyngdang

  • Holding
  • Posts: 2
    • View Profile
Re: Automation with C# VS2013
« Reply #2 on: July 04, 2018, 12:49:19 PM »

 Hi
I am using C# to automate Mach3. But i am stuck how to displace Gcode running in C#

If you guys know please help