Grasshopper

algorithmic modeling for Rhino

Hello, I trying to calculate the area and the centroid of a surface:


Dim a As New Double
Dim c As New Double
Dim aT As New Double
Dim cT As New Double

cT = S.Centroid
aT = S.Area

For i As Integer = 0 To DATA.Count - 1
print(i)
c = (DATA(i)(0)).Centroid
a = DATA(i)(0).Area
If aT = a And cT = c Then
index = i
End If

Next

What is wrong?

(the error start with S.centroid s is a surface)
thanks

Views: 133

Replies to This Discussion

Hi RG,

there's no such function as Centroid or Area on Surface. Where did you get those from?

The deeper reason behind this is that it's rather expensive (computation cycle wise) to calculate areas and centroids etc. And a lot of the work is the same for all of these properties. That is why all AreaMass properties have been bundled into a single class, that maintains all the data for you:

Dim ap As AreaMassProperties = AreaMassProperties.Compute(S.ToBrep())
A = String.Format("Area: {0:0.0} Centroid: {1}", ap.Area, ap.Centroid)


I also recommend using Breps instead of Surfaces as Surfaces really are quite limited.

--
David Rutten
david@mcneel.com
Poprad, Slovakia

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service