Object: NearestValue2D
- Updated2024-09-12
- 1 minute(s) read
(2DAxisSystem | Collections) > 2DCurves > 2DCurve > Object: NearestValue2D
Object: NearestValue2D
The NearestValue2D object provides the coordinates and the index of a curve point that lie nearest to a specified point, in DIAdem REPORT.
The following example creates a 2D axis system with a curve and determines the coordinates and the index of the curve point which is nearest to the point (20,30).
| VBScript | Python |
Dim oMy2DAxisSystem, oMyPos, oMy2DCurve, oMyNearestValueObj Call Report.NewLayout() Call Data.Root.Clear() Call DataFileLoad(DataReadPath & "Report_Data.tdm","TDM","") Set oMy2DAxisSystem = Report.ActiveSheet.Objects.Add(eReportObject2DAxisSystem, "My2DAxisSystem") Set oMyPos = oMy2DAxisSystem.Position.ByCoordinate oMyPos.X1 = 20 oMyPos.X2 = 80 oMyPos.Y1 = 20 oMyPos.Y2 = 80 Set oMy2DCurve = oMy2DaxisSystem.Curves2D.Add(e2DShapeLine, "MyNew2DCurve") oMy2DCurve.Shape.XChannel.Reference = "[1]/[1]" oMy2DCurve.Shape.YChannel.Reference = "[1]/[2]" Set oMyNearestValueObj = oMy2DCurve.FindNearestValue(20,30) Call Report.Refresh() Call MsgBoxDisp("x value: " & oMyNearestValueObj.X & vbCrLf & "y value: " _ & oMyNearestValueObj.Y & vbCrLf & "point index: " & oMyNearestValueObj.Index)