Questions similar to this appear on the Be Community Forums. This problem appeared in the MicroStation Programming Forum.
Q MicroStation's main window caption, by default, displays the current DGN file name and the active model. Sometimes you may want to change that default to something more meaningful to your colleagues.
The answers to those questions are solved by creating a VBA project that responds to
DGN File Events.
We provide a different implementation of subroutine hooks_OnDesignFileOpened
that updates the Application.Caption
each time the user opens a new DGN file …
Public Sub hooks_OnDesignFileOpened(ByVal fileName As String) Debug.Print "Opened design file " & fileName End Sub
A
Setting the DGN file as the Application.Caption
is straightforward,
since we have to do little more than copy the name to the caption …
Public Sub hooks_OnDesignFileOpened(ByVal fileName As String) Debug.Print "Opened design file " & fileName Application.Caption = fileName End Sub
You may want to do a little more work than that. Perhaps you want just the file title displayed, rather than its full path …
Public Sub hooks_OnDesignFileOpened(ByVal fileName As String) Debug.Print "Opened design file " & fileName Application.Caption = ParseFileTitle (fileName) End Sub
ParseFileTitle
extracts the file title from the full path.
The function is included in the
SetMicroStationTitle project.
A
Setting the workspace project name as the Application.Caption
is also straightforward.
In this case, expand the _USTN_USER
or _USTN_PROJECT
name …
Public Sub hooks_OnDesignFileOpened(ByVal fileName As String) Debug.Print "Opened design file " & fileName Dim projectName As String projectName = ActiveWorkspace.ConfigurationVariableValue ("_USTN_PROJECT") Application.Caption = projectName End Sub
A
You obtain the dimension of a model using its Is3D
property.
You need to convert that boolean value to a string.
Something like this …
Public Function ModelDimension(ByRef oModel As ModelReference) As String If (oModel.Is3D) Then ModelDimension = "3D" Else ModelDimension = "2D" EndIf End Sub
Dim title As String title = ActiveModelReference.Name & "is " & ModelDimension (ActiveModelReference)
The functions above are included in the
SetMicroStationTitle project.
You can download this ZIP archive and extract SetMicroStationTitle.mvba to your Workspace\Standards\vba
folder.
Enter keyin vba run [SetMicroStationTitle]modMain.Main
to load and initialise the project.