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:

Do I need to Install the MasterCAM SDK or just copy the folder?


Recommended Posts

Hello,

 

I met a problem when I am trying to debug my c-hook program in MasterCAM.

 

Currently, I am developing c-hook program for MasterCAM X6 in Visual Studio 2010. In the release configuration, everything goes well, I build the mychook.dll and it works well in MasterCAM.

 

Now, I want to debug mychook.dll with MasterCAM running, which means I want to see how values changes in my source code in visual studio when I press buttons of mychook.dll in MasterCAM. I did what Roger said before: In visual studio, under my project.

 

Configuration->Debug

Configuration->Debugging->Command-> C:\mcamx6\sdk\x64\debug\Mastercam.exe

Configuration->Debugging->Work Directory-> C:\mcamx6 (where I install mastercamx6)

 

After these setup, I press Start Debugging(F5), MasterCAM opens successfully. However, when I try to using mychook button to open a step file(which works well in release mode), visual studio report a fatal error. like below:

post-49696-0-36321200-1399319337_thumb.jpg

 

This error points to some mastercam database read/write code in my program. like below:

post-49696-0-59652500-1399319572_thumb.jpg

 

This is very strange to me. Because it works well in the release mode, but here it fails. I am guessing that it uses some read/write dlls in the \sdk\x64\Debug folder instead of the dlls in my noraml running \mcamx6. Which means the sdk is causing the problem. Could it be that my sdk is not compatible with my mcamx6 ? Or could it be that I am not installing my sdk correctly?(Honestly, I just copy the sdk folder to any location in my computer, instead of installing it), Here is the "Error Reprot Dialog" when I open the mastercam in debug mode.

post-49696-0-95623200-1399319963_thumb.jpg

 

I guess the problem would be the way that I deal with sdk, but I have no clue how can I fix this.

 

 

Thanks in advance for your help.

 

Guangyu

ISU

Link to comment
Share on other sites

You do not have to "install" the CHook SDK, if you have it in ZIP form.

 

Ignore the "Error Report" dialog listing "menu" or "toolbar" issues when starting up in Debug mode.

(You will always see this dialog when starting up in Debug, as it will always find something to complain about.)

 

Absolutely true ->

I am guessing that it uses some read/write dlls in the \sdk\x64\Debug folder instead of the dlls in my noraml running \mcamx6.

 

These setting look correct ->

Configuration->Debug

Configuration->Debugging->Command-> C:\mcamx6\sdk\x64\debug\Mastercam.exe

Configuration->Debugging->Work Directory-> C:\mcamx6 (where I install mastercamx6)

 

Are you sure you're building the correct bit-ness of your CHook in Debug mode? (32 or 64 bit)

 

Check for an ART.FT file in the mcamx6\CHooks folder and if found change the file's extension to something other than .FT

(I doubt that this is the cause, as I would expect to see a different error message if this was the issue.)

 

If you start Mastercam in Debug, but then just try to create some geometry instead of running your CHook, does that work OK?

 

This is a strange error to see in the situation where it runs in Release, but not in Debug. ->

"The Microsoft Visual Studio C Runtime Library has detected a fatal error in Mastercam.exe"

 

What is the extract version of X6 your are running?

What is the extract version of the Chook SDK?

Link to comment
Share on other sites

Roger,

 

Thanks very much for your reply.

 

I double checked the bitness in Visual Studio and it is correct(x64).

 

I did not found any ART.FT file in mcamx6\chooks, so I think it is OK.

 

I tried creating cylinder surfaces and open igs models in mastercam in debug mode and it also works well.

 

The exact version of my X6 is 15.0.4.3

The exact version of my SDK is 15.2.1.2

 

I realized the version dis-match so I install the mastercamx6-MU2-x64-web patch and now my version of X6 is 15.2.1.2, like below:

 

post-49696-0-47063200-1399337177_thumb.jpg

 

I rebuild my project and try to debug again, I met the same error described above.

post-49696-0-31010700-1399337269_thumb.jpg

 

However, I want to mention one important warning when I press Start Debugging(F5) in Visual studio, it says this:

post-49696-0-27277700-1399337410_thumb.jpg

 

I am not pretty sure what this means. So I just press yes, and it continues opening MasterCAM.

 

The other problem I have is that I wonder how the Visual studio know which dll I am debugging.

 

Say my project locates at E:\mychookproject\

The mychook.dll I generated locates at E:\mychookproject\x64\Release and E:\mychookproject\x64\Debug\

I copy the mychook.dll from E:\mychookproject\x64\Release to C:\mcamx6\mychook\

Thus, when I open MasterCAM and uses my chook program, it uses the C:\mcamx6\mychook\mychook.dll

 

In my opinion,when I am debugging the mychook.dll from my project, I assume the MasterCAM.exe should uses E:\mychookproject\x64\Debug\mychook.dll instead of C:\mcamx6\mychook\mychook.dll

 

However when I am checking the Modules when I am debugging in Visual studio, it shows the following:

post-49696-0-59093800-1399338675_thumb.jpg

And the warning says "the module did not load at the default load address"

 

