Hi,
I know this has been asked before but perhaps there are any updates on this matter.
The method DgnFile.GetTextStyles() only seems to return the TextStyles in the active designfile (if DgnFile the active designfile).
I therefore tried the following code but no dgnlibs are found, and yes, there is a dgnlib containing TestStyles in MS_DGNLIBLIST.
ArrayList textStyles = new ArrayList();
BM.DgnLibIterator iterator = new BM.DgnLibIterator(BM.DgnLibSelector.TextStylesOnly);
// Get styles in active file (works fine for the active file) foreach (BDPN.DgnTextStyle textStyle in DgnHelper.GetActiveDesignFile().GetTextStyles()){ textStyles.Add(textStyle.Name);}
// Get styles in dgnlibs (no dgnlibs found) foreach (BDPN.DgnFile dgnlib in iterator) { foreach (BDPN.DgnTextStyle textStyle in dgnlib.GetTextStyles()) { if (textStyles.Contains(textStyle.Name) == false) { textStyles.Add(textStyle.Name); } } }
No one?
Owner consultant at Surell Consulting AB
The C++ equivalent is
bvector <DgnTextStylePtr> DgnTextStyle::BuildList (StyleIteratorMode mode)
where StyleIteratorMode is
StyleIteratorMode
Invalid ActiveFileOnly LibrariesOnly ActiveFileAndLibraries
Krister Surell said:BM.DgnLibIterator iterator = new BM.DgnLibIterator(BM.DgnLibSelector.TextStylesOnly);
What happens if you write this?
BM.DgnLibIterator iterator = new BM.DgnLibIterator(BM.DgnLibSelector.None);
Regards, Jon Summers LA Solutions
Nope, no result for BM.DgnLibSelector.None either (one would think that there would be a BM.DgnLibSelector.All as well).
/Krister
[DllImport("ustation.dll")] public static extern void mdlDialog_dmsgsPrint(byte[] wMsg); private static void GetTextStylesInDgnLibs() { ArrayList textStyles = new ArrayList(); DgnLibIterator dgnlibIter = new DgnLibIterator(DgnLibSelector.ElementStyles); foreach (DgnFile dgnlib in dgnlibIter) { foreach (DgnTextStyle textStyle in dgnlib.GetTextStyles()) { if (textStyles.Contains(textStyle.Name) == false) { textStyles.Add(textStyle.Name); mdlDialog_dmsgsPrint(Encoding.Unicode.GetBytes(textStyle.Name)); } } } }
Output is as below:
Answer Verified By: Krister Surell
Thanks!
That worked just fine. Not quite obvious that ElementStyles should be used though :).
Krister Surell said:Not quite obvious that ElementStyles should be used
Yes: what is the purpose of DgnLibSelector.TextStylesOnly?
DgnLibSelector.TextStylesOnly
Either it's not working as advertised, or MS_DGNLIBLIST_TEXTSTYLES is defined to point somewhere containing no text styles.
EDIT: dumb horizontal scrollbars in code snippets. From the C++ API:
TextStylesOnly uses MS_DGNLIBLIST_TEXTSTYLES if that is defined. Otherwise it uses MS_DGNLIBLIST.