Remove Elements in dgn-file with specific name

I have this:

using (FileLevelCache levelCache = ActiveDgnFile.GetLevelCache())
{
LevelHandleCollection levelHandles = levelCache.GetHandles();
foreach (LevelHandle level in levelHandles)
{
if (level.Name.EndsWith(" P") || level.Name.EndsWith(" L"))
{
levelCache.RemoveLevel(null, level);

levelCache.Write();
}
}
}

But it dont remove the levels. I think I need to remove the elements assosiated with the levels before removing the levels. But I dont know how...

Can anyone help?

Parents Reply
  • Hi Samuel,

    Levels thats are of type "Smart solids" doesnt get deleted.. anyone that know why?

    As Jon wrote, nothing like "Smart Solid level" exist, but what exists is MicroStation SmartSolid element (old, from V8 era).

    It looks like you try to write some program without proper knowledge not only of MicroStation NET API, but also DGN format and how MicroStation creates data. Which makes situation that is not easy to give any advice.

    As Jon wrote, without sharing data and explanation why you guess "Smart Solid level" exists, it's hard to guess anything.

    Crucial is understand how data in DGN format are organized and difference between file / model(s) / level(s) / DGN element(s) and MicroStation (user) element(s). Smart solids are persisted (stored in DGN file) as cells with extra data attached. Moreover, cell is complex element, starting with header, that has no level (because it is not graphical element). So a question is what (what element type) your iteration finds?

    With regards,

      Jan

Children