Grasshopper

algorithmic modeling for Rhino

The answer must be really simple for this one:

I want to offset a planar curve on the XY plane (x) so that the resulting area is a percentage (y) of the original curve area. It works for polylines, but not for a polycurve... what am I missing?

(By the way, if someone has other ideas of how to approach this task, I'm all ears)

 

Private Sub RunScript(ByVal x As Curve, ByVal y As Double, ByRef A As Object, ByRef B As Object)
Dim masspropsx As AreaMassProperties = AreaMassProperties.Compute(x)
Dim originalArea As Double = masspropsx.Area

Dim center_point As New Point3d(0, 0, 0)
Dim height_point As New Point3d(0, 0, 1)
Dim zaxis As Vector3d = height_point - center_point
Dim plane As New Plane(center_point, zaxis)

Dim areaRatio As Double = 0
Dim distance As Double = 100
Dim OCurve As Curve() = Nothing

Do While areaRatio < 0.9
distance = distance - 0.5
OCurve = x.Offset(plane, distance, 0.1, CurveOffsetCornerStyle.None)
Dim ampOCurve As AreaMassProperties = AreaMassProperties.Compute(OCurve(0))
areaRatio = ampOCurve.Area / masspropsx.Area
Loop

A = distance
B = areaRatio

Views: 987

Replies to This Discussion

Hi Santiago,

I don't know how to do it in C# or VB but the work around in python is to use RhinoScript to calculate the area. Check the attached component...

Attachments:

Thanks Mostapha.

I discovered the source of the issue which had to do with the geometry itself, not with the area method.

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