[CE U12 C#] Reading DimensionStyles from external DGN not working

We try to read the DimensionStyles from an external DGN(LIB) via this code

DgnDocument targetDgnDocument = DgnDocument.CreateForLocalFile(filename);
DgnFileOwner dgnFileOwner = DgnFile.Create(targetDgnDocument, DgnFileOpenMode.ReadOnly);
DgnFile dgnFile = dgnFileOwner.DgnFile;
StatusInt i;
DgnFileStatus fs = dgnFile.LoadDgnFile(out i);
DimensionStyleCollection dsc = dgnFile.GetDimensionStyles();
//dsc is empty

The collection returned from dgnFile.GetDimensionStyles() is empty!

The DgnFileStatus fs is Success, so the file existed and has been opened fine.

When used on the active DGN, this works, but only on the used DimensionStyles. It does not return all DimensionStyles defined in the DGN.

How can we get all DimensionStyles from a dgn(lib), including Styles that are not used, but only defined.

We use a similar function with the same DgnFile loading routine to get the levels from an external DGNFile, which works fine. So it seems to be a problem of DimensionStyles.

Same Problem exists for GetTextStyles() and GetMultilineStyles()

P.S.:  the 5 lines necessary to open the DGN in C#, were in the past only a single command OpenDesignFileForProgram(). Any chance to get such easy way access in the new Connect world for C# as well?

Such code looks pretty bloated when compared to code in the past or the still existing interop functions.

Parents Reply Children
  • Hi Axel,

    but what can I do with the DimensionStyles from a dgn (lib)

    In C++ documentation I see static DimensionStyle::BuildList that allows, using StyleIteratorMode, access dimension styles both from active file and dgnlibs. I do not see similar functionality in managed API, despite of SyleIteratorMode exists. Maybe it has not been implemented yet.

    In general you should not acess DGN files directly when working with any settings from dgnlib(s), because it should be (I think) encapsulated and managed by MicroStation itself.

    With regards,

      Jan