ABD SS6 - Named expressions question

Hi

I have a question about named expressions. Maybe we use them in a strange way or we don't use all their capabilities.

When we create a plot file the name of the file is for example: "js_A01_Situation.dgn"

We create a named expression attached in all the plot files that is:

System.String.Substring(System.Path.GetFileNameWithoutExtension (ActiveFile.FileName),7,-1)

It is obviously based in the length of the string.

We use this named expression to take parts of this file name " js_A01_Situation.dgn" and fill the border of the drawing thanks to the pen table.

Project code: js

Sheet number: A01

Sheet title: Situation

For us is very useful. We change the name of file o rewrite it once and we change the name of pdf we generate without open the file.

Now we have a little problem. We must deliver the sheets with the sheet title in two languages in two different lines.

Continuing with the previous example a possible file name would be: "js_A01_Situation-Emplazamiento.dgn"

And obviously the length of the string is different in every case. Is there any way to trim the string based in a special character. In this case it would be "-"

Lot of thanks

Regards

  • I don't know the first thing about name expressions, but, does this help any?
    communities.bentley.com/.../349437



  • Hi Steve
    After one hour playing what your link I have achieved what I wanted. I can not believe it but it works.
    Named expressions are something mysterious and dark.
    Lot's of thanks
    Borja
  • Hi Steve

    We are here again with this subject. I know you told me you don't dominate this world very well, but maybe you can help me.

    We have this name file.

    mv_A01_Situación__Situation.dgn

    1. I can get with a named expression extract the number "A01" of the name file and put it into the border. It always has three characters. Always the same lenght. That's important.

    The named expression we use is:

    System.String.Substring(System.Path.GetFileNameWithoutExtension (ActiveFile.FileName),3,3)

    2. I can get the english word "Situation" with the info you showed me in the link. I can get from the "__" till the end of file name.

    The named expression we use is: (I know we have to polish it, but by now it works)

    IIf (System.String.Indexof (System.Path.GetFileNameWithoutExtension (ActiveFile.FileName), "__") >= 0,System.String.Substring (System.Path.GetFileNameWithoutExtension (ActiveFile.FileName), System.String.Indexof (System.Path.GetFileNameWithoutExtension (ActiveFile.FileName), "__") +2, -1),System.Path.GetFileNameWithoutExtension (ActiveFile.FileName))

    3.  We don't know how to get the spanish word "Situación". In this case is "Situación" but it can be "Alzado interior". The length changes everytime. Is it possible to trim a string between to characters, in this case "_" and "__", with named expressions?

    Maybe there's another way to get this things. Maybe VBA Macro loaded on the pen table but I can not find examples.

    Lots of thanks

    Regards

    Borja

  • This is a good example where we need a better project menu

    One that controls the naming convention BUT
    Allows you to edit the page properties across a list of all your sheets
    The Model properties is the best way to control all the text in your title blocks and create a index at the same time

    IT JUST NEEDS A LOT OF POLISH AS IT HAS BEEN DROPPED BEFORE MADE USER FRIENDLY AND COMPLETE.

    Ustn since 1988
    SS4 - i7-3.45Ghz-16 Gb-250/1Tb/1Tb-Win8.1-64b

    Eric D. Milberger
    Architect + Master Planner + BIM

    Senior  Master Planner NASA - Marshall Space Flight Center

    The Milberger Architectural Group, llc

  • Borja,

    Can you change file name to mv_A01__Situación__Situation.dgn?

    If so then these expressions may be of some use to plug into your if statement. (They are stored in attached file if you want to test)

    FileName_Last

    System.String.SubString(System.Path.GetFileNameWithoutExtension (ActiveFile.FileName),System.String.LastIndexOf(System.Path.GetFileNameWithoutExtension (ActiveFile.FileName), "__")+2, -1)

    FileName_Next Last

    System.String.SubString(System.Path.GetFileNameWithoutExtension (ActiveFile.FileName),System.String.IndexOf(System.Path.GetFileNameWithoutExtension (ActiveFile.FileName), "__")+2, Session.EvalNEAsInt ("FileName_NextLastMinusLast",0)  )

    FileName_NextLastMinusLast

    System.String.Length(System.String.SubString(System.Path.GetFileNameWithoutExtension (ActiveFile.FileName),System.String.IndexOf(System.Path.GetFileNameWithoutExtension (ActiveFile.FileName), "__")+2, -1))
    -
    System.String.Length(System.String.SubString(System.Path.GetFileNameWithoutExtension (ActiveFile.FileName),System.String.LastIndexOf(System.Path.GetFileNameWithoutExtension (ActiveFile.FileName), "__"), -1))

    Basically "FileName_NextLastMinusLast" expression returns a number difference between

    Situación__Situation "and" Situation

    and is used in Expression "FileName_Next Last"

    Expressions could also be adjusted to trim

    mv_A01_Situación-Situation.dgn?

    HTH's

    Tom

    mv_A01__Situación__Situation.dgn

    http://communities.bentley.com/products/building/building_analysis___design/w/building_analysis_and_design__wiki/31031.extracting-a-text-string-between-specific-characters-using-named-expressions

    Answer Verified By: Borja Gutiérrez Febles