Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
MicroStation
  • Product Communities
MicroStation
[Archived] AskInga Wiki Run commands or BASIC macro when opening files
    • Sign In

    • -AskInga
      • +3D MicroStation
      • +AccuDraw Secrets
      • +Animation - Rendering
      • +Behind The Scenes
      • +Cells
      • +Colours
      • +Conversion - Translation
      • +Coordinate Input
      • +Design Settings
      • +Dimensions
      • +DWG
      • +EDG
      • +Element Manipulation
      • +Element Properties
      • +Element Selection
      • +Freeware - Shareware
      • +Interface Look And Feel
      • +Internet - E-Links - Links
      • +Keyins
      • +Levels
      • +Line Styles
      • +Models
      • +MSM Archive
      • +Other
      • +Presentations
      • +Printing - Plotting
      • -Programming - Automation
        • Run a VBA macro when opening or closing design files
        • Run commands or BASIC macro when opening files
        • Run commands when starting MicroStation
        • The Settings Manager - Part 1
        • The Settings Manager - Part 2
      • +Rasters - Images
      • +References
      • +Tags - Data Fields - Fields
      • +Text - Fonts - Annotation
      • +Views
      • +Windows - Interacting With
      • +Workspaces - Configuration
    • graffiti

     
     Questions about this article, topic, or product? Click here. 

    Run commands or BASIC macro when opening files

    AskInga logo

    Original Article Date: July 19, 2002 

    Execute a BASIC macro (or run commands) every time a file is opened.
    2003-11-24 Included notes from MicroStation /J's ReadMe file.
    2005-09-27 Confirmed workflow in MicroStation V8.

    2018-11-26 Updated for clarity

    This following information will allow you to configure MicroStation /J or V8 to execute a startup macro each time a DGN file is opened.

    • Locate the MDL called runmacro.ma in the following installation folder:  .../mdlapps/
    • Copy the .ma and .dll to the installation folder .../mdlsys/asneeded/

    • .../workspace/standards/macros/  folder create a new text file named RunMe.bas (as an example) and add the commands to run when a file is opened:

    Sub main
        Dim startPoint As MbePoint
        Dim point As MbePoint, point2 As MbePoint
    '   Send a keyin that can be a command string
        MbeSendKeyin "LV=1"
        MbeSendKeyin "CO=0"
        MbeSendKeyin "WT=0"
        MbeSendKeyin "LC=0"
        MbeSendKeyin "ON=ALL"
        MbeSendKeyin "POINT absolute"
        MbeSendKeyin "FIT VIew Extended"
    End Sub
    

    • Finally, define the following new variables:

    MS_DGNAPPS > runmacro

    MS_DGNMACROS=runme



    Now everytime a file is opened, the macro name RunMe will be run. You can also configure MicroStation to run a suite of macros. In that case you would set MS_DGNMACROS as follows:

    MS_DGNMACROS=The_First_Macro_to_run.ba
    MS_DGNMACROS>The_Second_Macro_to_run.bas

    2003-11-24:
    The following notes were posted to v8.general newsgroup by Bentley's Phil Chouinard and can also be found in MicroStation /J's ReadMe:

    The configuration variable MS_MACRO is used to define the folders that contain the macros.

    If RunMacro is defined in MS_INITAPPS, MicroStation /J will ignore any command line parameters and the MicroStation Manager dialog box will be opened after all macros have been completed.RunMacro can be run as both an INITAPP and a DGNAPP.

    Any number of macros may be included in either the MS_INITMACROS or MS_DGNMACROS configuration variables. Simply separate the macro names with a semi-colon when using MicroStation/J's Configuration Variables dialog box, or use the ">" sign as shown above.

    MicroStation BASIC macro names may be specified in the configuration variables with no extension, .BA extension, or .BAS extension.

    MS_INITMACROS [is] run before a design file is opened. Therefore, the macro must not access any design file objects or attempt to do anything which requires an open design file.

    Source code for RunMacro is provided with MDE. RunMacro starts MicroStation/J graphics environment using mdlSystem_enterGraphics. However, this MDL application may be modified to not start the graphics environment. In this case, the application must not perform any MicroStation BASIC function which requires graphics (like opening a dialog box, for example).

     

    AskInga Article #116

    • Askinga
    • Automation
    • Programming
    • Article
    • Share
    • History
    • More
    • Cancel
    • Anonymous Created by Anonymous
    • When: Thu, May 29 2008 9:47 AM
    • Inga Morozoff Last revision by Bentley Colleague Inga Morozoff
    • When: Mon, Nov 26 2018 1:27 PM
    • Revisions: 7
    • Comments: 3
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies