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:

How to automate tool library editing in 2017?


Eric Rawls
 Share

Recommended Posts

In previous versions we had the option to export tools to a text file via Tool Manager, manipulate the text compumatically with our own programs, then import the text back into a tool library via Tool Manager.

 

It seems that the option to convert to text is no longer available. Editing the tools one at a time is too tedious. I would really like to let a script do the work for me. How can we do this with Mastercam 2017?

 

thanksinadvancesmartpeople.gif

  • Like 2
Link to comment
Share on other sites

In previous versions we had the option to export tools to a text file via Tool Manager, manipulate the text compumatically with our own programs, then import the text back into a tool library via Tool Manager.

 

It seems that the option to convert to text is no longer available. Editing the tools one at a time is too tedious. I would really like to let a script do the work for me. How can we do this with Mastercam 2017?

 

thanksinadvancesmartpeople.gif

It's SQL based now... A custom app could handle it the way you want...
Link to comment
Share on other sites

So a text file like this out of MC:

The text I was initially referring to would be generated from a right-click menu in the Tool Manager. In the older versions of Mastercam, you could highlight tools in the Tool Manager, right-click, and export to a text file. The first part of the text file would be a key explaining the output, and below that would be a table of codes for each tool. All tool attributes would be available: name, type, diameter, corner radius, stepover, speed, feed, etc. It made it really easy to make changes to multiple tools, e.g., coolant on for all drills, stepover a certain percent of diameter for end mills, etc. Then the text file could be converted back into a tool library by importing the text file in Tool Manager.

 

It seems that it is now a relic of days gone by.

Link to comment
Share on other sites

It's SQL based now... A custom app could handle it the way you want...

This will be a learning experience. I have done some work with VB.NET and am comfortable with Visual Studio. Some google searching has led me to believe that ADO.NET may be the way to go here, and I am really ignorant in that department. If anyone here is familiar with ADO.NET, could you tell me if I will be able to access the file directly, or will I need to set up a virtual machine to serve the database?

 

 

 

Edit: Upon further reflection, I have decided that learning a new language is a lot more work than editing some tools one by one. I think the simplest solution for me is to wipe out most of the tool library and edit the tools that are left, one by one. hakunamatata.gif

 

 

Edit2: It sucks to edit 150+ drills one by one, doing something that the computer could do with a click of a button. I'd like to set all of them to 1 flute so that IPR is displayed when programming. I'll get it done manually in this case, but ...

 

If anyone comes across this thread and cares to explain like I'm five how to edit the tool database programmatically for Mastercam 2017 that would be great. If I ever figure it out I will post an update.

Link to comment
Share on other sites

I have MC 2017 HLE. I'll try to do something with their SQLLite database in vb.net and post a sample.

 

Don't get worried about ADO and other terms. There are many ways to accomplish this and the recipe is pretty straightforward, with little variations...

 

The most important thing is to start to study the tables and columns, and learn the basic of sql language. If you don't know how to build queries, no development language in the world will do it automatically for you.

Link to comment
Share on other sites

Thank you Roger.

 

Eric, I should have something for you by Wednesday...

 

Would you mind to cite an example? Like, "I want to mass change the tool descriptions starting with "123"...

 

I won´t build a do it all application for you but I´m willing to create a few real world examples so you can figure out the rest and re-use my code to build it the way you wanna it...

Link to comment
Share on other sites

Eric,

 

This is what I´m going to do:

 

  • Allow you to export several parameters from the Tool Manager DB to an Excel file
  • Allow you to import from this file back to Tool Manager DB to update your fields

 

BUT some rules:

 

  • I won´t allow you to change your tool IDs, because this is the primary key and column name I´ll use to make sure you´re updating the same tools you exported via app. This means I won´t allow you to insert new tools in the spreadsheet and/or create them in the Tool Manager via spreadsheet.
  • In this code sample I´ll only allow you to update existing tools. I didn´t study the MC database yet, but it´s likely that there are cross referenced constraints that use more than one table to completely define a tool. By allowing you to update back only what already exists, I´m not supposed to break any existing constrain or create corrupted entries.
  • I´ll do my best to code a robust solution that won´t break anything on your tool database. But If I do, I won´t accept any liability for that. Use it at your own risk.

 

I´ll post a solution until the end of this week... With complete (And commented) source code + the Visual Studio Project (I´m using VS 2012 Premium). If you want to use Ok, if not, Ok too.  :fun:

 

This shall help you to engage on software development.. VB is a pretty good start... 

  • Like 1
Link to comment
Share on other sites

Eric,

 

This is what I´m going to do:

 

  • Allow you to export several parameters from the Tool Manager DB to an Excel file
  • Allow you to import from this file back to Tool Manager DB to update your fields

 

