New Version of MVBA that Creates Element Templates from Levels in a DGN File

I assume many Civil product users are like me: Since the particular civil product we used created many of the elements in our DGN files, Element Templates were not seen as a priority, nor as a necessity.

However, as we begin using more and more Open Roads tools, we find ourselves needing more and more Element Templates. While I actually have written other VBA macros that convert other types of files into Element Templates, in the XML format, I discovered this MVBA as another tool for the toolbox. However, after some testing and trial sessions, I often found that some level naming conventions are not naturally descriptive enough to be a satisfactory naming convention for element templates. Additionally, since Element Templates do not have a Description attribute, there seems to be very little options than to use verbose, descriptive names when creating element templates. Since most DGNLIB's that I have used that are intended to supply levels contain levels with good descriptions, the modifications that I made to this VBA macro were a "no-brainer" (except for the use of my VBA Coding brain.)

I therefore created a new version of the VBA macro with the following revisions:

  • The original macro named the element template using the level name. This version reads the Level Description and uses it as the Element Template Name while retaining all other element template attributes as the original macro.
  • The original macro created an element template for every level in the file. If run from a DGNLIB, and other DGNLIB's were attached to the file, all of those levels were also added as element template. This version performs two tests before it build the element template XML in memory before writing it to a file. The tests are: "Is this level coming from a DGNLIB or is its name 'Default'?" If either of these is true, that level is skipped.

Notes: The test of whether the level is coming from a DGNLIB does not return TRUE if the active file is a DGNLIB, even if it is one that is supposed to be supplying levels to files in a workspace. Basically, it only returns TRUE if the Level does not exist in the active file but is coming solely from a DGNLIB. Currently, if the level has no description, an unnamed element template is created in the XML file. I have not tested to see what happens if such an element template is imported.

I hope others find this useful.

SaveLevelsToElementTemplateXML.zip