# How to set a gumball from a brep?

Hi, I want get a brep’s gumball,but I can’t find it in sdk

``````    Public Function SetFromArc(ByVal arc As Arc) As Boolean
Public Function SetFromBoundingBox(ByVal boundingBox As BoundingBox) As Boolean
Public Function SetFromBoundingBox(ByVal frame As Plane, ByVal frameBoundingBox As BoundingBox) As Boolean
Public Function SetFromCircle(ByVal circle As Circle) As Boolean
Public Function SetFromCurve(ByVal curve As Curve) As Boolean
Public Function SetFromEllipse(ByVal ellipse As Ellipse) As Boolean
Public Function SetFromExtrusion(ByVal extrusion As Extrusion) As Boolean
Public Function SetFromHatch(ByVal hatch As Hatch) As Boolean
Public Function SetFromLight(ByVal light As Light) As Boolean
Public Function SetFromLine(ByVal line As Line) As Boolean
Public Function SetFromPlane(ByVal plane As Plane) As Boolean
``````

@dale
@DavidRutten
I use net in gh. I am writing a gha need to do this.

@stevebaer
Trouble Stevebaer to see this problem.

@DavidRutten has a bit more experience with this than me. The gumball access in the SDK could use some tuning up.

The gumball should be oriented to some plane. So determine a plane on one of the faces of the Brep, and then pass that plane to SetFromPlane().

I have asked him. he can’t give any solution either

Hi Dale,Thank you first.
Can you say more detail ? or Post some net code.
I don’t understand “Determine a plane on one of the faces of the Brep”, if the face is not a planar surface How can I get a plane from it?
And you see "Public Function SetFromPlane(ByVal plane As Plane) As Boolean"
SetFromPlane just need One Plane,but a brep may be many faces–

Gumball is a transformation widget. And the basis for many transformation is a base plane (e.g. starting location). So the Gumball wants to be oriented to some plane.

A Brep does not necessarily have an obvious plane on which to orient on. So, it might not be easy to come up with a single “SetFromBrep” function that always set it to where you want.

But if you need some example, then perhaps you can use this as a starting place.

``````Public Shared Function SetFromBrepFace(ByRef gbl As GumballObject, ByVal face As BrepFace) As Boolean
Dim result As Boolean = False
If (gb IsNot Nothing AndAlso face IsNot Nothing) Then
Dim u As Double = face.Domain(0).Mid
Dim v As Double = face.Domain(1).Mid
Dim frame As New Plane()
result = face.FrameAt(u, v, frame)
If (result = True) Then
result = gbl.SetFromPlane(frame)
End If
End If
Return result
End Function
``````
1 Like

Just get the Frameat(u.mid,v.mid)? I don’t belive the gumball will use in rhino is so easy–
Not say the gumball, I want to know, Is there a OCS coodinate system in a geometrybase?
I need it,when the geometrybase being trimed or split,the OCS plane do not change.
@dale are you there? I really hate the time difference-- It’s midnight now here

This is just an example. As it is your tool, feel free to come up with whatever method works best for you.

No, Rhino does not maintain an object coordinate system, or OCS. Ironically, this is something we are considering for Rhino 6 for this very reason.

1 Like

OK,I see.
I am a fans of your rhino develop team. I believe,rhino6 will be more Powerful.
Thank you again dear dale–

Hi @dale, is there yet a RhinoCommon method in V6 which allows to get the plane which is used when the CPlane is set to “Object” ? (note, i am aware of the V7 method to get the gumball frame).

_
c.

Hi @clement,

No there is not. `CPlane -> Object` special cases a number of different object types. Is there a particular object type you are interested in know how the CPlane command works?

– Dale

Thanks @dale, i did not have a particular object type in mind. Maybe it would make sense to expose the CPlane’s code as a method in RhinoCommon, eg. like `Plane.TryGetFromGeometry(geo)` ?

_
c.