48784209 Microstation Basic

Click here to load reader

  • date post

    12-Nov-2014
  • Category

    Documents

  • view

    517
  • download

    39

Embed Size (px)

Transcript of 48784209 Microstation Basic

MicroStationBASIC GuideDAA010290-1/0002

TrademarksAccuDraw, MicroStation, MicroStation Modeler, MicroStation PowerDraft, MicroStation Review, MicroStation Vault and SmartLine are registered trademarks of Bentley Systems, Incorporated. Bentley, the B Bentley logo, MDL, PowerScope, QuickVision, TeamMate and MasterPiece are trademarks of Bentley Systems, Incorporated. Bentley SELECT is a service mark of Bentley Systems, Incorporated. Adobe, the Adobe logo, Acrobat, the Acrobat logo, Distiller, Exchange, and PostScript are trademarks of Adobe Systems Incorporated. Windows is a registered trademark and Win32s is a trademark of Microsoft Corporation. Other brands and product names are the trademarks of their respective owners.

Copyrights1997 Bentley Systems, Incorporated. MicroStation 95 1995 Bentley Systems, Incorporated. IGDS file formats 1987-1994 Intergraph Corporation. Intergraph Raster File Formats 1994 Intergraph Corporation Used with permission. Portions 1992-1994 Summit Software Company. Unpublished rights reserved under the copyright laws of the United States.

MicroStation BASIC Guide

i

ii

MicroStation BASIC Guide

Table of ContentsPart 1: Concepts and Procedures1. Introduction to MacrosCreating Macros ______________________________________________ 1-1 Guidelines for creating a macro_____________________________ 1-2 Advanced macro programming _____________________________ 1-3 Running Macros _____________________________________________ 1-5 Creating and Managing Macros ________________________________ 1-6 Generating macros________________________________________ 1-6 Managing macros _________________________________________ 1-7 Adding macros to MicroStations user interface ________________ 1-8

2. Prototyping, Editing, and Debugging MacrosPrototyping__________________________________________________ 2-1 Starting conditions ________________________________________ 2-1 The Create Macro dialog box _______________________________ 2-1 Stopping the macro generator ______________________________ 2-2 The form of a prototype macro _____________________________ 2-3 BASIC extensions commonly used by the macro generator _____ 2-4 The BASIC Editor ____________________________________________ 2-6 Text editing area and scrolling______________________________ 2-7 Status message field_______________________________________ 2-8 Line number and column number fields _____________________ 2-8 File menu _______________________________________________ 2-8 Edit menu _______________________________________________ 2-9 Run menu _______________________________________________ 2-10 Debugger icons __________________________________________ 2-11 Working with variables ____________________________________ 2-12

3. Macro Language OverviewComments___________________________________________________ 3-1 Naming Rules ________________________________________________ 3-1 Built-in Data Types ___________________________________________ 3-2 Integers _________________________________________________ 3-2 Long integers ____________________________________________ 3-2 Strings __________________________________________________ 3-2 Singles __________________________________________________ 3-3 Doubles_________________________________________________ 3-3MicroStation BASIC Guide

iii

