Scripting with CAMMaster and Visual Basic 2008

Similar documents
Getting started 7. Setting properties 23

Starting Visual Studio 2005

A Quick Tour GETTING STARTED WHAT S IN THIS CHAPTER?

Getting started 7. Setting properties 23

Part I. Integrated Development Environment. Chapter 2: The Solution Explorer, Toolbox, and Properties. Chapter 3: Options and Customizations

COPYRIGHTED MATERIAL. Part I: Getting Started. Chapter 1: IDE. Chapter 2: Controls in General. Chapter 3: Program and Module Structure

GUI Design and Event- Driven Programming

Your First Windows Form

Visual Basic Program Coding STEP 2

Copyright. Trademarks Attachmate Corporation. All rights reserved. USA Patents Pending. WRQ ReflectionVisual Basic User Guide

CHAPTER 1 COPYRIGHTED MATERIAL. Getting to Know AutoCAD. Opening a new drawing. Getting familiar with the AutoCAD and AutoCAD LT Graphics windows

LESSON B. The Toolbox Window

CHAPTER 1 COPYRIGHTED MATERIAL. Finding Your Way in the Inventor Interface

Tutorial - Hello World

Menus. You ll find MenuStrip listed in the Toolbox. Drag one to your form. Where it says Type Here, type Weather. Then you ll see this:

The Basics of PowerPoint

Interface. 2. Interface Adobe InDesign CS2 H O T

Let s Make a Front Panel using FrontCAD

2 USING VB.NET TO CREATE A FIRST SOLUTION

PBwiki Basics Website:

LESSON A. The Splash Screen Application

The options for both the Rectangular and Elliptical Marquee Tools are nearly identical.

Copyright 2018 MakeUseOf. All Rights Reserved.

Chapter One: Getting Started With IBM SPSS for Windows

SlickEdit Gadgets. SlickEdit Gadgets

To get started with Visual Basic 2005, I recommend that you jump right in

Specification Manager

Microsoft Visual Basic 2005 CHAPTER 6. Loop Structures

Microsoft Visual Basic 2005 CHAPTER 5. Mobile Applications Using Decision Structures

Using Selection Tools and Layers

MS Word Basic Word 2007 Concepts

Creating a new CDC policy using the Database Administration Console

Boise State University. Getting To Know FrontPage 2000: A Tutorial

Midterm Exam, October 24th, 2000 Tuesday, October 24th, Human-Computer Interaction IT 113, 2 credits First trimester, both modules 2000/2001

Understanding the Interface

Excel window. This will open the Tools menu. Select. from this list, Figure 3. This will launch a window that

Using Microsoft Word. Text Editing

Quartus II Tutorial. September 10, 2014 Quartus II Version 14.0

Get comfortable using computers

MFC One Step At A Time By: Brandon Fogerty

Figure 1: My Blocks are blue in color, and they appear in the Custom palette in NXT-G.

This Tutorial is for Word 2007 but 2003 instructions are included in [brackets] after of each step.

Getting Familiar with Microsoft Word 2010 for Windows

Introduction to MS Word XP 2002: An Overview

HAPPY HOLIDAYS PHOTO BORDER

Working with Macros. Creating a Macro

PowerPoint Introduction

Document Formatting with Word

Create Reflections with Images

Advanced Financial Modeling Macros. EduPristine

Introduction to the Visual Studio.NET Integrated Development Environment IDE. CSC 211 Intermediate Programming

Tabbing Between Fields and Control Elements

Artistic Text. Basics 1

Specification Manager

