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:

Project Information Saved with MCX


Recommended Posts

Like many who post here, I've always wanted to learn how to write CHooks (NETHooks) but thought it would be too complex. I have installed VS Express 2012, SDK from Microsoft, the examples and samples from Mastercam as well as some other information from the internet and this forum. I have searched through this forum and found a few things that are close to what I want to do but not quite.

 

I am trying to create a place to store and output project information i.e. Customer, Part Number, Revision, Job Number, and NC revision number. I started by exhausting the buffer file option in MP.exe without acceptable results so I am looking for the path of least resistance to accomplish this. The Holy Grail would be to have an Operations Manager Tab with user customizable fields to enter this information then have the ability to output this data to NC as well as an Excel file for an MRP system to parse the data.

 

I will be excited as groom on his honeymoon if I can get a NetHook to write a .csv or .xml file with the data then read it again for the NC revision level. I accomplished this with the MP.exe buffer file however, it kicked up an error that I couldn't remove; the first time the post runs, the output file doesn't exist for the previous revision level value call.

 

From what I have read this is all doable in a CHook but I have not seen a solution that captures it.

 

Questions:

1.) Is there a Third-Party Developer that has done this already? If yes, is it customizable for file location, field labels, etc.?

2.) If I decide to tackle this myself, will the software I listed above be enough to accomplish the tasks?

3.) Where would you start?

 

Thanks!

-Pat

Link to comment
Share on other sites

I write only Nethooks, and have tried several things to do exactly what you are trying to do. I'm not aware of the 'buffer' option of MP.exe, but from your post I might assume that there wasnt enough room?

 

VeriSurf has a 'NotePad' CHook that stores information. I do not know how this is accomplished, tho.

 

I also looked into the structured storage option (right click on a Mcx file in windows explorer, select 'Properties', then select the 'Descriptor' tab). However, while the user can enter this data from within MasterCam, (click "File", "Properties") I saw nothing in the NetHook API to allow me access to this. And while it can be written to Programmatically from .NET, it cannot be done while the Mcx file is open.

 

 

The benefit of this approach is that structured storage can be read directly from the file by other applications, without having to have the parent application (MasterCam) installed! Also, it wont require an additional exported file. I've used this approach in Acad, and different Office apps. Is there access to the structured storage from a CHook? I'd be VERY interested in this....

Link to comment
Share on other sites

rocheey1,

 

Thanks for the information! Excuse my ignorance because I am totally new to this; would it be possible to have the nethook write the project data to a memory buffer while in MC then any time an MC save is executed the buffer would populate the structured storage?

 

 

As for the MP buffer file output, it worked great for exporting an ASCII text file until I hit the ceiling of my NC revision number counter needs to read the previous revision to increment. This works great when a file exists. However, when you post a file for the first time and the file does not exist the MP.exe reports an error for the missing file.

 

Thanks,

-Pat

Link to comment
Share on other sites

would it be possible to have the nethook write the project data to a memory buffer while in MC then any time an MC save is executed the buffer would populate the structured storage?

 

I'm not sure what type of memory buffer you'd be referring to .... but since NetHooks dont have access to the structured storage thru MasterCam, the only way I've been able to do it was from the outside (using dsofile.dll). But coming from the outside, as an external program, dso wont allow writing to the structured storage while the Mcx file is open. So I've only been able to READ the props using .Net :(

 

As for the MP buffer file output, it worked great for exporting an ASCII text file until I hit the ceiling of my NC revision number counter needs to read the previous revision to increment. This works great when a file exists. However, when you post a file for the first time and the file does not exist the MP.exe reports an error for the missing file.

 

So, part of this is being run after code has been posted? The only sure way I know of to make sure the posted file is there (and it could be anywhere, since the user can override the location and/or name of the GCode, or even Cancel posting altogether) is to call a hook from within the post itself. I've had great success with doing this from NetHooks, I'd imagine CHooks would have this capability.

 

Check out This Link: http://www.emastercam.com/board/index.php?showtopic=57228&hl=launch#entry640643

Link to comment
Share on other sites

Yes the buffer files are written after posting is complete. Now that you mention it, that will do it. Now if I wouldn't have given my customer the idea that there is a way to have fields to populate in MC for this data... *Sigh*.... It's all good, I'm learning something new.

 

When I started this project I didn't think I'd be as deep as I currently am. I'm learning C# .NET language now with hopes that I won't be starting over when I want to write a CHook.

 

Thanks!

Link to comment
Share on other sites

if you have the data, and it can be written, then why cant you read it back and put it in a form? Attach it to an .ft file and assign it an icon, and its in a toolbar.

 

That was my plan until you brought up the file descriptor. That was more appealing due to there not being an additional file to manage.

Link to comment
Share on other sites

That was my plan until you brought up the file descriptor. That was more appealing due to there not being an additional file to manage.

 

Still the same, isnt it ? Read the data out of the file descriptor, seed the info on the form.....if the User makes changes to the data on the form, write the data back to the file descriptor.

Link to comment
Share on other sites

I was speaking of MY code, which uses NetHooks. You mentioned you are writing CHooks - from what I've read here, many things are possible in CHooks that are not available for NetHooks. I wouldnt be the guy to ask where to look, unfortunately, but if you can access the File Props from within CHooks, you'd be able to read/write your data while MasterCam is open.

Link to comment
Share on other sites
  • 3 months later...

Well I finally got something to work close to what I envisioned.

 

Please give me your thoughts/criticism.

 

Thanks,

-Pat

 

Hi Pat!

I really liked your solution, you made a great job! I'm plannig some similar to do.

But I have some questions here. Do you use a temporary file to store those values or those are written into directly into the MCX file?

Or in the descrtiptor...?

What methods you used in your C-Hook or NET-Hook?

 

I planning to use an independent entity on a given level (C-Hook) and put some datas into. Just a plan yet. :)

 

THX!

Peter

Link to comment
Share on other sites

Hi Peter,

 

My current app saves the data to a MS Access Database file. The cool thing is that you don't need MS Access to run it. I am also working on a version that saves to SQL DB as well as with the MCX file. Not the descriptor.

 

I am not willing to share code here as I am in the process of marketing it.

 

If you are interested in what I have message me.

 

Thx,

-Pat

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