Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
  • Welcome
  • Products
  • Support
  • About
  • More
  • Cancel
MicroStation
  • Product Communities
  • More
MicroStation
[Archived] AskInga Wiki Using MSBATCH to replace cells from Windows Explorer
    • 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
      • +Rasters - Images
      • +References
      • +Tags - Data Fields - Fields
      • +Text - Fonts - Annotation
      • +Views
      • -Windows - Interacting With
        • All about thumbnail generation
        • Bring up the system calculator in MicroStation
        • Close modal dialogs with ESC
        • Expand Element Info with an asterisk
        • Finding text content in DGN files using Windows Search
        • Google Tip - Search a website easier
        • Group the display of files in the MicroStation Manager
        • How to determine MicroStation's installation date
        • Maximize MicroStation when started from desktop
        • Move a dialog off your screen without docking
        • Open Windows Explorer and navigate to folder of active file from MicroStation
        • Right click when dragging and dropping
        • Running an external application from a read-only file
        • Start an application and keep MicroStation running
        • Start an application and suspend MicroStation
        • Start an application from within MicroStation
        • Start MicroStation without the splash screen
        • Stop that annoying Restart Now - Restart Later dialog
        • Strip text formatting when copying between applications
        • Suspend MicroStation open a DOS window and start another application
        • Use keyboard shortcuts to launch your programs
        • Using a system variable for your license folder
        • Using MSBATCH for command line processing
        • Using MSBATCH to replace cells from Windows Explorer
        • Windows Tip - customize My Documents
      • +Workspaces - Configuration
    • graffiti

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

    Using MSBATCH to replace cells from Windows Explorer

    Ask Inga logo

    With thanks to Duane Marshall for contributing this workflow that will allow you to replace cells by simply selecting a customized right-click menu item when using Windows Explorer. It's really quick slick!

    Simply put, an MS-DOS Batch File is a text file filled with DOS commands that will be executed by the Windows operating system. Batch files have an extension of bat are commonly used to run frequently used commands such as deleting a series of files, renaming files, or running an program. If you're new to the concept of using or writing up batch files, you might want to explore a few external links first.


    In this sample tutorial, a little batch file is written to replace cells called prelim with cells called final using msbatch as the mechanism to make the file changes. If you're completly unfamiliar with msbatch, you may want to read this first:  Using MSBATCH for command line processing   (was *** Understanding and using MSBATCH *** ) . In addition, take a peek at MicroStation's HELP file and specifically search on repcell. Ok, now you can proceed.

    To get started open any text editor and write the following commands as it would apply to your situation.
    Save the file with a bat extension and in a safe folder such as c:\batch\:

    @echo off
    c:
    cd..
    cd..
    cd..
    cd program files\bentley\program\microstation
    msbatch repcell.ma %1 "k:\projects\2007\cell\ABCompany.cel" y prelim final


    Where:
    @echo off suppresses the printing of each command in the window.
    Refer to Wikipedia > Batch File for additional information.

    cd.. changes the current folder.
    See also: Wikipedia > List of DOS Commands


    program files\bentley\program\microstation would be the install folder of your MicroStation.

    msbatch repcell.ma kicks off the msbatch utility with the Replace Cell application.

    %1 gets converted to a file name.

    "k:\projects\2007\cell\ABCompany.cel" is the name of the cell library.

    y tells the replace cells application to save the attributes

    prelim is the name of the cell to replace

    final is the name of the replacment cell.


    The next task is to add a shortcut that points to the batch file in the Windows Explorer right click menu. For example, when selecting and right-clicking on a design file in Windows Explorer, the following menu will appear. (Note, that your menu may be slightly different depending on your operating system and installed software).

    In Windows Explorer, select Tools > Folder Options...
    In the resulting dialog, navigate to the File Types tab and highlight DGN

    Choose Advanced > New and fill in the following fields:

    Action is the name of the entry that will be added to the right click menu.

    Application used to perform action would be the location and name of the batch file created earlier.
    Don't forget to put "%1" at the end so that the selected file will be acted upon.

    Use DDE enabled.

    Application set to ustation
    Note, depending upon how many version sof MicroStation you have running, you may need to input the entire path in this field.

    Topic set to System

    Note, to learn more about Dynamic Data Exchange refer to Windows Help or Wikipedia > Dynamic Data Exchange

    Save all of the changes and then go proceed to right click on any MicroStation design file via Windows Explorer. Note the addition of the Update Prelim cell to Final cell menu item as per the above instructions. Selecting this option will execute the commands located in the batch file. In this case, msbatch will replace cells called prelim with cells called final and will do do without actually starting MicroStation. That's the power of msbatch!

    Troubleshooting
    Double check your syntax!
    Ensure that each command entry in the batch file is correct.
    In other words...will they run successfully on their own in a DOS Command Window?
    If not, you've probably got a typo. ;-)

    As you can see, knowing just a wee bit of DOS can open an entirely new world for you. Of course, it goes without saying that you should always test this kind of stuff on scrap files. Also note that the information contained in this article is designed for experienced users.

    This information is supplied as is and does not come with support. AskInga, Bentley Systems Inc., and the author of the workflow assumes no liability for damages direct, indirect, or consequential, which may result from the use of these instructions. Use these instructions at your own risk.

     

    AskInga Article #309

    • Askinga
    • Cells
    • Windows Interacting with
    • Share
    • History
    • More
    • Cancel
    • Frank Conforti Created by Bentley Colleague Frank Conforti
    • When: Fri, May 16 2008 2:24 PM
    • Inga Morozoff Last revision by Bentley Colleague Inga Morozoff
    • When: Wed, Jun 9 2010 1:57 PM
    • Revisions: 5
    • 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