[v8i VBA] Seemingly random propertyHandler failures

I must be using the propertyHandler slightly incorrectly, because it works most of the time.  The function I'm asking about has worked on thousands of lines, including this one!   I'm trying to access the "count" property because I want to access the element's segments.  It's easiest just to show:

Apologies about the messy code, you can probably tell I'm a bit frustrated at this point.  This was about 3 lines of code and all the rest is various attempts to make this stop happening, including making this a physical element in the drawing at all. 

Clearly the property is there and has a value.  I clicked the element and highlighted it green in the screenshot.  Why can I not access it?

  • Hi Scott,

    without test case (code snippet + dgn file) it's hard to guess what can be wrong.

    A few notes:

    Clearly the property is there and has a value. 

    The fact there an element has a property and it's displayed in Element information dialog does not mean PropertyHandler exists. It's VBA feature that some properties can be accessed, some not, some for read-only, some for full access.

    I must be using the propertyHandler slightly incorrectly, because it works most of the time.

    In my opinion the best way how to use PropertyHandler is to don't use it at all. It should be "the last solution or workaround" where standard VBA object model does not provide required data, not "first selection" code.

    They have plenty of disadvantages, for example:

    • Bad performance: My experience is that to access data using PH is far more slower than to access it directly using VBA API. It makes sense, because you have to create extra object (property handler), access data using access string and the data are converted in several different ways before they are available.
    • Does not work always:
      • Some property handlers are not available (and there is no such list available and it has to be tested by developer).
      • When there will be more element properties with the same access string (which I think can happen when another application is started and will add own data to Element information dialog), it's not defined what data will be reported.
    I'm trying to access the "count" property because I want to access the element's segments.

    Use MicroStation VBA feature as it should be used: LineElement provides vertices count property, so property handler should not be used.

    With regards,

      Jan

    Answer Verified By: Scott Clarke 

  • Thank you!  I did not read carefully enough to see that GetVertices has a defined order, so I will prefer that and VerticesCount in the future.