BUT some rules:

 

  • I won´t allow you to change your tool IDs, because this is the primary key and column name I´ll use to make sure you´re updating the same tools you exported via app. This means I won´t allow you to insert new tools in the spreadsheet and/or create them in the Tool Manager via spreadsheet.
  • In this code sample I´ll only allow you to update existing tools. I didn´t study the MC database yet, but it´s likely that there are cross referenced constraints that use more than one table to completely define a tool. By allowing you to update back only what already exists, I´m not supposed to break any existing constrain or create corrupted entries.
  • I´ll do my best to code a robust solution that won´t break anything on your tool database. But If I do, I won´t accept any liability for that. Use it at your own risk.

 

I´ll post a solution until the end of this week... With complete (And commented) source code + the Visual Studio Project (I´m using VS 2012 Premium). If you want to use Ok, if not, Ok too.  :fun:

 

This shall help you to engage on software development.. VB is a pretty good start... 

 

Awesome! I didn't expect such a generous response. I'm honored. Thanks a lot.

 

 

Edit: In another comment, you had asked me to cite an example.

 

One thing I did manually was to alter the number of flutes (change 2 to 1) for all drills. That's done now, but still a good example of desired capability.

 

One thing I *almost* did was append the diameter to the end of the tool name (tool ID?). I decided against doing that and made a post mod in the ptoolcomment postblock to do that, so that the actual programmed diameter is appended to the tool comment at post time, to prevent any accidental lies in my comments.

 

Something I may want to do in the future is use the tool's step and peck values when programming. I would *definitely* want to set that programmatically to avoid pecking a calculator for each tool.

 

Thanks again.

Link to comment
Share on other sites

The functionality to import/export a tool database still exists in 2017 but it is turned off by default.

To enable via the Win7 Start button: All programs > Mastercam 2017 > Utilities > Advanced Configuration > User Interface > Show Tool Manager option for text file import/export (Enable)

 

BTW... I am very interested in the import/export application Watcher is developing... it would be very useful and informative!

Link to comment
Share on other sites

it will be ready this weekend.. I already finished the code to read the database and populate a list box... and export to Excel... now I need to code the reverse process: read from Excel and update the database.

 

Note to you: Get ready to learn SQL inner joins... Mastercam tooldb files use tables referencing each other, quite a bit. Seldom a single table gives you all meaningful parameters. Fortunately my application will come with a good example of inner joins...

 

I will finish it this weekend... Been quite busy in the last two days...

  • Like 2
Link to comment
Share on other sites

Ok...

 

I put an extra hour into it this morning and was able to have the reading and exporting functionality working fine...

 

The link is here for those who want to take a look at it...

 

https://drive.google.com/drive/folders/0B-zWGlBf98V0UkZfVERUcG5VMmc?usp=sharing

 

I´ll finish the import functionality this weekend...

 

In the folder from the link above, there are two sub folders:

 

Executables: The executables - If you don´t have Visual Studio and cannot compile the project, you have have a sneak peak of how the app works.

 

VSProject: The full Visual Studio Solution - You need to have Visual Studio 2012 or higher to open it. If you do´t have Visual Studio, I encourage you to download Visual Studio 2015 Community - It´s free and fully functional.

 

I tested it with tooldb files from the Mastercam Shared folder I have in the HLE version. The file mill_mm.tooldb is the one I used the most. Please test it with your current custom library if possible. It won´t do any damage because at this point it only reads data from the SQLite database.

 

Keep in mind this application is currently limited to the queries that are hardcoded into it. It´s not my plan to make it a fully featured solution: I just wanted to provide some base code to show how to code something that can read/write Mastercam tooldb files. If you open your files now and don´t see an specific column, it´s likely because the sample query I provided is not fetching it. Although I tried to make it easy to understand and well commented, it´s up to you to customize/ expand it´s functionality to have it your own way.

 

I coded the export to Excel function in a way that you don´t have to worry about changing the code to export to Excel something that is on the listview already. If you made it appear on the listview, my function will get it into the Excel file for you. The trick is to change the query and add more columns to show the extra data you want. In my sample query I´m querying endmills, but you can change it to whatever you want... Again.. it´s just a reference, a start for those trying to dive into it...

 

I´ll provide some further documentation about how to add SQLite and other references to the Visual Studio solution, as well as discuss some important concepts. I´ll do it when I finish the code to import data. If you need help to add missing references now, take a look at the code, and in the function ExportListViewToXLSxFile. There I commented out about how to add the Microsoft.Office.Interop.Excel class reference. If any other problem arise, let me know and I can explain...

 

Last but not least, I think this thread may belong to the development forum. It would be good if a mod move it to there to help other people...

 

This project is a modest contribution, I know, and I´m trying to make it as simple as possible to help beginners to understand how to do make it. Please bear with me if something is not sophisticated enough.

  • Like 3
Link to comment
Share on other sites

Ok...

 

I put an extra hour into it this morning and was able to have the reading and exporting functionality working fine...

 

The link is here for those who want to take a look at it...

 

https://drive.google.com/drive/folders/0B-zWGlBf98V0UkZfVERUcG5VMmc?usp=sharing

 

