Sowmya,
IMHO you have two issues. The first and most important is to identify the how and why the elements are being generated incorrectly in the first place and make it a priority to address the issue(s) found there first. The second issue is correcting cases similar to what you provided as a sample. Given your test/use case is only one I propose an identification technique to a.) validate as being a closed element, b.) validate that the Start Point of the 1st segment is within tolerance/identical to the End Point of the last segment (if all segments drawn in the same direction - e.g. check with MicroStation "change direction" tool). Using that information should ensure you can detect cases like you provided.
HTH,
Bob
IMHO you have two issues. The first and most important is to identify the how and why the elements are being generated incorrectly in the first place and make it a priority to address the issue(s) found there first. The second issue is correcting cases similar to what you provided as a sample. Given your test/use case is only one I propose an identification technique to a.) validate as being a closed element, b.) validate that the Start Point of the 1st segment is within tolerance/identical to the End Point of the last segment (if all segments drawn in the same direction - e.g. check with MicroStation "change direction" tool). Using that information should ensure you can detect cases like you provided.
HTH,
Bob