I would like to change the name of a level, but it don't work.
I use the „Text.dgn“ Example for testing.
Here is a part of the code.
I use: bentley.interop.microstationdgn
using MicroStationDGN;
private MicroStationDGN.Application msApp;
private MicroStationDGN.DesignFile msDGN;
msApp = new MicroStationDGN.Application();
// Works
String DGNLevelName = "ClipShape";
MicroStationDGN.Level dgnLevel = msApp.ActiveDesignFile.Levels.Find(DGNLevelName);
MessageBox.Show(dgnLevel.ID.ToString());
MessageBox.Show(dgnLevel.Name.ToString());
MessageBox.Show(dgnLevel.Description.ToString());
// Works (Focus in Levenmanager switch to ClipShape)
dgnLevel.IsActive = true;
// Problem part
String newName = "Clip";
dgnLevel.Name = newName;
// Works (Levelmanager reloads)
msApp.ActiveDesignFile.Levels.Rewrite();
........................................
At this - dgnLevel.Name = newName;
i alway got a „Level-ID is invalid“.
Same is if i try - dgnLevel.Description = newName;
Debugger gives me a „Level-ID is invalid“.
I have tried some other tests, like:
msApp.ActiveDesignFile.AddNewLevel("Demo_1");
or
msApp.ActiveDesignFile.DeleteLevel("Demo_1");
All works fine.
Whats wrong with my code or the „ string Name { get; set; } “
Thank you
Harry