This article is for MicroStation CONNECT administrators and users who want to show environment information in a DGN text element. By environment information we mean data external to the DGN file such as …
There are probably other environment data that we haven't considered. Here's an example of a DGN model with some text elements that show date and time …
If you want to ask questions about MicroStation CONNECT, post your question to the MicroStation Forum.
We assemble the solution from several MicroStation CONNECT technologies including …
Expressions let us extract information from various sources and perform simple computations on those data. The Named Expressions dialog lets us view, define and test an expression …
For example, we can obtain the current date using System.DateTime.Now()
.
That date is a date-time value not intended for human consumption …
07/10/2021 12:33:25
Other operations let us manipulate text. For example, we might want to format the date to something more readable using a format string …
System.String.Format ("{0:yyyy-MMM-dd}", System.DateTime.Now())
The result of that computation is easier on the human eye …
2021-Oct-07
We use the Named Expressions dialog to develop and test an expression. We use the expression in an Item Type property definition.
Item Types
let us define meta data in an Item Type library.
That library can subsequently be used to create an Item instance with named properties.
In this solution we create an Item Type library named Environment that contains Item Type DateTime
…
DateTime
has properties CurrentDate
and CurrentTime
.
Those properties each contain an expression that obtains the system date or time and formats it as a string.
The Expression in the above dialog is not easy to see. Here it is …
System.String.Format ("{0:yyyy-MMM-dd}", System.DateTime.Now())
Once you've defined an Item Type, you can create an Item instance attached to one of three DGN objects …
Use MicroStation's built-in tool to attach an Item Type to a DGN element. If you want to attach an Item Type to a DGN model or file, use MicroStation Explorer.
With Explorer open in MicroStation, right-click the active DGN file, and choose Attach Item on the context menu …
Next, choose the DateAndTime Item Type in the dialog and click Attach …
MicroStation Text Fields are created as part of a DGN text element. To create a Text Field, start placing some text, which opens the Text Editor dialog …
Press the Insert Field button to open the Select Field Type dialog. Choose File Properties …
The Fields Editor dialog opens.
Because the DateAndTime.CurrentDate
and DateAndTime.CurrentTime
are Expressions,
they are calculated automatically.
Those properties are now visible as file properties that you can use in a Text Field …
Follow these steps to create a Text Field that displays a property of the DateAndTime
Item Type …
CurrentDate
or CurrentTime
property
You can install this solution in one of several ways …
Whichever you choose, you can subsequently create a text field that references the required Item Type property.
You can download the Date Time Expressions DGN file. The DGN file was created using MicroStation CONNECT Update 16. It should work with versions of MicroStation CONNECT from Update 12.
Post questions about MicroStation to the MicroStation Forum.