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.
Axel Krueger said:Such code looks pretty bloated when compared to code in the past or the still existing interop functions
You're comparing apples with oranges.
The CONNECT code is doing work to obtain a DgnFile reference from an abstracted Document. It's not constrained to a DgnFile. Someday, you may find that extra capability useful. In the meantime, wrap that bloated code in a slimline call …
bool OpenDesignFileForProgram (String filename, DgnFileOpenMode fileMode = DgnFileOpenMode.ReadOnly) { DgnDocument targetDgnDocument = DgnDocument.CreateForLocalFile (filename); DgnFileOwner dgnFileOwner = DgnFile.Create (targetDgnDocument, fileMode); DgnFile dgnFile = dgnFileOwner.DgnFile; StatusInt i; DgnFileStatus fs = dgnFile.LoadDgnFile (out i); return DgnFileStatus::Success == fs; }
Regards, Jon Summers LA Solutions
that's clear, but what can I do with the DimensionStyles from a dgn (lib)
Hi Axel,
Axel Krueger said: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
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point