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

Hi

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());
		}
		else
			lifalib_dmsg("NULL...");

		ISessionMgr::GetActiveDgnModelRefP()->GetFileLevelCacheP()->Write();

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:

ISessionMgr::GetActiveDgnModelRefP()->GetFileLevelCacheP()->Write();

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

mdlLevelTable_rewrite(mdlModelRef_getActive());

and / or

ISessionMgr::GetActiveDgnModelRefP()->GetFileLevelCacheP()->Write();

Any ideas ?

Regards, Evan

Parents Reply Children