[docs]classRhinoPlane(BaseRhinoGeometry):"""Wrapper for a Rhino plane objects. Attributes ---------- point (read-only) : :class:`Rhino.Geometry.Point3d` Base point of the plane. normal (read-only) : :class:`Rhino.Geometry.Vector3d` The normal vector of the plane. xaxis (read-only) : :class:`Rhino.Geometry.Vector3d` The X axis of the plane. yaxis (read-only) : :class:`Rhino.Geometry.Vector3d` The Y axis of the plane. Notes ----- In Rhino, a plane and a frame are equivalent. Therefore, the COMPAS conversion function of this class returns a frame object instead of a plane. """def__init__(self):super(RhinoPlane,self).__init__()@propertydefpoint(self):returnself.geometry.Origin@propertydefnormal(self):returnself.geometry.Normal@propertydefxaxis(self):returnself.geometry.XAxis@propertydefyaxis(self):returnself.geometry.YAxis
[docs]@classmethoddeffrom_geometry(cls,geometry):"""Construct a plane wrapper from an existing geometry object. Parameters ---------- geometry : tuple of point and normal or :class:`Rhino.Geometry.Plane` or :class:`compas.geometry.Plane` or :class:`compas.geometry.Frame` The geometry object defining a plane. Returns ------- :class:`compas_rhino.geometry.RhinoPlane` The wrapped plane. """ifnotisinstance(geometry,Rhino.Geometry.Plane):ifisinstance(geometry,Plane):point=Rhino.Geometry.Point3d(geometry[0][0],geometry[0][1],geometry[0][2])normal=Rhino.Geometry.Vector3d(geometry[1][0],geometry[1][1],geometry[1][2])geometry=Rhino.Geometry.Plane(point,normal)elifisinstance(geometry,Frame):point=Rhino.Geometry.Point3d(geometry[0][0],geometry[0][1],geometry[0][2])xaxis=Rhino.Geometry.Vector3d(geometry[1][0],geometry[1][1],geometry[1][2])yaxis=Rhino.Geometry.Vector3d(geometry[2][0],geometry[2][1],geometry[2][2])geometry=Rhino.Geometry.Plane(point,xaxis,yaxis)else:point=Rhino.Geometry.Point3d(geometry[0][0],geometry[0][1],geometry[0][2])normal=Rhino.Geometry.Vector3d(geometry[1][0],geometry[1][1],geometry[1][2])geometry=Rhino.Geometry.Plane(point,normal)line=cls()line.geometry=geometryreturnline
[docs]defto_compas(self):"""Convert to a COMPAS geometry object. Returns ------- :class:`compas.geometry.Frame` A COMPAS frame object. """returnFrame(self.point,self.xaxis,self.yaxis)