Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Recommended Posts

Hello,

 

starting to use Mastercam X2 I would also like to make the transition from VS 2003 to VS 2005. If I use the new nethook.dll everything works fine, but I don't see any point, because there is nothing new in nethook.dll, is there? On the other hand, if I use the new NETHook2_0.dll, my old code doesn't work any more and updating is quite demanding. Besides, I couldn't find any documentation about the new NETHook2_0.dll (all documentation available in fact refers to nethook.dll).

 

To conclude, I would like to solve two problems:

1. How to update my old .NET (C#) programs to get the ability to use new functions (is it possible to include both nethook.dll and NETHook2_0.dll in the same project)?

2. How to use the new NETHook2_0.dll? Is there really no documentation / examples of (C#) code available?

 

Thank the one who answers very much.

Link to comment
Share on other sites

Hello Jure,

 

The .dll you're referring to is the .dll for the new NetHook 2.0 API shipping with X2. There are a number of drastic changes in this version of the API that we hope should make development for NetHook apps much easier in the future, but in the short term converting apps to target the 2.0 API may require a good deal of re-writing. We've used the new API internally and I think you'll find the same thing we did - there is a small learning curve with the NetHook 2.0 API, but it's much easier than the old one once you get the hang of it. You're correct about the NetHook 1.0 API though - although there may be one or two bug fixes, the NetHook 1.0 API is really only being included for backwards compatibility and will probably see no more forward development.

 

As for the documentation, we're aware of the lack of documentation and examples for the new NetHook API in X2. There are some things in the works to remedy the shortcomings, and hopefully we'll have a few things to present to the Mastercam development community soon. Don't worry - help is on the way. :-)

Link to comment
Share on other sites

Mike,

 

thank you for your kind reply. Could you be a little more clear, please:

 

If NetHook 1.0 API is intended for backwards compatibility, is it possible to include both .DLLs in the same project? This would enable the programmer to keep the old code and to develop it further.

 

I have asked for documentation because I tried to use the simplest method using NetHook 2.0 API, but I didn't succeed. At this point I actually don't urgently need any documentation, only one single but complete example of C# NetHook code. Therefore, I kindly request you to provide this example, preferably including the method: Mastercam.Database.Geometry.Translate.

 

Thank you for your answer smile.gif

Link to comment
Share on other sites

Hello again Jure,

 

Sadly, you won't be able to mix the two APIs. Apps written for the NetHook 2.0 API (NH 2.0 for brevity) are different all the way down to the NH 2.0 app class and the way Mastercam handles the two types of NetHook apps. The way you setup your app should be similar to the way you set up your old NetHook apps, however - the only thing that has changed in that regard is the name of the class.

 

All you have to do with the NH 2.0 API to write the simplest of apps, once you've added "NETHook2_0.dll" as a reference to your project, is derive from the 'NetHook2App' class and override the 'Run' method. Here's some code for a Hello World type of app that will hopefully be enough to get you started (written in C#).

 

code:

 

using System;

using Mastercam.App;

using Mastercam.App.Types;

 

public class HelloWorldApp : NetHook2App

{

public override MCamReturn Run(int param)

{

DialogManager.OK("Hello World!!","Hello World App");

 

return MCamReturn.NoErrors;

}

}

I'm afraid the explanation on how to use the NH 2.0 API's implementation of geometry transforms has to be preceded by an explanation of the NH 2.0's brand new database system, so I'll save that for another thread. Hopefully this is enough to get you started though, and if you have some more questions down the road about geometry specific methods (or anything else for that matter) I'll be happy to answer those too. Good luck... !! smile.gif

 

 

P.S. A quick documentation hint: we shipped a full suite of fairly good documentation associated with the NETHook2_0 assembly that can be read in Visual Studio's Object Browser. If you use the Object Browser to select the NETHook2_0 assembly and explore the API a little bit you'll find that almost everything in the API is documented pretty well. Hope that helps.

Link to comment
Share on other sites

Mike,

 

thank you again. You are really very helpful.

 

I understood:

It isn't possible to mix the two APIs. All the old NetHooks will have to be rewritten for the new API NH 2.0.

 

I tried out the HelloWorld code you provided and at first it didn't work. After I added Mastercam.IO. into the line to become:

code:

Mastercam.IO.DialogManager.OK("Hello World!!", "Hello World App");

it worked well. Then I added another line:

code:

Mastercam.IO.SelectionManager.SelectAllGeometry();

which also worked. But I can't imagine why I can't translate the selected objects now:

code:

Mastercam.Database.Geometry.Translate( ... )

(doesn't work.)

 

I know I can use Object Browser to explore the API and right there I can see the method Mastercam.Database.Geometry.Translate, which I cannot use. Neither can I draw one single line... I bet you already guessed, what I will say now: "Please, help!" smile.gif If you think it is necesary to learn "the brand new database system", please start with that.

Link to comment
Share on other sites

Below is an example of creating two lines:

 

code:

	// Define our points

Point3D pt1 = new Point3D(-0.5, -0.5, 0);

Point3D pt2 = new Point3D();

Point3D pt3 = new Point3D(1.0, 0, 0);

 

// Define our lines

LineGeometry line1 = new LineGeometry(pt1, pt2);

LineGeometry line2 = new LineGeometry(pt2, pt3);

 

//Commit to database

line1.Commit();

line2.Commit();

I am not sure but there might be a scoping issue with translate as I too can not access the method even though it is visible in the object browser. We will get back to you on that asap.

Link to comment
Share on other sites

Mick,

 

this is called HELP! idea.gif I think I got "the brand new database system" and I think I will like it.

 

I don't know why you mentioned "scoping issue", because the translate method works well in my NetHook. I added this line:

code:

line1.Translate(TranslationMode.Copy, pt1, pt2, 1, 1);

to your code and on my computer it works just fine.

 

In the next days I won't bother with basic questions any more, but after a while I will have some hard ones for sure. Till then, have a nice time!

cool.gif

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...