Grasshopper

algorithmic modeling for Rhino

How would I find the area of a curve using VB? I found the areamassproperties method of the OnCurve class but its asking for points and vectors as arguments, and as I am new to VB script I wasn't sure how to convert the mp Massproperties object that is passed on by reference into an integer that I can pass back to grasshopper.

Best,

Ben

Views: 630

Replies to This Discussion

Private Sub RunScript(ByVal inCrv As List(Of OnCurve), ByRef A As Object)
Dim dList As New List (Of Double)

Dim tol As Double = RhUtil.RhinoApp().ActiveDoc().AbsoluteTolerance()

Dim crv As OnCurve
For Each crv In inCrv
If (crv.IsPlanar) Then
Dim tBox As New OnBoundingBox
crv.GetBoundingBox(tBox)

Dim tPt As New On3dPoint
tPt = tBox.Center()

Dim tPlane As New OnPlane
crv.IsPlanar(tPlane)

Dim cMass As New OnMassProperties
Dim area As New Double
crv.AreaMassProperties(tPt, tPlane.zaxis, cMass, Nothing, Nothing, tol)
area = Math.Abs(cMass.Area())
dList.Add(area)
End If
Next



A = dList
Thanks, this helped.

T

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service