I am calculating the area of a grouped hole with the help of this command ComputeGroupedHoleArea (at the bottom of the page).
It works very well but now I came across an grouped hole with an element in it which has a very small area.
area = area - oEnumerator.Current.AsClosedElement.Area
Throws an error in the Do While block)
block)
. Well...
oEnumerator.Current.AsClosedElement.Area
does throw an error.
The .Area is where it goes wrong so the code is fine but the .Area itself is not.
After some investigation it turns out the area of the element was very small. The element was a triangle with the second point exactly between the other two.
When I used Microstation itself to calculate the area it said it could calculate it.
When I used Microstation to calculate the area of the Grouped Hole it worked fine.
A way to let Microstation calculate the area outside VBA and return the value would be a solution?
Now I would like it very much if it would just return 0.
Try and Catch looked promising but that does not exist (yet) in VBA.
I read something about using On Error but It is a little bit out of my league (yet).
Does anyone has a solution for catching such an error and replace it with another value (0)?
A dgn with the grouped hole is in the attachment.
errorArea.dgn
Is there a way to let Microstation itself calculate it and return the value to VBA?
Microstation does calculate the area of the Grouped Hole, with an hole with no (calculatable) area in it, and returns no error.
pieter Dorp said:Is there a way to let MicroStation itself calculate it and return the value to VBA?
Jan usually suggests the VBA PropertyHandler. There are examples in VBA help.
PropertyHandler
Regards, Jon Summers LA Solutions
Jon Summers said:Jan usually suggests the VBA PropertyHandler.
Yes, I do :-) ... even when I prefer to do not use it personally. Or, better to say, the idea of PropertyHandlers is great and they can provide a solution when specific feature is not supported by VBA API directly.
But there are some disadvantages also, so I prefer to e.g. try to find MDL function that can be called (which is probably faster always and provides return code whether operation was successful). In the worst case, people overuse PropertyHandlers in situation, when VBA API even exists (but they are lazy to use VBA help or search forums for the best solution).
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point