A Table Seed is a model in a DGN file. Usually the DGN file is a DGNLib listed in configuration variable MS_DGNLIBLIST. To find a table seed programmatically, I suppose that the procedure looks like this...
MS_DGNLIBLIST
Here's some 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; }
private bool IsTableSeed (DgnModel model) { ElementId dummy = DgnTextStyle.GetSettings(Session.Instance.GetActiveDgnFile()).Id; // Use static method to create a TextTable for testing TextTable someTable = TextTable.Create(1, 1, dummy, 1.0, model); // Attempt to copy the DGN model to see if it is a Table Seed TextTable table = someTable.Copy(model); return (null != table); }
That almost works. It gives me the models that contain a Table Seed, but it also gives me the default model in each DGN file when that does not contain a Table Seed. I admit that function IsTableSeed looks clunky. Is there a better way?
IsTableSeed