This Client Server article is republished in its entirety from 2003 for reference purposes.
Have you ever wanted to store more information against a DGN file for use later? Is your manager finding it hard to locate files? Would you simply like an automated title block updater like ProjectWise (we call this last one ProjectWise envy)?
The answer is at hand. The only prerequisites are:
1) Files are stored on NTFS partitions
2) Your client machines are Windows 2000 or later
3) MicroStation V8
Since Windows 2000 was released, some nice things have been added to NTFS. For example, with most files, right clicking and selecting Properties will yield a Summary and possibly even a Custom tab. These tabs allow you to use default fields or to create your own. In this article, you'll learn to use some of these common fields and to create some of your own. Figure 1 displays a shot of the Properties dialog Summary tab.
You can also have these default values as columns in your detail view in Windows Explorer. Right click on the Heading row.
Some of these properties are also available via the File>Properties menu inside MicroStation V8.
Most of these will provide basic information. For creating user-defined attributes, we have the Custom tab.
Don't worry if you don't have a Custom tab right now. After following the steps in this article, you certainly will have one.
Adding information into the File Properties>Summary Tab or the MicroStations File>Properties menu is easy enough. Let's take a look at how you might do this with some VBA code.
Sub justStartingOut()
ActiveDesignFile.Author = "Ron"
MsgBox ActiveDesignFile.Author
End Sub
If you close the design file after running the code, you'll see this in the Summary tab (Figure 6):
The following are now available (using the above ActiveDesignFile object):
Not all of these properties correlate directly to the Summary tab, however. Some are also embedded in MicroStation itself:
.Client will populate the category field in the summary tab.
.Company will populate the properties in MicroStation only.
.LastSavedBy will populate the properties in MicroStation only.
.Manager will populate the properties in MicroStation only.
You will need to determine what fields you will use to achieve your desired results. If you want as much information displayed as possible in the Windows Explorer Details view, you will use the following values, because all of them populate information into the Summary tab.
By using these fields, and displaying the extra columns in Windows Explorer, people who are not familiar with document-coded filenames can look through other values to find the design file relevant to them.
You may have a program that needs to store information against a design file
For example: you may have a VBA program that displays a Web page with as-built photos is based against a design file. Or, another example: perhaps Bentley Redline is installed on the desktop, and an excel spreadsheet displays information regarding the estimated performance of items in our design file (And you thought Bentley Redline was only good for markups!).
You can use engineering links to link the spreadsheet into a few elements. In order to do that, you would need to remember what elements are linked, or use the Show Engineering Links tool each time. Then you would need to format the link correctly, and then teach management how to use them.
Take a look at the spreadsheet example.
Creating a custom property in which to store some information requires nothing more than:
ActiveDesignFile.SetCustomProperty "My custom property", "value"
In our example, it would look like:
ActiveDesignFile.SetCustomProperty "Excel_Linkage", "javascript:void(null);"
This custom property will show up in the Custom tab, in the File Properties dialog (Figure 7).
You can't leave it at that, so you would just snip in some code to read that value and open Excel too. It might go something like:
Sub getCustomPropAndOpenExcel()
Dim oExcel As Object
Set oExcel = CreateObject("Excel.Application")
If ActiveDesignFile.CustomPropertyExists("Excel_Linkage") Then
oExcel.Workbooks.Open ActiveDesignFile.GetCustomProperty("Excel_Linkage")
oExcel.Visible = True
Else
MsgBox "No linkage in this file"
Set oExcel = Nothing
End If
End Sub
When you go to read a custom property value, you need to first check that it exists. Simple error checking should always be done when you write programs. Users should never have to deal with runtime errors.
If the value exists, get Excel to open the workbook, and show Excel on the screen.
If the custom value doesn't exist, let the user know why nothing happened and close the Excel process.
Why not try using the properties of a DGN file to update a tag set in your title block design file or placed cell?
The example below hooks into a tag set called "TitleBlock" and a series of tags within that tag set. You can find this example tag set in the DGN files supplied in \Examples\Borders\ISO in the Workspace Projects directory.
Sub updateTitleblock()
Dim ee As ElementEnumerator
Dim sc As New ElementScanCriteria
Dim eleTag As TagElement
sc.ExcludeAllTypes
sc.IncludeType msdElementTypeTag
Set ee = ActiveModelReference.Scan(sc)
Do While ee.MoveNext
Set eleTag = ee.Current
If eleTag.TagSetName = "TitleBlock" Then
eleTag.Redraw msdDrawingModeErase
Select Case eleTag.TagDefinitionName
Case "Drawn"
eleTag.Value = ActiveDesignFile.Author
Case "DWG No"
eleTag.Value = ActiveDesignFile.Name
Case "Title"
eleTag.Value = ActiveDesignFile.Title
Case "Drawn Date"
eleTag.Value = Date
Case "Rev."
If ActiveDesignFile.CustomPropertyExists("Rev.") Then
eleTag.Value = ActiveDesignFile.GetCustomProperty("Rev.")
End If
End Select
eleTag.Redraw msdDrawingModeNormal
eleTag.Rewrite
End If
Loop
RedrawAllViews
End Sub
I hope you have already discovered a use for properties in your organization.
ProjectWise TechNotes And FAQs
Bentley's Technical Support Group requests that you please confine any comments you have on this Wiki entry to this "Comments or Corrections?" section. THANK YOU!
Original Author: Bentley Technical Support Group