Scripting with CAMMaster
And
Scripting with CAMMaster and Visual Basic.NET
Copyright 2005 by PentaLogix, LLC – All rights reserved.
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.
Scripting with CAMMaster and Visual Basic.NET
Copyright 2005 by PentaLogix, LLC – All rights reserved.
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:
Scripting with CAMMaster and Visual Basic.NET
Copyright 2005 by PentaLogix, LLC – All rights reserved.
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:
Scripting with CAMMaster and Visual Basic.NET
Copyright 2005 by PentaLogix, LLC – All rights reserved.
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:
Scripting with CAMMaster and Visual Basic.NET
Copyright 2005 by PentaLogix, LLC – All rights reserved.
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
Scripting with CAMMaster and Visual Basic.NET
Copyright 2005 by PentaLogix, LLC – All rights reserved.
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:
Scripting with CAMMaster and Visual Basic.NET
Copyright 2005 by PentaLogix, LLC – All rights reserved.
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:
Scripting with CAMMaster and Visual Basic.NET
Copyright 2005 by PentaLogix, LLC – All rights reserved.
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.
Scripting with CAMMaster and Visual Basic.NET
Copyright 2005 by PentaLogix, LLC – All rights reserved.
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.
Scripting with CAMMaster and Visual Basic.NET
Copyright 2005 by PentaLogix, LLC – All rights reserved.
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:
Scripting with CAMMaster and Visual Basic.NET
Copyright 2005 by PentaLogix, LLC – All rights reserved.
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
Scripting with CAMMaster and Visual Basic.NET
Copyright 2005 by PentaLogix, LLC – All rights reserved.
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
Scripting with CAMMaster and Visual Basic.NET
Copyright 2005 by PentaLogix, LLC – All rights reserved.
Select the “Startup” object.
Select “Project->CAMMaster Sample Script Properties…” as shown in figure 11 below:
Scripting with CAMMaster and Visual Basic.NET
Copyright 2005 by PentaLogix, LLC – All rights reserved.
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 [email protected].