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:

Make dll with VS2005


Recommended Posts

Hi All,

 

I wrote VB script programs to simply tasks in Mastercam. But there are limitations in accomplishing the complex jobs. So I now try to use VS2005 (Professional version) to learn how to write and use dll files.

 

Following suggestion in this forum, I started with sample project, "NetHook2Example", I loaded this project file in VS2005 and further open one of the example, "5.1 - The PointGeometry Class". Then I did all the steps mensioned in "Read Me First!!.txt". Then I click on menu "build", then click "build NetHook2Example". Ok, it did generate (2) files, "NetHook2Example.dll" & "NetHook2Example.pdb" in the folder ...NetHook2ExamplebinRelease.

 

After that, I open my Mastercam, click on menu "Settings", "Run User Application", find and click above dll file (NetHook2Example.dll) and hope it will run. But instead, it pop up a message window: "The appropriate Mastercam .NET Support dll could not be found".

 

I am at loss. I installed mastercam SDK under the Mastercam directory and I think VS2005 professional would intall all the required stuf needed. Can anyone tell why it did not run.

 

The only thing I can think of that may cause problem is that I run Mastercam mill X2 Mr2 SP1 and SDK installed is for Mastercam X MR1 SP2. Are they not compatible.

 

I am new to VS2005, but I studied "C" programming and "Basic" preogramming back in college iong time ago.

 

I would appreciate greatly any insight in solving this problem.

 

Thanks

 

Kevin Qian

Quality Forming

Link to comment
Share on other sites

quote:

The only thing I can think of that may cause problem is that I run Mastercam mill X2 Mr2 SP1 and SDK installed is for Mastercam X MR1 SP2. Are they not compatible

The is no 'SDK' for NETHooks. The NETHook support is via the NETHook2_0.DLL which you add to the References of your NET Project.

There is an SDK for creating CHooks, which are written in C++ (with MFC).

 

Q? Which copy of NETHook2_0.dll is referenced in your NET Project?

NetHook2_0ReferenceProperties.jpg

 

 

I downloaded the NetHook2Example package from here -> NetHook2Example.zip

Then set the Reference to the NetHook2_0.DLL , then build the NetHookExample project (in Release mode).

Fired up up X2-MR2 and Settings, Run User Application and selected the new NetHook2Example.dll and up pops -

ExampleAppdialog-1.jpg

Link to comment
Share on other sites

Hi, Roger,

 

Thanks for your insightful reply.

 

I downloaded again the "NetHook2Example.zip" from your link. I loaded the program in the VS2005, referenced the "NetHook2_0.dll" and re-assign the "build path" directly under McamXchook. Then I built the project, fired up Mastercam and run the NetHook2Example.dll and Walla, It worked.

 

I am glad it worked, but I don't think I did anything different from what I did before other than re set up the "NetHook2Example" from fresh. and reassign the "build path" to a different location (I used to built program into a Desktop folder).

 

My "NetHook2_0.dll" has version of 1.0.2909.14326 and Run Time version of V2.050727. I laugh now that I fixated on 'SDK' which turns out has zero effect on running the program.

 

I still have some questions that I likes to know,

 

1). It seems that NetHook2Example.dll generated will run every samples inside the project, from 1st sample to the last. Is there a way that I can build a .dll file which will run just one sub sample in it, such as "5.1-The pointGeometry Class".

 

2). If everything to do with Mastercam API is inside the single file "NetHook2_0.dll", how do I know what functions inside it that I can use to write my own program. Is there any Instruction/description booklet that will list each function and syntex for using them.

 

Thanks again for your help

 

Kevin Qian

Link to comment
Share on other sites

Hi Kevin,

 

1). Yes, you can create a NetHook that contains only one class and runs that class when you launch it. I'll did around and see about coming up with a sample.

 

2). The Mastercam API is separate from the NetHook 2.0 Dll.

 

The NetHook Class Library (there are several versions, the latest release from Microsoft is 3.5) is a Class Library that is created by Microsoft that contains re-useable classes that can be referenced by your application.

 

Mastercam uses components of the Net Framework. To make sure that your NetHook (the .dll you are creating) and Mastercam can work together, they have to reference the same library so that the functions they share are compatible.

 

I'm sure some of the other members can provide additional details and insight into what is going on.

Link to comment
Share on other sites

quote:

If everything to do with Mastercam API is inside the single file "NetHook2_0.dll", how do I know what functions inside it that I can use to write my own program. Is there any Instruction/description booklet that will list each function and syntex for using them.

That’s kind of what the NetHook3Example set of files is for, to demonstrate what you can do.

You can also examine the functions exposed by the NetHook2_0.dll by using the Object Browser in Visual Studio.

Expand the References branch of the NetHook2Example project and ...

Select the NETHook2_0 item and then select Object Browser (on the View menu)

or

Right click on the NETHook2_0 item and select View in Object Browser from the popup menu.

Now expand the NETHook2_0 item (in Object Browser) and you can explore the details.

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...