[Connect Upd. 15/16 MDL/C++] Set ElementLineStyle for new level


I would like to set the ElementLineStyle (using standard linestyles 0-7) for a new level. It should be a quite simple task but I got some troubles.

        LevelId lvlID = ISessionMgr::GetActiveDgnModelRefP()->GetFileLevelCacheP()->ComputeHighestUsedLevelId();
		EditLevelHandle elh = ISessionMgr::GetActiveDgnModelRefP()->GetFileLevelCacheP()->CreateLevel(L"TestLayer", 555, lvlID + 1);
		LsEntryCP ls = LineStyleManager::ResolveLineStyle(3, ISessionMgr::GetActiveDgnModelRefP()->GetDgnFileP());
		if (ls != NULL)
			lifalib_dmsg("Name = %ls", ls->GetStyleName());
			elh.SetByLevelLineStyle(*ls, NULL, *ISessionMgr::GetActiveDgnModelRefP()->GetDgnFileP());


My problem is that LineStyleManager::ResolveLineStyle returns NULL.

Is there another way to set the linestyle for a level ?

I've tried to use the MDL funktion mdlLevel_setElementStyle and it works just fine when working in a "normal" active design file, but some of our users often work in a model from a reference file that is "activated". In that case I have to store the fileLevelCache using:


Then I can set the linestyle for the level and it seems to work just fine, but the linestyle is not saved even though that I use


and / or


Any ideas ?

Regards, Evan

Parents Reply
  • It is true that there is no way how to obtain line style entry for standard MicroStation line styles 0 - 7

    I found this comment in MicroStationAPI help under LineStyleManager: If the style number is in the range STYLE_MinLineCode to STYLE_MaxLineCode, the LineStyleManager does not retrieve an LsDefinition. Handling of these line styles is strictly defined and does not require an LsDefinition.

    enum   LsKnownStyleNumber { 
      STYLE_MinLineCode = 0, STYLE_MaxLineCode = 7, STYLE_ByLevel = 0x7fffffff, STYLE_ByCell = 0x7ffffffe, 
      STYLE_Invalid = 0x7fffff00 

    Regards, Jon Summers
    LA Solutions