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?
Or, alternatively, you can use PropertyHandler to read area calculated by MicroStation.
I do not prefer this option, because it's slower, but it's standard MicroStation VBA feature, discussed many times, where also examples are available.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point