Therefore, I am wondering, if MasterCAM.exe load the mychook.dll in C:\mcamx6\mychook, it is totally wrong, the dll there is a release version. Meanwhile, I wonder what setting makes the MasterCAM.exe uses the Debug version of mychook.dll.

 

Thank you very much.

 

Guangyu

Link to comment
Share on other sites
Debugging information for ‘Mastercam.exe’ cannot be found….”

Just select Yes (also select the “Don’t show this again”)

You are not debugging Mastercam, so this is fine.

 

Microsoft Visual Studio Runtime Library has detected a fatal error…

There something wrong with your code and/or the environment, but determining what is the real issue is with just this error message is somewhat impossible.

 

In my opinion,when I am debugging the mychook.dll from my project, I assume the MasterCAM.exe should uses…

Mastercam doesn't use (run) any CHook DLL without you telling it which one is to be run.

 

How do you start your CHook once Mastercam is running?

Main menu – Settings – Run User Application and you select the exact DLL to be loaded.

 

The other way to run a CHook is by a toolbar icon or key assignment.

To do this requires a Function Table file (FT) and within that FT file you created, you specify the path (and name) of the CHook DLL to be run when that toolbar icon is clicked.

I usually recommend not using the FT file during debugging.

Your can but...

If your CHook DLL is referenced in an FT, it is automatically loaded when Mastercam starts up and cannot be unloaded during the session.

If you forget to copy the DLL you just built over to the folder that your FT points to, you can run into "why doesn't this work?!?" issues.

Also, don’t run a Debug build of your CHook using the Release version of Mastercam.exe, as that’ll not work “correctly”.

 

Just select the desired (debug) DLL to run using the ‘Run User Application’ menu.

You can easily set your DLL as the default CHook in Configuration, on the Start/Exit page.

Set the desired default DLL for the ‘Add-in programs’ on the right side of that page.

Then you can just press ALT-C and [enter} to start your CHook.

Link to comment
Share on other sites

Roger,

 

Thanks very much.

 

I checked mychook.FT file in the mcamx6\chooks\ folder, it defines the function and resource dll directory as "mcamx6\mychook\mychook.dll".

post-49696-0-48415900-1399514702_thumb.jpg

 

I think that cause my debugging a different dll from my project debug dll. so I changed it to

post-49696-0-66815000-1399514994_thumb.jpg

 

where my project locates.

 

I did not use settings->Run User Application to load my chook dll because it shows this:

post-49696-0-41602500-1399514790_thumb.jpg

 

I think this is because I specified several entry point functions in the .FT file. in the following form:

FUNCTION CPP "OpenNewCAD"

SBMP 18000

LBMP 18001

TIP 2

END_FUNCTION

 

 

Now everything seems to be fine. I am using the C:\mcamx6\sdk\x64\debug\MasterCAM.exe as command, uses C:\mcamx6\ as work directory. I am debugging the mychook.dll in my E:\mychookproject\x64\debug\ folder.

 

 

However, I come up with another problem. I can not open the .step file in my c-hook program in debug mode. I checked my program it seems when I use the MasterCAM SDK function:

 

MC_BOOL status= DoFileOpen(file,false,false,0);

The function return status=0;

 

At this point, I think the file is not open/load successfully, thus when I later want to get the entities using

get_ent(&ptr, &e_ptr, &entity, ALIVE_BIT, P_ID|L_ID|A_ID|S_ID|SURF_ID|SOLID_ID|SPLINE_ID|N_ID|W_ID|D_ID, &succf);

 

the result succf=0;

which means I did not get any entity from mastercam.

 

Therefore, when I later want to convert the entities read from .step file to a stl file, the file formed results in 0 byte. code :

post-49696-0-11862700-1399514860_thumb.jpg

and with this warning:

post-49696-0-72505200-1399514877_thumb.jpg

The stl_file here is created but no data is written into it.

 

I am confused because when I build the release mode of mychook.dll and run it using release Mastercam.exe, it works so well.

 

I even try to make mastercam load the release version of mychook.dll and in command specify the release MasterCAM.exe, but still debug it in visual studio. Detail:

in Visual Studio: Debugging->Command->C:\mcamx6\MasterCAM.exe

in C:\mcamx6\chooks\mychook.ft :

FUNC_DLL "E:\mychookproject\x64\release"

RES_DLL "E:\mychookproject\x64\release"

 

and then start debugging in Visual studio, and it turns out that the chook works out very well. I know this is a wrong way to debug, but it verifies in release mode, the file read works.

 

Thanks again.

Link to comment
Share on other sites

"Program entry point not found"

When you run a CHook via the Settings - "Run User Application" (ALT-C)

There needs to be the default entry point function called "m_main" for Mastercam to call to start your C-Hook.

Using an FT file you can define alternate entry points as you did with "OpenNewCAD".

 

As to why "DoFileOpen" would not be working in Debug, when you say it works in Release - I have no idea.

Since "DoFileOpen" is used extensively within Mastercam itself, I know that it works.

 

If you would like me to investigate further, I'm going to need your code.

You can send it to SDK[at]mastercam[[dot]com

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