Trimming Text Substitutions

I am using the filename text substitution in a pen table in order to print the path & filename of my drawing. However, for drawings in ProjectWise, the left part of the text is redundant - shows the server name, etc. Is there any way to trim the text substitution to get only the specific part of the path that I want to see? Something like trim off the first 25 characters of the text substitution.


I. Kinal

Parents Reply
  • Correction, it is possible in MicroStation V8i using a named expression.  Say you define a named expression in one of your DGNLIBs called "TruncatedPrintDefSourceFile".  In the pen table, the replacement string would be "<expr?name=TruncatedPrintDefSourceFile>".  In a design script, the code would be something like "if (text == "__dgnfile__") then characters = "<expr?name=TruncatedPrintDefSourceFile>" endif"

    The "TruncatedPrintDefSourceFile" named expression would need the PrintDefinition and System.String symbol sets.  The expression itself could be one of two I came up with:

    (a) Rightmost 25 characters of print definition source file path if length longer than 25.  Otherwise entire string.

    IIf (System.String.Length (PrintDefinition.SourceFile) > 25,
    System.String.Substring (PrintDefinition.SourceFile, System.String.Length (PrintDefinition.SourceFile) - 25, -1),

    (b) If print definition source file path contains "Documents", use everything to the right of that plus the folder separator character.  Otherwise entire string.  When in ProjectWise mode, this evaluates to the ProjectWise document URL without the datasource name and other characters you probably don't care about.

    IIf (System.String.Indexof (PrintDefinition.SourceFile, "Documents") >= 0,

    System.String.Substring (PrintDefinition.SourceFile, System.String.Indexof (PrintDefinition.SourceFile, "Documents") + 10, -1),



  • Unknown said:

    Correction, it is possible in MicroStation V8i using a named expression.  

    Andrew  thats awesome  but is there any useful documentation on how to use named expressions, the  Mstn V8i help file on this is so lacking I have just avoided named expressions, and I think most  users have too...

    until last week when there was a really good example of how to use named expressions  in find replace  but that's about it,   its an even less understood feature than tags and tag reports ( which unfortunately I really  learned alot  from outside of bentley resources)... 


    Started msnt work 1990 - Retired  Nov 2022 ( oh boy am I old )

    But was long time user V8iss10 ( dabbler CE  update 16 ( 

    MicroStation user since 1990 Melbourne Australia.
    click link to PM me 

  • Thanks - that sounds exactly like what I am looking for. We will try it out and will let you know if we run into any issues.

    I. Kinal