Friday 17 October 2014

Rectangle Centerlines Part 06

...continued from Part 5

The values of the coordinates are always returned in meters which is the internal unit of Solid Edge. This needs to be converted to document units since some values like 50 mm are reported as 0.050000043 or 0.049999999999 in internal units and pose problems when comparing due to rounding errors.


The GetValueInDocumentUnits function takes the coordinate value as double and also returns a double after converting the value to document units.

startXthis = GetValueInDocumentUnits(startXthis)
startYthis = GetValueInDocumentUnits(startYthis)

endXthis = GetValueInDocumentUnits(endXthis)
endYthis = GetValueInDocumentUnits(endYthis)


Private Function GetValueInDocumentUnits(ByVal Value As Double) As Double
  Return Val(oUoM.FormatUnit(SolidEdgeConstants.UnitTypeConstants.igUnitDistance, Value))
End Function

Next, a For loop iterates through the list of other lines and checks if the start point of the this line matches the start point of the other line.

If it does match, the For loop Exits and the StartPointMatch Boolean is set to True which was assumed to be False to begin with.

StartPointMatch = False

For j As Integer = 0 To oListOfOtherLines.Count - 1
  oListOfOtherLines.Item(j).GetStartPoint(startXother, startYother)
  oListOfOtherLines.Item(j).GetEndPoint(endXother, endYother)

  startXother = GetValueInDocumentUnits(startXother)
  startYother = GetValueInDocumentUnits(startYother)
  endXother = GetValueInDocumentUnits(endXother)
  endYother = GetValueInDocumentUnits(endYother)

  If ((startXthis = startXother) And (startYthis = startYother)) Or _
     ((startXthis = endXother) And (startYthis = endYother)) Then
     StartPointMatch = True
    Exit For
  End If

Similarly, the end point of the this line is also checked.

If either the start point or end points of the this line do not match with any of the start or end points of the other lines, then the lines are disconnected and there is no need to further check the remaining lines from the all lines list.

If (StartPointMatch = False) Or (EndPointMatch = False) Then
  LineIsConnected = False
  iErrorCode = 1003
  Return iErrorCode
  Exit Function
End If

The error code returned is 1003.

If the lines are indeed all connected, the error code still is 0 which was set at the beginning of the ValidateRectangle function and the function returns with no non-zero error code. This launches the dialog.

Continued to Part 7...

Index of all Solid Edge Tutorials, Tips, Videos...

No comments:

Post a Comment