Hello Guest it is March 29, 2024, 10:44:15 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - davew

Pages: 1
1
I am working on remoting mach from C# as well.  I have got most things working, but I am tearing my hair out with a problem.  Brian added into Mach3 the .GetMessage call (to display the status label data), this returns a BSTR, now that is well and good in C++ but it is killing me with C#.  Do you guys know of a way of accessing a BSTR in C#???

Andrew,

I haven't needed strings yet, but as I was getting started, the following article was helpful for me.

http://msdn2.microsoft.com/en-us/magazine/cc301501.aspx

Dave

2
Figured it out...

I was just digging around CMach4.h and realized the ShutDown() call is to close the Mach3 app. ...not what I was trying to accomplish.

After a bit more digging, I noticed we're doing an AttachDispatch for both mach4 and scripter...but only doing the DetachDispatch for scripter.

This code is working for me well now:
     scripter.DetachDispatch();  //detach the scripter object
     mach4.DetachDispatch();
     CoUninitialize();

Thanks for your thoughts/time on a Saturday afternoon!

Dave

3
The scripter.detach() call should return the IDispatch pointer, so try releasing it as so:

IDispatch tmp = scripter.detach;
tmp->Release();

James,

Here's the shutdown code I ended up with, based on your suggestion:

   LPDISPATCH tmp = scripter.DetachDispatch();  //detach the scripter object
   tmp->Release();
//   mach4.ShutDown();
   CoUninitialize();

Unfortunately this didn't appear to help.  I'm stilling getting HRESULT of 1 from GetActiveObject on my subsequent runs.

4
Ok, I've got my hands dirty and I'm back with a few questions...

First, thanks James for your Plugin tutorial and whoever wrote MachRemote.

I've developed an application in C# (VS2005) and have been tasked with making it automate Mach3.

What I've done is created a DLL which exports many of the functions of the Mach3.exe Object Model.  I used James' Plugin Tutorial as a reference to get started.  I then imported these functions into C# and wrapped them with a C# class (which handles connection, exceptions, etc).

This isn't a plugin.  I'm not doing anything with dialogs.  I'm just setting DRO's, pushing buttons, etc.

So far it is working well except for when I shutdown my app and restart it.  After the first time I run, future runs of my app fail to connect to Mach3.  If I shutdown Mach3 and restart it, everything is fine (until I shutdown my app and restart it).

I've added some debug code and discovered subsequent runs are failing with a result code (HRESULT) of 1 from GetActiveObject(clsid,NULL,&lpUnk) (see Mach3ObjectModelStartup() in Plugin Tutorial; page 73/92 in V01).

So I started by looking at the shutdown code where I detach from Mach3.  In the plugin tutorial, it appears to only be calling "CoUninitialize();"  (see Mach3ObjectModelShutdown(VOID); page 74/92 in V01).

However, in MachRemote, I find this code in CMachRemoteDlg::OnBnClickedDisconnect():
    scripter.DetachDispatch();  //detach the scripter object
    //mach4.ShutDown(); //then shutdown MAch3's interface..

With only the CoUninitialize() call in Plugin Tutorial, Mach 3 would complain on exit with an Art Code of 9991.  After I added the scripter.DetachDispatch(), this complaint went away (mostly at least).  If I add the "mach4.ShutDown()", this creates an additional error.

Any insights on what I'm missing?
Why doesn't the Plugin Tutorial call scripter.DetachDispatch()? (oversight?  am I missing something?)
Why is mach4.ShutDown() commented out in MachRemote?

Any insights appreciated,
Dave

5
If there is sufficient interest I will make this a series.
-James Leonard

This tutorial has been a tremendous aid.  Thanks for sharing!

6
I "second" Bob's (BW's) suggestion.  I had to post a message in the forums to find the SDK.  After I had searched for quite a while.  The menu system was confusing me.  A single "developer" link from the menu with a splash page explaining the different options (plug-in's, scripts, MachRemote, etc) would be a HUGE time saver for developers tasked with automating/customizing Mach3.

7
Thanks guys.  I guess I was looking mainly at the menus of the website and not drilling down into each page enough.

I've got both VS2005 & VS2003, so I'll give it a look.

Dave

8
I have just been introduced to the Mach3 software and am looking for ways of automating it from external software.

In skimming over the manual, I noticed in section 3.1.3, it states that using the OCX it is possible to control Mach3 without its GUI.  Where can I find more information on this?

After a few hours of digging around I've come across talk about Plugins, but can't find any "Getting Started" documentation (other than how to setup Visual Studio).  At first impression, "plugin" sounds like something used WITHIN Mach3 (and it's GUI), rather than something to control it externally.

Any good pointers on where to start?  I'm comfortable with most any development language/environment.

Any assistance greatly appreciated,
Dave

Pages: 1