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:
Scott Clarke said: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.
Scott Clarke said: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:
Scott Clarke said: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
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
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.