Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
  • Welcome
  • Products
  • Support
  • About
  • More
  • Cancel
MicroStation
  • Product Communities
  • More
MicroStation
[Archived] AskInga Wiki How to expand keyins that contain configuration variables
    • 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
        • Access the BASIC editor
        • An alternate keyin for DL=0,0,0
        • Capturing messages from the dialog debugger
        • Changes to the DI keyin
        • Combine your keyins
        • Dealing with quotation marks in named settings such as saved views, text styles, dimension styles and more
        • Dealing with spaces in names when using keyins
        • Determining keyins associated with tool settings
        • How to expand keyins that contain configuration variables
        • How to extract keyins for the tool settings in MicroStation V8i
        • How to string keyins together or create keyin scripts
        • Increment or decrement keyins
        • Keyin for the save as dialog
        • Keyins to reload active file
        • MicroStation's accelerator keys AKA keyboard shortcuts
        • MicroStation's calculator preprocessor
        • Multiply or divide keyins
        • Paste into the keyin window
        • Print messages in your scripts
        • Something neat to add to the end of script files
        • The keyboard shortcuts
        • The power of keyins
        • The V7 Keyin list
        • The V8 Keyin list
        • To open the previous file
        • Understanding the Key-in Browser
        • Use the pipe key for repetitive keyins
        • Using the Expand Keyin
        • What command was that?
      • +Levels
      • +Line Styles
      • +Models
      • +MSM Archive
      • +Other
      • +Presentations
      • +Printing - Plotting
      • +Programming - Automation
      • +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. 

    How to expand keyins that contain configuration variables

    Did you know that you can include a MicroStation configuration variable (and then perform certain operations on those variables) in commands? For example, you can use:

    $ model rename default $(basename(_DGNFILE))
    (that is a $ sign, then space, then model...) to rename the default model in your DGN file to the name of the file that you are in. What follows is how this works.

    This is all straight MicroStation... no VBA required, although you can queue these sorts of commands in VBA macros if you want to. The $ at the beginning is a "shortcut" for "expand keyin", which is something that was introduced in MicroStation V8. What that does is "expand" anything in the key-in that references a configuration variable -- in this particular case, the $(basename(_DGNFILE)) part.

    For the last part in that command, you might recognize _DGNFILE as the read-only configuration variable that contains your currently open file name, including extension, folder/path, etc. The basename(...) part is a variable definition reference. That particular reference "extracts" the filename without its extension. There are other references that can "extract" things (e.g. parent directory, filename with extension, etc.), those are documented in Help > Contents under "Configuration Variable File Syntax". Finally, the $(...) is what the "expand keyin" part operates on.

    So basically, the $ at the beginning "tells" MicroStation's input processor to walk through the command line to see if there are any $(...) things included. Since there are, what is inside that is "expanded". In this particular case, basename(_DGNFILE) "returns" just your filename (without the extension), which is then substituted for that part of the command and voila, you have what you are looking for.

    Related Links:

    Set temporary variables with the Expand Set keyin
    Report your variables with Expand Echo keyin
    How to set _WORKDIR=_ DGNDIR after starting MicroStation

    • Command
    • Askinga
    • expand
    • KeyIn
    • Share
    • History
    • More
    • Cancel
    • Phil Chouinard Created by Phil Chouinard
    • When: Mon, Mar 1 2010 10:33 AM
    • Inga Morozoff Last revision by Bentley Colleague Inga Morozoff
    • When: Thu, Jul 29 2010 5:41 PM
    • Revisions: 11
    • Comments: 0
    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

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