Welcome to: Bentley Bash 2011. Customizing MicroStation via VBA. Created by Mike Lazear Archway Systems, Inc.



Similar documents
1. a procedure that you perform frequently. 2. Create a command. 3. Create a new. 4. Create custom for Excel.

Excel & Visual Basic for Applications (VBA)

DATA 301 Introduction to Data Analytics Microsoft Excel VBA. Dr. Ramon Lawrence University of British Columbia Okanagan

Module 1. 4 Login-Send Message to Teacher

Working with Macros and VBA in Excel 2007

Unleashing Hidden Powers of Inventor with the API Part 1. Getting Started with Inventor VBA Hello Inventor!

Microsoft Migrating to PowerPoint 2010 from PowerPoint 2003

Automate tasks with Visual Basic macros

Migrating to Excel 2010 from Excel Excel - Microsoft Office 1 of 1

Programming in Access VBA

OneSourceFax Customer Guide

Database Automation using VBA

Access Tutorial 1 Creating a Database

Microsoft Migrating to Word 2010 from Word 2003

Using Microsoft Word. Working With Objects

Cox Digital Telephone Quick Guide

Microsoft Office Access 2007 Basics

Macros in Word & Excel

Hands-on Exercise 1: VBA Coding Basics

Introducing VBA Message Boxes

Ingham County Equalization/Tax Mapping Viewer Tutorial

PLAY VIDEO. Close- Closes the file you are working on and takes you back to MicroStation V8i Open File dialog.

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.

