Help me. How to get information Level ?

Parents
  • Hi NguyenDinh,

    I am not sure what do you mean by "information level". Are asking how to obtain information about a specific level? In such case you can use ModelReference.Levels collection (so it's DesignFile.Levels for your active model). The collection provides several way how to access the level object: by index, by name and there is also Find methods.

    With regards,

    Jan
  • Hi Jan
    I wan't see value level.number of element .With VBA in debug then no problem but with Addin then Value: COM Object ?
  • Hi,

    Unknown said:
    With VBA in debug then no problem but with Addin then Value: COM Object ?

    Despite of VBA and NET uses the same API, they are different in some aspects, especially if talking about Debug information. They are runtime information, so to interpret them correctly sometimes require good knowledge how API works, which in the case of COM is not always easy. And it can also easily leads to wrong picture how to use API, because object model published in API is not equal to Debug information.

    Unknown said:
    I wan't see value level.number of element

    There is no direct access from an element to level number, because the number is not the element property. It's something like:

    1. There is an element
    2. Get me level where the element is placed
    3. From the level definition object, get me its number

    Written in one line it would be something like

    num = Element.Level.Number

    With regards,

      Jan

  • My code :
    private Bentley.Interop.MicroStationDGN.Application app = null;
    app = BMI.Utilities.ComApp;
    ElementScanCriteria _ec = new ElementScanCriteriaClass();
    ElementEnumerator _es;
    TextStyle _TextStyle;
    _ec.ExcludeAllTypes();
    _ec.IncludeType(MsdElementType.Text);
    _es = app.ActiveModelReference.Scan(_ec);
    TextElement _etext;

    while (_es.MoveNext())
    {
    _etext = (TextElement)_es.Current;

    _TextStyle = _etext.TextStyle;
    _TextStyle.Height = 27.5;
    _TextStyle.Width = 27.5;
    _etext.TextStyle = _TextStyle;

    _etext.Rewrite();
    _etext.Redraw(MsdDrawingMode.Normal);
    Debug.Print(_etext.Level.Number.ToString());
    Erorr _etext.Level.Number = null in Local when Debug
  • Hi,

    because there is no any further information or question, the code only, I am not sure how to answer. So just a few comments:

    • Please, always use Syntaxhighlighter tool (yellow pencil icon) when posting any code and to set a correct language. To read an unformatted not colored text is time wasting effort.
    • Why do you use _ in variable names? Naming style is personal or company issue, but there are some general recommendations for all languages (e.g. for C#) and I am sure to use _ is treated as bad style generally (and is not allowed in languages like C++). Do you use tools like StyleCop to keep your code clean?
    • Casting to TextElement is not necessary, it's better to use _es.Current.AsTextElement.
    • From MicroStation V8 XM Edition it's not necessary to redraw elements after they are written to a design file. It means _etext.Redraw is redundant and should be removed.
    • It can be dangerous to rewite element inside Element Enumerator, because if the element size is changed, it's moved to the end of design file, so it will be processed probably again, because Element Enumerator is not fixed structure, but more like a dynamic cache.

    My question is why do you want to use level numbers? It's not ensured such number exist as can be easily tested in Level Manager. MicroStation uses internally system generated numbers, but they are not displayed by default. So MicroStation help file for details. But imporant thing is thay you should never (from MicroStation 8.0) work with level numbers, but always with level names or in the code with level definition objects.

    With regards,

      Jan

  • Hi jan
    I've fixed the problem.
    I thank you
Reply Children
No Data