How can find the min X of List of point2d?

How can find the min X of List of point2d?

Stakin
Collaborator Collaborator
136 Views
1 Reply
Message 1 of 2

How can find the min X of List of point2d?

Stakin
Collaborator
Collaborator

I want to query and group some 2D points, such as find the maxmum X coordinate in the point, find the points with the maxmum X coordinate, but when I query with linq, the code error and cannot run.Can someone help me out? thanks!
The error message is as follows:

Conversion From Type 'GroupedResultEnumerable(Of Point2d,Double,VB$AnonymousType_0(Of Double,Double))' to type 'IWin32Window' is not valid.

the code is as follows:

Sub Main
		Dim oTG As Inventor.TransientGeometry = ThisApplication.TransientGeometry
		Dim oPt2d As New List(Of Point2d)
		For i As Integer = 1 To 100
			oPt2d.Add(oTG.CreatePoint2d(Int(99*Rnd)+1,Int(99*Rnd)+1))
		Next
		Dim oRad 'As Double		
		oRad=From oPt As Point2d In oPt2d.Cast(Of Point2d)
                      Group By oPt.X
                      Into oMax = Max(Abs(oPt.X))
		MessageBox.Show(oRad, "Title")					  
		Dim oMaxXPt2d As List(Of Point2d)
		oMaxXPt2d=oPt2d.Cast(Of Point2d).Select(Function(p As Point2d) p.X=oRad).ToList
End Sub

 

0 Likes
137 Views
1 Reply
  • I
Reply (1)
Message 2 of 2

Michael.Navara
Advisor
Advisor

The reason is the method MessageBox.Show is overloaded. The first argument should be of type string or IWin32Window.

Convert your variable oRad to string and it cen resolve your issue.

0 Likes