Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
MicroStation
  • Product Communities
MicroStation
MicroStation Wiki Extract Project ID from file path
    • Sign In

    • -MicroStation Wiki
      • +Learning Tips
      • -MicroStation
        • +3D Printing - MicroStation
        • +Animation - MicroStation
        • +Archive / Backup - MicroStation
        • +Base Geometry - MicroStation
        • +Batch Processing - MicroStation
        • +CONNECT Advisor - MicroStation
        • CONNECT Integration - MicroStation
        • +CONNECTION Client
        • +Cells - MicroStation
        • +Change Tracking - MicroStation
        • +Configuration - MicroStation
        • +Coordinate Systems - MicroStation
        • +Curves - MicroStation
        • +Custom Linestyles - MicroStation
        • +DGN - MicroStation
        • +DWG - MicroStation
        • +Database - MicroStation
        • +Detailing Symbols - MicroStation
        • +Dimensions - MicroStation
        • +Documentation & Help - MicroStation
        • +Drawing Aids - MicroStation
        • +Exception - MicroStation
        • +FAQ - MicroStation
        • +Feature Based Solids Modeling - MicroStation
        • +File Access - MicroStation
        • +GUI - MicroStation
        • +General - MicroStation
        • +Graphics Display - MicroStation
        • +Groups - MicroStation
        • +Hardware / Input Devices - MicroStation
        • +Import/Export - MicroStation
        • +Installation - MicroStation
        • +Interchange - MicroStation
        • +Interference - MicroStation
        • +Internationalization - MicroStation
        • +Levels - MicroStation
        • +Licensing - MicroStation
        • +Manipulation - MicroStation
        • +Markup / Redline - MicroStation
        • +Measure - MicroStation
        • +Mesh - MicroStation
        • +Models - MicroStation
        • +Multi-Lines - MicroStation
        • +OLE - MicroStation
        • +Other - MicroStation
        • +Parametrics - MicroStation
        • +Patterning - MicroStation
        • +Point Cloud - MicroStation
        • -Printing - MicroStation
          • +Dialog - Printing - MicroStation
          • +Driver/HPGL2 - Printing - MicroStation
          • +Driver/JPEG - Printing - MicroStation
          • +Driver/PDF - Printing - MicroStation
          • +Driver/PSCRIPT - Printing - MicroStation
          • +Driver/SYSPRT - Printing - MicroStation
          • +Organizer - Printing - MicroStation
          • -Pen Table - Printing - MicroStation
            • Extract Project ID from file path
            • How to change the linestyle on printed output
            • How to detach a Pen Table from the Print Dialog
            • How to print Filled Elements that are in Master file but not in its Reference(s)
            • Import Color and Weight Maps into Pen Table
            • Pen table not applicable printing sheet or drawings
            • The border label is plotting inverted. Black background with white text.
          • +Print Def/CAD - Printing - MicroStation
        • +Programming - MicroStation
        • +Project Navigation - MicroStation
        • +Properties - MicroStation
        • +RSS Feeds - MicroStation
        • +Reference - MicroStation
        • +Security - MicroStation
        • +Selection - MicroStation
        • +Settings - MicroStation
        • +Sheet Composition - MicroStation
        • +Solids - MicroStation
        • +Standards - MicroStation
        • +Surfaces - MicroStation
        • +Tables - MicroStation
        • +Text - MicroStation
        • +UI Customization - MicroStation
        • +Units - MicroStation
        • +View - MicroStation
        • +Visualization - MicroStation
        • Welcome Page - MicroStation
        • +Accreditation - MicroStation
        • +i.Models - MicroStation
        • +ProjectWise Integration
        • +Raster - MicroStation
    • +Administration Wiki
    • +Annotations Wiki
    • +Bentley View Wiki
    • +MicroStation PowerDraft
    • +Programming Wiki
    • +Visualization Wiki

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

    Extract Project ID from file path

      Product(s): MicroStation
      Version(s): 08.11.09.829
      Environment: N\A
      Area: Printing
      Subarea: Pen Table

    Extract Project ID from file path

    Background

    User's requirement is to extract the Project ID from the file path and apply Pen Table text substitution

    Steps to Accomplish

    Named Expressions in Conjunction with a Pen Table worked well for this requirement.

    Input DGN file: D:\ 1000\ABC101\Grid24.dgn
    Output requirement: Replace a text -ProjectID- with ABC101

    First create a DGNLIB file (e.g. ABC.dgnlib) where we will create the required Named Expression.

    • Inside MicroStation, under menus, go to Utilities > Named Expressions
    • Inside the Named Expression dialog, click on New icon
    • Change both the Internal Name and External Name to GetMyProjectID
    • In the Keywords section select File
    • In the Symbol Sets section select and add Active File, System.String
    • In the Expression section add string System.String.SubString(ActiveFile.FileName,8,6)
    • Click the Test button to test if it works.
    • Click Save button inside the Named Expression dialog and close the dialog.
    • Click File > Save to save the DGNLIB

      

    Map the newly created DGNLIB file to configuration variable MS_DGNLIBLIST

    • Set configuration variable MS_DGNLIBLIST value = ABC.dgnlib
    • Click File > Save Settings

      

    Load input design file

    • Open Grid24.dgn file
    • Add a text -ProjectID-

      

    Apply the following in the Print dialog.

    • Inside MicroStation, under menus, go to File > Print
    • Inside Print dialog go to Resymbolization > New Pen Table
    • Give a name to your Pen Table
    • Under Global Actions click on Text Substitutions
    • Click on Insert > Edit New
    • Enter Actual string as -ProjectID-
    • Enter Replacement string as <expr?name=GetMyProjectID>
    • Save the pen table, go to File > Save
    • Go to File > Exit and Unload

      

    Attach the Pen table to test the output

    • File Location

    • Load the Print dialog and the pen table to test the output

    See Also

    A Step-by-Step Guide for Advanced Pen Table Text Substitution

    Print Text Substitution

    Named Expressions

     

      Original Author: Leonard Jones
    • Pen Table
    • 08.11.09.829
    • Printing
    • MicroStation
    • Named Expression
    • en
    • SELECTsupport
    • Share
    • History
    • More
    • Cancel
    • Leonard Jones Created by Bentley Colleague Leonard Jones
    • When: Sat, Oct 29 2016 7:12 AM
    • Leonard Jones Last revision by Bentley Colleague Leonard Jones
    • When: Sat, Oct 29 2016 7:28 AM
    • Revisions: 2
    • 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

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