Grasshopper

algorithmic modeling for Rhino

Hi everyone,

I am wondering how to select the origin point on which a Brep is rotated in VB.net? The Breps I have created are just boxes and i would like to be able to rotate them on the y axis from the centre of the bottom surface.

I have had a look on the Grasshopper Primer V2 and found the code "rotate.Rotation(angle, OnUtil.On_yaxis, OnUtil.On_origin)" but I don't know how to change the OnUtil.On_origin to the centre point of the base surface.

Any help would be very much appreciated.

Views: 664

Replies to This Discussion

you need to determine which is the bottom surface and then use a centroid of the brep.Face().NurbsSurface as an origin point. See code below of how to extrapolate the surface and centroid.

Private Sub RunScript(ByVal inContext As List(Of OnBrep), ByRef A As Object, ByRef B As Object)
Dim srfList As New List (Of OnNurbsSurface)
Dim ptList As New List (Of On3dPoint)
For i As Int32 = 0 To inContext.Count() - 1
Dim brep As New OnBrep
brep = inContext(i)
Dim faceCount As Int32 = brep.m_F.m_count
For j As Int32 = 0 To faceCount - 1
Dim nSrf As New OnNurbsSurface
nSrf = brep.Face(j).NurbsSurface
Dim mp As New OnMassProperties
nSrf.AreaMassProperties(mp)
Dim pt As New On3dPoint(mp.Centroid)
ptList.Add(pt)
srfList.Add(nSrf)
Next
Next

A = ptList

End Sub
Hi Dirk,

Thanks for getting back to me. I had managed to find a bit of a work around but it involved me doing a lot more manual calculations. I will try this code as soon as I get a free moment.

Thanks again
Hi Axiom,

OnBreps have a Rotate method as well as a Transform method. If you can get away with using one of the overloads of OnBRep.Rotate() I suggest you follow that route.

In either case, rotation origins are just regular points, and rotation axes are regular vectors. Thus, to set a custom rotation point do something like:

New On3dPoint(x,y,z)

and for custom rotation axes do something like:

New On3dVector(x,y,z)

--
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