bs^ir^qfkd=obcib`qflk= prfqb=clo=u

COPYRIGHTED MATERIAL. Visual Basic: The Language. Part 1

Skill Area 336 Explain Essential Programming Concept. Programming Language 2 (PL2)

Excel Vba Manually Update Links Automatically On Open Workbook Don

CHAPTER 3. Entering Text and Moving Around

Windows XP. A Quick Tour of Windows XP Features

HOUR 4 Understanding Events

Form into function. Getting prepared. Tutorial. Paul Jasper

The Filter Property Selecting a File The Save Menu The SaveFileDialog Control The Edit Menu The Copy Menu...

Basic Operation of Flash MX Professional 2004

COPYRIGHTED MATERIAL. Starting Strong with Visual C# 2005 Express Edition

Using Visual Studio.NET: IntelliSense and Debugging

Use signatures in Outlook 2010

GUARD1 PLUS Documentation. Version TimeKeeping Systems, Inc. GUARD1 PLUS and THE PIPE are registered trademarks

Computer Concepts for Beginners

Getting Started with Windows XP

GUARD1 PLUS Manual Version 2.8

Karlen Communications Track Changes and Comments in Word. Karen McCall, M.Ed.

Tutorial 03 understanding controls : buttons, text boxes

If this is the first time you have run SSMS, I recommend setting up the startup options so that the environment is set up the way you want it.

The purpose of this tutorial is to introduce you to the Construct 2 program. First, you will be told where the software is located on the computer

SNOWFLAKES PHOTO BORDER - PHOTOSHOP CS6 / CC

Visual Basic. murach s. (Chapter 2) TRAINING & REFERENCE. Mike Murach & Associates, Inc.

Chapter11 practice file folder. For more information, see Download the practice files in this book s Introduction.

Outlook Web Access. In the next step, enter your address and password to gain access to your Outlook Web Access account.

Visual Basic 2008 Anne Boehm

Welcome Application. Introducing the Visual Studio.NET IDE. Objectives. Outline

The Polygonal Lasso Tool In Photoshop

NiceForm User Guide. English Edition. Rev Euro Plus d.o.o. & Niceware International LLC All rights reserved.

Debugging in AVR32 Studio

Program and Graphical User Interface Design

The Mathcad Workspace 7

PagePlus X7. Quick Start Guide. Simple steps for creating great-looking publications.

The NetBeans IDE is a big file --- a minimum of around 30 MB. After you have downloaded the file, simply execute the file to install the software.

Volume CREATIVE DATA TECHNOLOGIES, INC. DATALAYER.NET. Getting Started Guide

Word Processing vs. Desktop Publishing

Adding A Signature To A Photograph By Jerry Koons

Viewing conditional text

SuperNova. Magnifier & Speech. Version 15.0

As you probably know, Microsoft Excel is an

PSpice Tutorial. Physics 160 Spring 2006

VBA Foundations, Part 7

StudioPrompter Tutorials. Prepare before you start the Tutorials. Opening and importing text files. Using the Control Bar. Using Dual Monitors

Windows Application Development Tutorial for ASNA Visual RPG 8.0 for Microsoft Visual Studio.NET 2005

Basic Concepts. Launching MultiAd Creator. To Create an Alias. file://c:\documents and Settings\Gary Horrie\Local Settings\Temp\~hh81F9.

Easy Windows Working with Disks, Folders, - and Files

Transcription:

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 and improved performance. Once programmed properly, scripts don t make mistakes. This ensures higher quality. Using scripts can help users that are not familiar with CAMMaster to become productive quickly. Scripts can be written to ensure 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 familiar with the Visual Basic programming language can utilize it to automate CAMMaster. In our opinion, the serious script writer should consider using Visual Basic 2008 (previously known as VB.NET) to write CAMMaster scripts. VB 2008 is a very powerful object oriented language based upon the Microsoft.NET framework. Programs generated using VB 2008 and compiled under the.net framework run very quickly. This document provides a brief overview of how to automate CAMMaster using Visual Basic 2008. Visual Basic 2008 is offered by Microsoft and is available in several different configurations. It is available as a low cost standalone product or as part of one of the many Visual Studio packages. The examples shown in this application note are created using the Professional edition of Visual Studio 2008. 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. Copyright 2008 PentaLogix, LLC All rights reserved Page 1

Configuring Visual Studio Start Visual Studio and select Tools >Options as shown below. Expand the Environment node and select the Keyboard node. Ensure that the keyboard mapping scheme is set to Visual Basic 6. Click on OK to dismiss the dialog. Copyright 2008 PentaLogix, LLC All rights reserved Page 2

Starting a New Project You save data pertaining to your script in a Microsoft Visual Studio project. To start a new project, either press Ctrl+N or select File >New Project as shown below: Ensure that you select the Windows Forms Application project type. Name your project My First Script and click on the OK button. Copyright 2008 PentaLogix, LLC All rights reserved Page 3

Starting a New Project continued After creating the new project, your screen should appear as shown below: Copyright 2008 PentaLogix, LLC All rights reserved Page 4

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 use these features, you must add a reference to the CAMMaster Tool Class. Select Project >Add Reference Click on the COM tab and then scroll down and select the PentaLogix CAM tools Type Library entry. Click on the OK button to add the CAMMaster Tool Class to your project. In the upper right corner, click on the Show All Files button and then expand the References folder. Notice that the CAMMaster tool class reference has been added to your project. Copyright 2008 PentaLogix, LLC All rights reserved Page 5

Adding Some Controls to Your Startup Form Click on the Show All Files button again to hide the support files of your project. Ensure that you click on the item called Form1.vb as shown below: When you start your project, this form will be displayed. Let s add a few controls to this form. Start by expanding the Common Controls folder in the ToolBox window. Then drag a button control onto your form as shown below: Copyright 2008 PentaLogix, LLC All rights reserved Page 6

Adding Some Controls to Your Startup Form continued If not already selected, click on the button to select it. Notice the Properties window in the lower right of the screen. Enter the words Do Now for the button Text and press Enter Scroll up in the Properties window and name the button btndonow. Copyright 2008 PentaLogix, LLC All rights reserved Page 7

Adding Some Controls to Your Startup Form continued Expand the Containers folder in the Toolbox window and drag a GroupBox control onto your form as shown below. You may need to reposition and resize it as appropriate. With GroupBox1 selected, set the Text property to Show and the Name property to grpshow. Your form should now look as follows: Copyright 2008 PentaLogix, LLC All rights reserved Page 8

Adding Some Controls to Your Startup Form continued Finally, add four radio button controls to your form as shown below: Set the Name and Text properties of each radio button as shown in the table below: Name opttraces optpads optbothtracesandpads optneithertracesnorpads Text Traces Pads Both Traces And Pads Neither Traces Nor Pads Copyright 2008 PentaLogix, LLC All rights reserved Page 9

Running the Program for the First Time We have now added the controls we need for our project. We will have to write some code that responds to the controls. However, for now, let s run our program. Press F5 or select Debug >Start Debugging as shown below: Our program should start and be displayed as shown below: Notice that none of the radio buttons are selected when the form starts. You can click on the individual radio buttons. Notice that the previously selected button is deselected when a new radio button is clicked. This is part of the built in operation when several radio buttons are placed into a group box control. You can also click on the Do Now button. Nothing happens... because we haven t written the Event Handlers for our controls. We ll do this in a subsequent section. But first, we ll declare some variables and import the CAMMaster tool class into our project. Exit the program before continuing. Copyright 2008 PentaLogix, LLC All rights reserved Page 10

Declaring Variables and Importing the CAMMaster Tool Class Ensure that the Form1 item is selected in the Solution Explorer. Then click on the View Code button as shown below: The code associated with Form1.vb is shown in the center part of the screen: Place the cursor at the beginning of the word Public and press the Enter key twice to add a couple of blank lines to the top of the code. Move the cursor to the beginning of the first line and start typing Imports. You ll notice that as soon as you type the I, Visual Studio will display the following Intellisense window: Press the Tab key and Visual Studio will automatically add the word Imports to your code. Copyright 2008 PentaLogix, LLC All rights reserved Page 11

Declaring Variables and Importing the CAMMaster Tool Class continued When you press the spacebar, Visual Studio next suggests the following items to be imported. Press the C key and the Intellisense choices are narrowed to CAMMaster. Press the Tab key to add the word CAMMaster to the code. Your code should now look as shown below: In our code we will need a variable that references the CAMMaster Tool Class. Let s call this variable CAM. Declare the variable by adding the following line to your code. Make sure that you add this line below the Public Class Form1 line and above the End Class line as shown in the figure below. Also add three variables called IsTrue, IsFalse and stritemstoshow as shown: Copyright 2008 PentaLogix, LLC All rights reserved Page 12

Writing Code to Respond to the Radio Button Controls We need to respond when the user selects one of the radio buttons. Add the following code above the End Class line. Note that you should use the Intellisense features whenever possible to avoid unnecessary typing. We will call this subroutine anytime the user clicks one of the radio button controls. In the first line, we identify which radio button was clicked. Notice that when you click a radio button, this subroutine will be called twice. It will be called the first time when the previously selected radio button is deselected. We don t want to respond to this event, so we exit the subroutine if the radio button is not checked. The routine is entered a second time when the new radio button is checked. In this case, we process the rest of the routine. We now need to tie each of the radio button controls to the optrb_checkedchanged event handler. Add the following code above the optrb_checkedchanged subroutine (notice that I ve collapsed the optrb_checkedchanged subroutine for clarity). Copyright 2008 PentaLogix, LLC All rights reserved Page 13

Writing Code to Respond when the Do Now Button is Clicked I think it is preferable to write event handlers as shown in the previous section. However, there is a simpler way to write an event handler. We ll do this now for the btndonow.click event handler. Click on the View Designer button to switch back to the Design view from the Code view: Double click on the Do Now button. Visual Studio adds a subroutine that will be called every time the user clicks the Do Now button. The view is automatically switched back to the Code view and Visual Studio automatically adds the following subroutine (shown below the optrb_checkedchanged subroutine): Add the following code to the new subroutine: Notice the With CAM... End With block. This lets you write.tracesvisible and.padsvisible instead of CAM.TracesVisible and CAM.PadsVisible respectively. Copyright 2008 PentaLogix, LLC All rights reserved Page 14

Initializing the Form The Page Load Event When our program starts, we need to make sure that certain things are initialized. For example, we need to call the subroutine that will add our event handlers. We also need to activate one of the radio buttons by default. Before adding the Page Load event, your code should appear as follows (all subroutines are collapsed for brevity): Click in the Class Name combo box and select the Form1 (Events) item as shown below: Then, click in the Declarations combo box, scroll down and select the Load item as shown below: Copyright 2008 PentaLogix, LLC All rights reserved Page 15

Initializing the Form The Page Load Event continued Visual Studio adds a subroutine called Form1_Load. This subroutine is executed when your program starts and the main form is loaded. Add the following code to the Form1_Load subroutine: Notice that we first call the subroutine that adds the event handlers. We then make sure that the option to select both traces and pads is selected. Finally, we ask that the btndonow.click event is called. Copyright 2008 PentaLogix, LLC All rights reserved Page 16

Run the Final Program To run without errors, you should ensure that you have exactly one instance of CAMMaster started before you start your program. Start CAMMaster and load a file that contains both traces and pads. To make things easier, it s probably best to activate only one layer: Now start your program by switching to Visual Studio and pressing F5. Your program should appear as shown below: Click on the Traces radio button and then click on the Do Now button... voila! We hope that this tutorial helps you get started with VB 2008 and CAMMaster. There s lots more to learn. Please feel free to call on us for additional information! Copyright 2008 PentaLogix, LLC All rights reserved Page 17