14.1. bs^ir^qfkd=obcib`qflk= Ñçê=emI=rkfuI=~åÇ=léÉåsjp=eçëíë

Lync Online Meeting & Conference Call Guide

Add an Audit Trail to your Access Database

NSCC SUMMER LEARNING SESSIONS MICROSOFT OFFICE SESSION

Hands-on Practice. Hands-on Practice. Learning Topics

Microsoft Outlook Tips & Tricks

How To Use Ticket Validation Software On A Pc Or Mac Or Macbook Or Ipad (For Acedo) On A Computer Or Ipa (For An Ipa) On An Ipad Or Macintosh (For Macintosh) On Pc

Create an Art Collage

Staying Organized with the Outlook Journal

How to test and debug an ASP.NET application

State of Illinois Web Content Management (WCM) Guide For SharePoint 2010 Content Editors. 11/6/2014 State of Illinois Bill Seagle

Outlook Web Access. PRECEDED by v\

Buddy User Guide. 1

RIT Installation Instructions

How to create pop-up menus

Introduction to Word 2007

Baylor Secure Messaging. For Non-Baylor Users

Microsoft Outlook 2013 Part 1: Introduction to Outlook

WebSphere Business Monitor V7.0 Business space dashboards

Hands-On Lab. Building a Data-Driven Master/Detail Business Form using Visual Studio Lab version: Last updated: 12/10/2010.

MiVoice Integration for Salesforce

Copyright 2006 TechSmith Corporation. All Rights Reserved.

Microsoft Office Access 2007 which I refer to as Access throughout this book

PC Agent Quick Start. Open the Agent. Autonomy Connected Backup. Version 8.8. Revision 0

I ntroduction. Accessing Microsoft PowerPoint. Anatomy of a PowerPoint Window

Microsoft Migrating to Access 2010 from Access 2003

E-Loader Operation Manual

Adobe Dreamweaver CC 14 Tutorial

Impact Call PC. call001. Impact Call User s Guide

Microsoft Access 2010 handout

Unified Communications Using Microsoft Office Live Meeting 2007

LogMeIn Network Console Version 8 Getting Started Guide

Visual Basic 2010 Essentials

Raptor K30 Gaming Software

How To Use Microsoft Word 2003

Microsoft Word 2010 Tutorial

Various MicroStation Tips and Tricks MicroStation (SELECTseries 3) Tine Lai Andersen, LEARNing Consultant

To Begin Customize Office

Excel & Visual Basic for Applications (VBA)

Verizon Collaboration Plug-In for Microsoft Outlook User Guide

2Creating Reports: Basic Techniques. Chapter

MICROSOFT OUTLOOK 2011 GETTING STARTED AND HELP RESOURCES

Creating Datalogging Applications in Microsoft Excel

Initial Setup of Mozilla Thunderbird with IMAP for Windows 7

Bonus etutorial from WebPrepPro. How to Make a Business Card Signature in your Outgoing Outlook Correspondence.

Basic Microsoft Excel 2007

Applications Development

Appendix K Introduction to Microsoft Visual C++ 6.0

Verizon Collaboration Plug-In for Microsoft Outlook User Guide

Create a PDF File. Tip. In this lesson, you will learn how to:

Google Drive: Access and organize your files

Microsoft Outlook 2010 Part 1: Introduction to Outlook

Desktop, Web and Mobile Testing Tutorials

TLMC WORKSHOP: THESIS FORMATTING IN WORD 2010

HP Quality Center. Software Version: Microsoft Word Add-in Guide

VBA PROGRAMMING FOR EXCEL FREDRIC B. GLUCK

Microsoft Outlook 2010 Part 1: Introduction to Outlook

Search help. More on Office.com: images templates

Access Tutorial 1 Creating a Database. Microsoft Office 2013 Enhanced

HP CLASSROOM MANAGER. Empowering teachers, engaging students. QuickStart Guide for Teachers

Umbraco v4 Editors Manual

Create a New Database in Access 2010

Microsoft Word 2013 Tutorial

Visual Basic Programming. An Introduction

Microsoft Access 2010 Part 1: Introduction to Access

Financial Data Access with SQL, Excel & VBA

Manual English KOI Desktop App 2.0.x

Microsoft Office 365 Outlook Web App (OWA)

User s Guide for Polycom CX7000 Systems

WebSphere Business Monitor V6.2 Business space dashboards

B2W Maintain. Setup and Preventive Maintenance

Fig. 1 The finished UserForm project.

Getting Started. Tutorial RIT API

Field Manager Mobile Worker User Guide for RIM BlackBerry 1

Microsoft Office 365 Outlook Web App (OWA)

Planning and Creating a Custom Database

Transcription:

Welcome to: Customizing MicroStation via VBA Bentley Bash 2011 Created by Mike Lazear Archway Systems, Inc.

Survey 1. Have you run a macro in MicroStation? 2. Recorded or created a macro in MicroStation? 3. Any programming experience? 4. If so, what languages?

What we will cover today What is an MVBA file and what s in it Overview/mechanics of using VBA Record a macro, run a macro Getting Assistance Interacting with MicroStation Scanning a Model Manipulating Elements

What is an MVBA file and what s in it MVBA stands for MicroStation VBA - VBA stands for Visual Basic for Applications MVBA is a single file, called a project, that contains: Modules, classes and forms Module1 Class1 Module2 Class2 Module3 Form1 Form2

Overview/mechanics of VBA

Overview/mechanics of VBA Macros shows only Subs from Modules that have no params Visual Basic Editor (IDE) Shows Projects and contents: Modules, Classes, Forms Project Manager shows only Projects

VBA Project Manager Open Editor Save Project Unload Project Open Existing Project Create new project Run Macro Start Recording Stop Recording Pause Recording Automatically load the project

VBA Editor (also know as IDE Integrated Development Environment) Projects Window Main Editor Window Immediate Window Properties Window Watches Window

Macros List of all Public Subs (that have no params), in all Modules, from the Project(s) selected below Runs highlighted Macro (same as Play) Cancels out of this dialog (same as Red X) Starts debugging for the highlighted macro Edits the highlighted macro Deletes the highlighted macro from module

Modules Modules contain: Declarations (variables) Const pi = 3.14159265358979 Private count As Integer Public oelement As Element Subroutines Sub subwithnoparams() Sub subwithparams(count As Integer, total As Integer) Functions (exactly like subroutine but return a value) Function calchighervalue(val1 As Double, val2 As Double) As Double See WhatIsInAModule module (bash2011 project)

Recording a Macro Open the Project Manager Highlight a project where the macro should be saved Click the red Record circle icon to start the record Perform whatever operations you wish to record Click the white Stop Record square (next to record icon) See Starter module (bash2011 project)

Run a Macro From Macros: (Alt-F8 to bring it up if necessary) Find the macro to run in the Macro name list Either double-click the name or highlight and click Run From VB Editor: (Alt-F11 to bring it up if necessary) Navigate to the project/module where your macro lives Click somewhere inside the macro. Click play button on toolbar (may have to open Debug toolbar) NOTE: if you click outside of the macro and then click play the Macros window will come up From Project Manager: Click the play button (arrow) and it will bring up the Macro window Follow steps (From Macros) above

Getting Assistance F1 for help Be aware there are 3 different help files that can be launched. MicroStation help, VBA help, MicroStation VBA help Examples are a gold mine! F2 in VB Editor for Object Browser MicroStation on the web www.bentley.com Click on community (near top) Click on discussion groups (on left side) Click on web browser (within page) Click on bentley.microstation.v8.vba Search for content you are interested in

Visual Basic Objects Properties Things that describe the object such as color, filled and border. Methods Things that we can do with the object (i.e. functions we can call) such as delete, copy, change size. Events Notification that something happened to our object. The object was clicked on. The object was moved. The object was deleted.

VB Objects Example Properties (things that describe) Color is silver Receiver is red Touch tone Stationary Text on screen Methods (things we can do) Answer incoming call Make an outgoing call Hang up a call Events (things we react to) Someone calls A call waiting comes in operator asks for money Someone calls us (Event). We answer the phone (Method). Text on the screen shows their phone # (property)

MicroStation objects Application (basically the root of all objects) ActiveDesignFile ActiveModelReference ActiveSettings Element LineElement, EllipseElement, etc. Color, LineWeight, IsGraphical properties

Interacting with MicroStation See MessagesAndInput module for examples of how to communicate to the user. ShowStatus ShowCommand ShowPrompt MsgBox InputBox Recording and editing a macro to be more interactive CadInputQueue SendKeyin SendDataPoint GetInput SendReset Debugging Breakpoints, watch window, immediate window, etc.

Record an action 1 Switch to Model Interaction 2 Unload all VBA projects except the Default project in the VBA Project Manager. 3 In Project Manager create a new project named MoveElement. 4 Select the MoveElement project, then click Start Record. 5 Returning to MicroStation, select the Move Element tool from the Manipulate tool box 6 Identify the element labeled VALVE 1. 7 Place the element a distance from its original location. Be sure to move it in both the X and the Y direction. (For this exercise the actual distance moved is not as important as the fact that you moved the object.) 8 Reset to release the element. 9 Click Stop Record. 10 Switch to the Visual Basic Editor to examine the new module. Double click MoveElement > Modules > Module1

Editing to be more interactive (change code to the following) 1 Sub Move50cm() 2 Dim startpoint As Point3d 3 Dim endpoint As Point3d 4 Dim message As CadInputMessage 5 6 ShowStatus "Move command using VBA" 7 ShowCommand "Move Element with macro" 8 ShowPrompt "Identify Element" 9 10 Set message = CadInputQueue.GetInput(msdCadInputTypeDataPoint, msdcadinputtypereset) 11 12 If message.inputtype = msdcadinputtypedatapoint Then 13 ' Start a command 14 CadInputQueue.SendCommand "MOVE ICON" 15 16 startpoint = message.point 17 endpoint = startpoint 18 endpoint.y = endpoint.y - 0.5 19 20 CadInputQueue.SendDataPoint startpoint, 1 21 CadInputQueue.SendDataPoint endpoint, 1 22 ElseIf message.inputtype = msdcadinputtypereset Then 23 CommandState.StartDefaultCommand 24 End If 25 26 CommandState.StartDefaultCommand 27 End Sub

Scanning a Model (Ways to scan) Scan all elements in a model Scan selected elements Scan elements in a fence Scan specific type of elements See Scanning module (bash2011 project)

Manipulating Elements Change Element properties Color, LineWeight, LineStyle, etc. Element.ReWrite Save changes made to element Creating new elements CreateEllipseElement2( ) ActiveModelReference.AddElement myellipse See ManipulatingElements module

Review & Wrap up Key points you learned: Mechanics of how to work with VBA How to record and run a macro Basic building blocks of interacting and manipulating elements Questions & answers Thank you for attending the Customizing MicroStation via VBA session

Other Useful stuff Modules, Classes, Forms Interfaces & Implements

Modules, Classes, Forms Module Contain subroutines & functions only Routines can be Private or Public Classes Contain Properties, Methods and Events The MicroStation Objects are instances of predefined classes Must create an instance (object) of a user class to call its code Forms Visual dialogs Similar to Classes they can contain Properties & Methods controls placed on form have predefined events

Programming Resources If you have never programmed To understand computer programming concepts we recommend How Computer Programming Works which can be found at www.desaware.com If you have done some programming but don t know Visual Basic Personally, I ve never found a good general book for learning Visual Basic but there is an excellent and inexpensive web site that has videos demonstrating features and functionality. www.learnvisualstudio.net The on-line documentation for Visual Basic is excellent Learning MicroStation VBA by Jerry Winters Bentley Institute Press ISBN: 0-9714141-8-1