Table Of Contents: Macro Language OverviewVariable Declarations __________________________________________3-3 Declaring integer variables _________________________________3-4 Declaring long variables ___________________________________3-4 Declaring string variables___________________________________3-4 Declaring single variables __________________________________3-5 Declaring double variables _________________________________3-5 Arrays of Variables ____________________________________________3-5 Fixed-length arrays ________________________________________3-6 Variable-length arrays______________________________________3-7 User-defined Data Type Variables _______________________________3-8 Creating a user-defined data type ____________________________3-8 Declaring user-defined data type variables ____________________3-9 Working with user-defined data type variables ________________3-9 Variable Scope _______________________________________________3-9 Local variables____________________________________________3-10 Private variables __________________________________________3-10 Public variables ___________________________________________3-10 Initial Variable Values _________________________________________3-11 Symbolic Constants ___________________________________________3-11 Expressions __________________________________________________3-11 Assignment operator_______________________________________3-11 Arithmetic operators _______________________________________3-12 String concatenation operators ______________________________3-13 Relational operators _______________________________________3-13 Logical operators__________________________________________3-14 Operator precedence ______________________________________3-15 Statements and the Line Continuation Character ___________________3-15 Controlling Execution _________________________________________3-16 If...Then...Else ____________________________________________3-16 Select...Case ______________________________________________3-18 Do...Loop ________________________________________________3-19 While...Wend _____________________________________________3-22 For...Next ________________________________________________3-22 Labels and the Goto statement ______________________________3-24 GoSub and Return statements _______________________________3-24 Program Structure_____________________________________________3-25 Subroutine procedures _____________________________________3-26 Calling subroutine procedures ______________________________3-27 Function procedures_______________________________________3-28 Calling function procedures ________________________________3-30 Passing arguments to procedures ____________________________3-30 Declaring procedures ______________________________________3-32 Objects in BASIC _____________________________________________3-32 Declaring an object variable ________________________________3-33 Object variable operations__________________________________3-34 Creating an object instance _________________________________3-35

iv

MicroStation BASIC Guide

Table Of Contents: Macro Interactions With MicroStationAccessing object properties ________________________________ 3-36 Accessing object methods__________________________________ 3-36 Object collections ________________________________________ 3-37 Constant objects __________________________________________ 3-37 Error Handling _______________________________________________ 3-38

4. Macro Interactions With MicroStationMicroStation BASIC Extension conventions _______________________ 4-1 Sequencing MicroStation Commands ____________________________ 4-1 Macro Coordinate System______________________________________ 4-2 Querying and Manipulating Graphic Elements ____________________ 4-3 Modifying graphic elements ________________________________ 4-8 Using selection sets and fences _____________________________ 4-9 Graphic element location __________________________________ 4-11 Accessing design file information ___________________________ 4-12 Accessing MicroStation settings _____________________________ 4-13 Accessing MicroStation state information _____________________ 4-13 Accessing design file view information_______________________ 4-14 Accessing reference file information _________________________ 4-14 Accessing MicroStation session information ___________________ 4-15 Database features of MicroStation BASIC extensions ___________ 4-15 Using Macros to Specify Pen Table Output Actions ________________ 4-18 Overview of macro operation in pen tables___________________ 4-18 The Main subroutine is optional in plotting___________________ 4-19 Working with element priorities in macros ___________________ 4-19 Pen Table Plot Element Hook function return values___________ 4-20 A macro plot function example _____________________________ 4-21 Pen table program entry points _____________________________ 4-22 The different program entry points and their function __________ 4-24 Optimizing the macro for plotting ___________________________ 4-25 Using Macros to Perform DWG Import/Export ____________________ 4-26 Objects for specifying import and export settings______________ 4-26 Object for specifying font cross-reference information__________ 4-27 Objects for specifying cell/block cross-reference information ____ 4-28 Editing and compiling dwg.bas____________________________ 4-29

MicroStation BASIC Guide

v

Table Of Contents: Adding Dialog Boxes to Macros

5. Adding Dialog Boxes to MacrosStandard Dialog Boxes_________________________________________5-1 Custom Dialog Boxes__________________________________________5-2 Dialog Builder________________________________________________5-3 Dialog menu _____________________________________________5-4 Edit menu________________________________________________5-6 Options menu ____________________________________________5-8 Common item attributes____________________________________5-10 Text Editor dialog box _____________________________________5-11 Label Editor dialog box ____________________________________5-11 Toggle Button Editor dialog box ____________________________5-12 Option Button Editor dialog box ____________________________5-12 Push Button Editor ________________________________________5-13 Color Picker dialog box ____________________________________5-14 Level Map Editor dialog box ________________________________5-15 Scale Editor dialog box ____________________________________5-15 Alignment menu __________________________________________5-18 Tool box______________________