OpenRoads Designer CONNECT Edition SDK Help

Create new level in DGN

The below code snippet shows how to create a new level in current dgn.


 public bool CreateNewLevelInDGN()
        {
            //Get Active Dgn Model
            DgnModel model = Session.Instance.GetActiveDgnModel();

            //Get levels information from current dGN 
            FileLevelCache fileLevelCache = model.GetFileLevelCache();

            //Create a new level 
            EditLevelHandle levelHandle = fileLevelCache.CreateLevel("ASampleLevel");
            if (levelHandle != null)
            {
                //Set color to newly created level, Range 0-255
                LevelDefinitionColor color = new LevelDefinitionColor(82, model.GetDgnFile());
                levelHandle.SetByLevelColor(color);

                //Set line style to newly created level, Range 0-7
                LineStyleParameters lineStyleParameters = null;    
                LevelDefinitionLineStyle lineStyle = new LevelDefinitionLineStyle(1, lineStyleParameters, model.GetDgnFile());
                levelHandle.SetByLevelLineStyle(lineStyle);
                return true;
            }
            return false;
        }

After successful level creation , the new level will appear in Level Manager. To use the newly created level, user can set it as active level from OpenRoads Designer application.

The below image shows the level "ASampleLevel" which is newly created and set as active.

Output