Grasshopper

algorithmic modeling for Rhino

Hi,
I'm trying to write a script that gives me a parralellogram shaped section given 3 points of the contour and the centroid of the parralellogram. (So the script has to find the fourth point...).

Input is the aproximate parralellogram (incrv), the centroid (inPt) of the new parralellogram and an offset distance (dist) (to create a hollow section)

I'm new to grasshopper en VB-scripting. As intuiative grasshopper seems, so complex seems VB to me... So far I was able to make an offset of the curve, make a brep of the incrv and the offsetted curve and determine the centroid of that brep. The only thing I still need is to move the vertex of the incrv so I can make a recursive loop until the centroid of the brep coïncides with the inPt.
I'm confused of all the different types of curves and the different actions you can do with them, for example I can move the vertex of an onnurbcurve but I can't offset it. I can offset an oncurve but I can't move a vertex of it...
can anybody help? this is what I have so far (working with oncurve):

Private Sub RunScript(ByVal inCrv As OnCurve, ByVal inPt As On3dPoint, ByVal Dist As Double, ByRef A As Object, ByRef brepout As Object, ByRef cen As Object, ByRef area As Object)

Dim Normal As New On3dVector(0, 0, 1)
Dim outCrv() As OnCurve = Nothing
print("1ste punt: " & incrv.PointAt(0).x & ", " & incrv.PointAt(0).y & ", " & incrv.PointAt(0).z)
RhUtil.RhinoOffsetCurve(inCrv, Dist, inPt, Normal, 0, 0.1, outCrv)
Dim allCrv(1) As OnCurve
allCrv(0) = inCrv
allCrv(1) = outCrv(0)
Dim brep(0) As OnBrep
rhutil.RhinoMakePlanarBreps(allCrv, brep)
brepout = brep(0)
A = allCrv
Dim mp As New OnMassProperties()
brep(0).AreaMassProperties(mp, True, False, False)
cen = mp.Centroid

Views: 1098

Replies to This Discussion

Hey David, Corneel,

bedankt voor de tips om de code een beetje overzichtelijk te houden. Ik ben begonnen met groeperen en het ziet er al heel wat overzichtelijker uit. In mijn beginners enthousiasme heb ik natuurlijk niet de ganse tutorial gelezen voor ik er aan begon :).

Nog een bericht voor de webmaster: Ik kan niet reply-en op jullie laatste bericht omdat de "ketting" doorbroken is door Taz, die replyde op een eerder bericht.

groet

Piet
How come the GH Google translate toolbar doesn't have English as a translation option?

That would be handy if it can be updated...

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