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.
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
Permalink Reply by Axiom on December 16, 2009 at 10:09am
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.
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: