Scripting with CAMMaster And Visual Basic.NET
Introduction CAMMaster is a very high performance CAM software program. Most of the functions that you can perform manually can be automated by utilizing the methods and properties that are exposed by CAMMaster. These methods and properties can be controlled by writing scripts. Scripts are essentially a recorded set of instructions that tell CAMMaster to perform a desired set of operations. There are many advantages to utilizing scripts with CAMMaster: Repetitive and/or tedious operations can be performed very quickly. This results in reduced operator fatigue. Once programmed properly, scripts don t make mistakes. This insures higher quality. Using scripts can help users that are not familiar with CAMMaster become productive quickly. Scripts can be written to insure that no procedural steps are missed when generating your CAM data. There are many ways to generate CAMMaster scripts. You can utilize the built in SAX Basic editor to record, store and run macros (simple scripts). Those who are familiar with the Visual Basic programming language can utilize it to automate CAMMaster. Microsoft has been developing a newer software framework known as.net (pronounced dot net ). The.NET framework includes a new sophisticated Visual Basic programming language called Visual Basic.NET (or VB.NET for short). Unlike previous versions of Visual Basic, VB.NET is a very powerful object oriented language. Programs generated using VB.NET can run very quickly. This document provides a brief overview of how to automate CAMMaster using the Microsoft.NET framework. The examples shown in this document were created using the Professional edition of Visual Basic.NET, from within version 7.1 of Microsoft s Visual Studio.NET. This document is not intended to be an exhaustive treatment of the subject. It is intended to give the user interested in scripting CAMMaster a starting point for further development.
Configuring Visual Studio To configure the.net environment perform the following steps. Start Visual Studio. If not displayed by default, display the start page by selecting Help ->Show Start Page as shown in figure 1 below: Figure 1 Displaying the Visual Studio Start Page
Configuring Visual Studio continued. Click on the My Profile tab to display your Visual Studio profile settings. Set all selections as shown in figure 2 below: Figure 2 My Profile Configured for a VB.NET user.
Starting a new project. You save the data pertaining to your script in a Microsoft Visual Studio project. To start a new project, either press Ctrl+N of select File->New->Project as shown in figure 3 below: Figure 3 Starting a new project.
Starting a new project - continued. In response the New Project dialogue is shown as shown in figure 4. Figure 4 New Project dialogue. Make sure that the Windows Application icon is selected in the Templates window. Enter CAMMaster Sample Script into the Name: text box. Accept the default project location or select a different directory to store your project in by clicking on the Browse button.
Starting a new project - continued. Click on the OK button to create the new project. In response, the Microsoft Visual Studio development environment is displayed as shown in figure 5 below: Figure 5 Visual Studio Development Environment New project loaded.
Adding the CAMMaster tool class reference. CAMMaster uses Active X to expose the many methods and properties that you can utilize to automate the operation of the program. To utilize these features, you must add a reference to the CAMMaster tool class. Select Project->Add Reference as shown in figure 6 below: Figure 6 Select Project->Add Reference
Adding the CAMMaster tool class reference - continued. Once the Add Reference dialogue is presented, perform the following steps: Click on the COM tab near the top of the dialogue. Scroll to the PentaLogix CAM-tools Type Library and click on this entry. Click on the Select button to add the library to the Selected Components list. Your screen should appear as in figure 7 below: Figure 7 Add Reference dialogue with PentaLogix CAM-tools Type Library selected. Click on the OK button to accept your choice.
Adding the CAMMaster tool class reference - continued. Notice the location of the cursor near the upper right hand corner of figure 8 below. You can see that the CAMMaster tool class has been added as a reference to the project. Figure 8 CAMMaster tool class added as a project reference.
Adding a code module. Now let s add a code module and name it Sample.vb. Select Project->Add Module as shown in figure 9 below: Figure 9 Adding a Module.
Adding a code module - continued. In response, Visual Studio displays the Add New Item dialogue as shown in figure 10 below: Figure 10 Add New Item dialogue. Enter the text Sample.vb into the Name: text box. Then click on the Open button to display the new code module. Add the following text to the new code module: Option Strict On Imports CAMMaster Module Sample Public CAM As New CAMMaster.Tool End Module
Adding code. You have now added a reference to the CAMMaster tool class and you have dimensioned the tool class so that you can use it. Now modify the Sample.vb module as shown below: Option Strict On Imports CAMMaster Module Sample Public CAM As New CAMMaster.Tool Public IsFalse As Integer = 0 Public IsTrue As Integer = 1 Sub main() With CAM.TracesVisible = IsFalse End With End Sub End Module
Select the Startup object. Select Project->CAMMaster Sample Script Properties as shown in figure 11 below: Figure 11 Select Project->CAMMaster Sample Script Properties
Select the Startup object continued. In response, the CAMMaster Sample Script Property Pages dialogue is displayed as shown in the figure below: Figure 12 The CAMMaster Sample Script Properties Pages dialogue. Select the Sub Main entry from the Startup object: combo box. This will insure that our Main subroutine will be used as the startup object. Run the program. Start CAMMaster and load a job that contains both pads and traces. From the Visual Studio main menu, select Debug->Start or press the F5 key to run your program. Switch back to CAMMaster and notice that the traces have now been turned off. Summary. This brief introduction to scripting with CAMMaster and VB.NET is intended to get you started. We will provide future application notes that will expand on this topic. If you have any questions, please forward them to max@pentalogix.com.