Dimension text is not correctly located for perpendicular distance relation

I am getting an issue for dimension text for perpendicular distance relation added using API IModelDoc2::IAddDimension2()

The issue particularly occurs if there are multiple distance relations (not for same but different entities) applied and only if, out of them a perpendicular distance relation is applied first using API.

Following is the work flow.

1. Created three sketch lines(Line1, Line2, Line3) using API ISketchManager::CreateLine()

2. Added perpendicular distance relation between Point 1 of Line 2 and Line1 using API IModelDoc2::IAddDimension2() with dimension location computed approrpiately

3. Added horizontal distance relation between end points of Line 3 using API IModelDoc2::IAddHorizontalDimension2() with dimension location computed approrpiately

The result for above work flow is as shown in snaps WrongResult.jpg and WrongResult_ZoomOut.jpg. The dimension text is not located at the position specified using API IAddDimension2()

Surprisingly, if the steps 2 and 3 are interchanged (Horizontal relation is added first), then the result is correct as shown in CorrectResult.jpg

Can anybody tell me why this issue is occurring?

SolidworksApi macros