MicroStation .NET: Table Seed Harvester

  • Products
  • Services
  • All Publications
  • CONNECT Publications
  • Links
  • WishList
  • LA Solutions
  • Home
LA Solutions
tel: +44 1398 361 800
DgnPlatformNet

Introduction

This article is for C# developers who want to write an application for MicroStation CONNECT. It describes a way to use DGNLib data in your own app. This is not a complete application: rather, it describes what might otherwise be a non-intuitive approach to solve a problem.

The Problem that Table Seed Harvester Solves

A MicroStation configuration often stores libraries of data in read-only design libraries, also known as DGNLibs. A set of DGNLibs is usually available as part of a MicroStation workspace. An administrator will often allocate different DGNLibs to store different kinds of data: for example, text styles, levels, dimensions etc. This article discusses table seeds that are stored in a DGNLib.

Because those data are stored independently of a user's active DGN file, your app may want to copy data from a DGNLib. This example shows how to harvest DGNLib data programmatically for use in your own .NET app.

Be Communities

If you want to ask about development for MicroStation, post your question to the MicroStation Programming Forum.

MicroStation Tables

MicroStation CONNECT Edition provides Tables.

MicroStation Help: Tables

A MicroStation administrator might include several table seeds in a DGNLib. The seeds are available to a MicroStation operator via a menu, which is available while using the Tables user interface.

Table Seeds

A table seed is a DGN model that contains a single DGN element. That element must be a table, a TextTableElement in programmer-speak.

An administrator would presumably design one or more tables and place them in a DGNLib. The name of the model is the name of the seed.

Table Seed Harvester

Finding Table Seeds

You want, as a MicroStation developer, to examine the visible DGNLibs and extract information about table seeds. Here's the code …

public int GetTableSeedModels ()
{
  int nModels = 0;
  DgnLibIterator iterator = new DgnLibIterator(DgnLibSelector.ElementStyles);
  foreach (DgnFile lib in iterator)
  {
    // Examine each DGN model in the file
    var indices = lib.GetModelIndexCollection();
    foreach (var index in indices)
    {
      StatusInt status;
      DgnModel model = lib.LoadRootModelById(out status, index.Id);
      if (IsTableSeed(model))
      {
        string s = $"Table seed: {lib.GetFileName ()}.{model.ModelName}";
        MessageCenter.Instance.ShowMessage(MessageType.Debug, s, s, MessageAlert.None);
        ++nModels;
      }
    }
  }
  return nModels;
}

Is this a Table Seed?

Method IsTableSeed is straightforward: it has to count the number of elements in a DGN model and, if it finds exactly one, test whether that element is a TextTableElement …

bool IsTableSeed(DgnModel model)
{
  var elements = model.GetGraphicElements();
  return (elements.Count() == 1 && elements.First() is TextTableElement);
}

Acknowledgements

This article was written as a summary of my own experience in developing the DGNLib Harvester. I was helped on my way by hints & tips on the MicroStation Programming Forum. Special thanks go to YongAn Fu, a regular contributor to Bentley Communities, for his suggestions.

Questions

Post questions about MicroStation programming to the MicroStation Programming Forum.


Bentley Technology Partner

Trademarks

All trademarks are acknowledged. Trademarks may be registered in some jurisdictions.
e-mail Contact LA Solutions using this enquiry form.

Home
Home
Updated on 14-Sep-2020 Copyright © 2020…2025 Jon Summers