Grasshopper

algorithmic modeling for Rhino

Hello there

Like my last question I try to find equal points and delete them. To compare these points i try to use the Equal function.

If x(i)equals(x(i)+1) = True Then

EndIf

But it destroyed my If Orders:

1. Error (BC30205): "end of"-Anweisung erwartet. (line 96)

So i try to convert the Points3d to Strings:

v1 = (x(i).ToString())

or

v1 = (x(i).ToString("N10"))

With the result:

1. Conversion from type 'Point3d' to type 'String' is not valid. (line: 0)

So how can I extract a Data to compare the points and if equal is true do whatever I want. on my Linecomparescript ist works:

Ly = (y(i + 1).getlength())

Lx = (x(i).getlength())

If Lx.ToString("N10") = Ly.ToString("N10") Then
          i = i + 1
End If

'cause there is only one Double inside.

THX for your ideas!

Views: 466

Replies to This Discussion

If x(i)equals(x(i)+1) = True Then

EndIf

This is not valid VB code. This is:

If (x(i).Equals(x(i+1))) Then

End If

Note that equals requires exactly the same coordinates. Even if the points are one electron apart, they will still register as different. If you want to compare with tolerance you should compare the distance between two points to some threshold value.

--

David Rutten

david@mcneel.com

Thx that helpes first step!

I ll try to extract the XYZ Coordinades and then just use 3 decimals, that should be exact enough.

Not in all cases. When you start rounding numbers then numbers that are very close apart but on different sides of a rounding threshold will actually be pushed further apart. The only reliable way to test whether points are coincident within tolerance is to measure the distance between them and compare that distance to a tolerance threshold.

--

David Rutten

david@mcneel.com

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service