# How to convert Rhino.Geometry into RhinoObject?

**URL:** <https://discourse.mcneel.com/t/how-to-convert-rhino-geometry-into-rhinoobject/145334>\
**Category:** Scripting\
**Tags:** windows, rhinocommon\
**Created:** [July 15, 2022, 12:06pm UTC](https://discourse.mcneel.com/t/how-to-convert-rhino-geometry-into-rhinoobject/145334 "2022-07-15T12:06:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manuel3](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/manuel3/32/390166_2.png) [@Manuel3](https://discourse.mcneel.com/u/Manuel3)\
**Post date:** [July 15, 2022, 12:06pm UTC](https://discourse.mcneel.com/t/how-to-convert-rhino-geometry-into-rhinoobject/145334/1 "2022-07-15T12:06:07Z")

</div>

Hello all,  
this might be a very basic question for everyone having more C# experience then I, but so far I havent found any tutorial explaining this:  
How can I convert for example a Rhino.Geometry.Brep into an Rhino.DocObjects.ObjRef ?  
I need the ObjRef or RhinoObject (?) for the delete function: ObjectTable.Delete Method (RhinoObject, Boolean)

Thanks!

---

<div class="post-metadata">

**Author:** ![flokart](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/flokart/32/765122_2.png) [@flokart](https://discourse.mcneel.com/u/flokart)\
**Post date:** [July 15, 2022, 9:22pm UTC](https://discourse.mcneel.com/t/how-to-convert-rhino-geometry-into-rhinoobject/145334/2 "2022-07-15T21:22:41Z")

</div>

You need to find the object by finding or iterating over all objects and check if the id is the one from your geometry then you can delete it.

---

<div class="post-metadata">

**Author:** ![Manuel3](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/manuel3/32/390166_2.png) [@Manuel3](https://discourse.mcneel.com/u/Manuel3)\
**Post date:** [July 16, 2022, 2:31pm UTC](https://discourse.mcneel.com/t/how-to-convert-rhino-geometry-into-rhinoobject/145334/3 "2022-07-16T14:31:41Z")

</div>

well, to work with ids, I need to have a RhinoObject at the begining, right?. But the problem was how do i get from a Rhino.Geometry to a RhinoObject.

The only way I ever got an Rhino.Geometry into a RhinoObject was by FindByLayer() but i need a specific Object not the whole Layer. So I tried it with the FindByUserString(), but it doesnt seem to put any “findings” into my RhinoObject “srf”.

cube.brep.SetUserString(“delete”, “1”);  
Rhino.DocObjects.RhinoObject srf;  
srf = Rhino.RhinoDoc.ActiveDoc.Objects.FindByUserString(“delete”,“1”,true,true,true,Rhino.DocObjects.ObjectType.AnyObject);

---

<div class="post-metadata">

**Author:** ![flokart](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/flokart/32/765122_2.png) [@flokart](https://discourse.mcneel.com/u/flokart)\
**Post date:** [July 17, 2022, 8:16am UTC](https://discourse.mcneel.com/t/how-to-convert-rhino-geometry-into-rhinoobject/145334/4 "2022-07-17T08:16:56Z")

</div>

you could compare the boundingbox of the object geometry and the geometry to get the object.

```python
import Rhino as rh
import scriptcontext as sc

l1 = rh.Geometry.Line(1,2,3,4,5,6)
sc.doc.Objects.AddLine(l1)

for i in rh.RhinoDoc.ActiveDoc.Objects:
    if i.Geometry.GetBoundingBox(i).Equals(rh.Geometry.Line(1,2,3,4,5,6).BoundingBox):
        sc.doc.Objects.Purge(i)

```
