Attempting to use design scripts for text replacement in a multi-line string. IE - SEE SHEET $SNUM$.
This can be done fairly quickly with a config variable and concating the text. My problem is that the SEE SHEET is not standard, and can be basically anything.
It is more like {VARIABLE TEXT BEFORE} $SNUM$ {VARIABLE TEXT AFTER}
What needs to be done is basically split using $, grabbing the first portion, then grabbing all text after the last $. Then concating: character = TEXT BEFORE + 2 + TEXT AFTER.
Can this be done in a design script?
Maybe? You need to use a regular expression, and unfortunately design script language for this isn't super easy. From the InterPlot help:
extract_envr_expression The extract_envr_expression keyword specifies a regular expression that is used to filter the string returned by extract_envr_value. When you set extract_envr_value to a particular string in the DGN file, IPLOT parses the string with respect to the regular expression specified by extract_envr_expression, and then sets the value that matches the regular expression. It is not necessary to set extract_envr_expression for every extract_envr_value. You can set extract_envr_expression once at the top of the Design Script and use the same expression for a series of assignments. The extract variables keywords enable you to extract information from a DGN file, store it in per-plot environment variables, and then write it back to the IPARM in Organizer. You can then display this information as additional columns in Organizer. For more information on extracting variables, see the Extracting Variables section in Organizer's Help file. Syntax: extract_envr_expression = string Example: ! Extracting Variables Design Script. ! This Design Script extracts the ! Discipline and Page Number from ! the Titleblock section of the DGN file. ! It also substitutes the sheet number and ! and the total sheets of each Discipline. ! if (level_name eq "titleblock") then extract_envr_variable="DISCIPLINE" extract_envr_expression="[A-Z]*" extract_envr_value=characters extract_envr_variable="SHEET_NUM" extract_envr_expression="[0-9]+" extract_envr_value=characters endif if (characters eq "S$") then envr_variable="GROUP1_PAGE_NUMBER" characters= envr_value else if (characters eq "T$") then envr_variable="GROUP1_TOTAL_PAGES" characters= envr_value endif
if (type eq text) then ; make sure $SNUM$ is in string if (characters eq "*$SNUM$*") Then ; get chars before extract_envr_variable="BEFORE" extract_envr_expression="^(.*)\$" extract_envr_value=characters ; get chars after extract_envr_variable="AFTER" extract_envr_expression="\$(.*)$" extract_envr_value=characters ; construct new string envr_variable="BEFORE" characters = envr_value + SHEETNUM envr_variable="AFTER" characters = characters + envr_value endif endif
That might get you close. I'm not 100% sure how much of the regex language Bentley implemented. I haven't tested this, and I'm worried it'll keep the $ in the string. If so you'll probably have to get ahold of bentley for more info.
the before extract_envr_expression uses regex where:
^ - means beginning of string
(.*) - .* means match any character any number of times, the () groups the characters it finds
\$ - means search for a literal $
the after expression:
\$ - literal $ again
(.*) - any character any number of times and save to a group
$ - the end of the string