I´ll finish the import functionality this weekend...

 

In the folder from the link above, there are two sub folders:

 

Executables: The executables - If you don´t have Visual Studio and cannot compile the project, you have have a sneak peak of how the app works.

 

VSProject: The full Visual Studio Solution - You need to have Visual Studio 2012 or higher to open it. If you do´t have Visual Studio, I encourage you to download Visual Studio 2015 Community - It´s free and fully functional.

 

I tested it with tooldb files from the Mastercam Shared folder I have in the HLE version. The file mill_mm.tooldb is the one I used the most. Please test it with your current custom library if possible. It won´t do any damage because at this point it only reads data from the SQLite database.

 

Keep in mind this application is currently limited to the queries that are hardcoded into it. It´s not my plan to make it a fully featured solution: I just wanted to provide some base code to show how to code something that can read/write Mastercam tooldb files. If you open your files now and don´t see an specific column, it´s likely because the sample query I provided is not fetching it. Although I tried to make it easy to understand and well commented, it´s up to you to customize/ expand it´s functionality to have it your own way.

 

I coded the export to Excel function in a way that you don´t have to worry about changing the code to export to Excel something that is on the listview already. If you made it appear on the listview, my function will get it into the Excel file for you. The trick is to change the query and add more columns to show the extra data you want. In my sample query I´m querying endmills, but you can change it to whatever you want... Again.. it´s just a reference, a start for those trying to dive into it...

 

I´ll provide some further documentation about how to add SQLite and other references to the Visual Studio solution, as well as discuss some important concepts. I´ll do it when I finish the code to import data. If you need help to add missing references now, take a look at the code, and in the function ExportListViewToXLSxFile. There I commented out about how to add the Microsoft.Office.Interop.Excel class reference. If any other problem arise, let me know and I can explain...

 

Last but not least, I think this thread may belong to the development forum. It would be good if a mod move it to there to help other people...

 

This project is a modest contribution, I know, and I´m trying to make it as simple as possible to help beginners to understand how to do make it. Please bear with me if something is not sophisticated enough.

 

Excellent contribution sir!!!! :thumbsup: :thumbsup: :thumbsup:

Link to comment
Share on other sites

Daniel,

 

Thank you for sharing this project! I looked at the link you provided. Some of the common parameters are inaccessible when multiple tools are selected in the external tool library manager, but your solution may provide the means to handle those situations. I apologize for dropping out of the conversation for the past week; I've been tied up. I very much look forward to learning from what you've done here.

Link to comment
Share on other sites

I'm sorry I did not update the project to import data. I was planning to do it last weekend but wife told me it was her or my laptop... I made the right decision I guess...

 

I've been quite busy in the past weeks implementing cycle 19 on old Heidenhain controls here... so I'm quite tired when I get home... It's not a big deal in terms of programming... Just needs to be coded... I'll finish it as soon as possible...

Link to comment
Share on other sites

I'm sorry I did not update the project to import data. I was planning to do it last weekend but wife told me it was her or my laptop... I made the right decision I guess...

 

I've been quite busy in the past weeks implementing cycle 19 on old Heidenhain controls here... so I'm quite tired when I get home... It's not a big deal in terms of programming... Just needs to be coded... I'll finish it as soon as possible...

 

No need to apologize sir. Thank you for your efforts and wish you all the best.

 

Yes you made a great decision letting your wife use the laptop.

  • Like 3
Link to comment
Share on other sites
  • 1 year later...
  • 4 years later...
  • 8 months later...

Any updates on this topic? 

I have a question that's sort of related to this subject.

I want to programmingly request tool data from Mastercam. 

Could someone please elaborate on the API methods utilized by tools like the VERICUT chook to requisition cutter data from a specified toolpath group within the toolpath manager. The encompassed tool data comprises vital attributes: tool ID, descriptive information, classification (turning or milling), gauge length, CAD profile coordinates of the cutter, gage length, rotational aspects, and orientation.

From within the tool data retrieval methods are their GET functions I can use to control the format/structure of the data I've requested? 

Link to comment
Share on other sites
3 hours ago, DBronson said:

Any updates on this topic? 

I have a question that's sort of related to this subject.

I want to programmingly request tool data from Mastercam. 

Could someone please elaborate on the API methods utilized by tools like the VERICUT chook to requisition cutter data from a specified toolpath group within the toolpath manager. The encompassed tool data comprises vital attributes: tool ID, descriptive information, classification (turning or milling), gauge length, CAD profile coordinates of the cutter, gage length, rotational aspects, and orientation.

From within the tool data retrieval methods are their GET functions I can use to control the format/structure of the data I've requested? 

That would be done with nethook or chook. I think so at least, I don't know how it works exactly, still learning.

 

You would probably find more on the subforum:

https://www.emastercam.com/forums/forum/10-mastercam-c-hook-net-hook-and-vbscript-development/

  • Like 1
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...