# C# About ObjectTable Class

**URL:** <https://discourse.mcneel.com/t/c-about-objecttable-class/92769>\
**Category:** Scripting\
**Tags:** rhinocommon, grasshopper\
**Created:** [November 26, 2019, 9:09am UTC](https://discourse.mcneel.com/t/c-about-objecttable-class/92769 "2019-11-26T09:09:44Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![hk11](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/hk11/32/652249_2.png) [@hk11](https://discourse.mcneel.com/u/hk11)\
**Post date:** [November 26, 2019, 9:09am UTC](https://discourse.mcneel.com/t/c-about-objecttable-class/92769/1 "2019-11-26T09:09:44Z")

</div>

I have a question about ObjectTable class. When I want to use a method of ObjectTable Class. I can’t new a ObjectTable like below. How I can do?Please help…

---

<div class="post-metadata">

**Author:** ![hk11](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/hk11/32/652249_2.png) [@hk11](https://discourse.mcneel.com/u/hk11)\
**Post date:** [November 26, 2019, 9:10am UTC](https://discourse.mcneel.com/t/c-about-objecttable-class/92769/2 "2019-11-26T09:10:27Z")

</div>

![%E6%8D%95%E8%8E%B7](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/a/e/ae57c1a41f6d0d15b2f67300b9b610057a7aa1be.png)

---

<div class="post-metadata">

**Author:** ![menno](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/menno/32/770384_2.png) [@menno](https://discourse.mcneel.com/u/menno)\
**Post date:** [November 26, 2019, 10:59am UTC](https://discourse.mcneel.com/t/c-about-objecttable-class/92769/3 "2019-11-26T10:59:52Z")

</div>

`ObjectTable` is part of the document, you cannot create a new table.

What do you want to achieve?

---

<div class="post-metadata">

**Author:** ![hk11](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/hk11/32/652249_2.png) [@hk11](https://discourse.mcneel.com/u/hk11)\
**Post date:** [November 29, 2019, 1:04am UTC](https://discourse.mcneel.com/t/c-about-objecttable-class/92769/4 "2019-11-29T01:04:47Z")

</div>

Thank you Menno, I want to translate a circle from geometry obj.Have any ideas? Where I can found some information about objs things translate from geometry objs?Thanks for your help! Happy thanksgiving

---

<div class="post-metadata">

**Author:** ![nathanletwory](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nathanletwory/32/482880_2.png) [@nathanletwory](https://discourse.mcneel.com/u/nathanletwory)\
**Post date:** [November 29, 2019, 4:59am UTC](https://discourse.mcneel.com/t/c-about-objecttable-class/92769/5 "2019-11-29T04:59:46Z")

</div>

Here are examples of adding objects to the document:

> **[mcneel/rhino-developer-samples](https://github.com/mcneel/rhino-developer-samples/search?l=C%23&q=Objects.Add)**
>
> Rhino and Grasshopper developer sample code. Contribute to mcneel/rhino-developer-samples development by creating an account on GitHub.

Here some with translating objects:

> **[mcneel/rhino-developer-samples](https://github.com/mcneel/rhino-developer-samples/search?l=C%23&q=Translate)**
>
> Rhino and Grasshopper developer sample code. Contribute to mcneel/rhino-developer-samples development by creating an account on GitHub.

For the last one especially the array-by-distance.cs sample.

---

<div class="post-metadata">

**Author:** ![hk11](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/hk11/32/652249_2.png) [@hk11](https://discourse.mcneel.com/u/hk11)\
**Post date:** [November 29, 2019, 6:12am UTC](https://discourse.mcneel.com/t/c-about-objecttable-class/92769/6 "2019-11-29T06:12:34Z")

</div>

Thank you Nathan!

I have a question that I’m using a GeometryBase to get a real circle. In the c# program, it’s GeometryBase OBJ,how I can convert it to a circle?

---

<div class="post-metadata">

**Author:** ![nathanletwory](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nathanletwory/32/482880_2.png) [@nathanletwory](https://discourse.mcneel.com/u/nathanletwory)\
**Post date:** [November 29, 2019, 7:07am UTC](https://discourse.mcneel.com/t/c-about-objecttable-class/92769/7 "2019-11-29T07:07:19Z")

</div>

You can use [`Geometry.ObjectType`](https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_Geometry_GeometryBase_ObjectType.htm) to figure out what type your object is, then cast.

Probably shorter is even:

```auto
if(someob is Rhino.Geometry.Curve crv) { /* .. your code here .. */ }

```

---

<div class="post-metadata">

**Author:** ![hk11](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/hk11/32/652249_2.png) [@hk11](https://discourse.mcneel.com/u/hk11)\
**Post date:** [November 29, 2019, 8:21am UTC](https://discourse.mcneel.com/t/c-about-objecttable-class/92769/8 "2019-11-29T08:21:55Z")

</div>

Hi Nathan, I know how to figure out the tyep of my objcet is but I don’t know how to convert it from geometry to circle.😅

---

<div class="post-metadata">

**Author:** ![hk11](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/hk11/32/652249_2.png) [@hk11](https://discourse.mcneel.com/u/hk11)\
**Post date:** [November 29, 2019, 9:12am UTC](https://discourse.mcneel.com/t/c-about-objecttable-class/92769/9 "2019-11-29T09:12:54Z")

</div>

![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/1/6/166a1a8f75d55180b4b5e7c121ce973bc8e1804b.png)  
There is no any warning but it’s still can’t convert to a circle.🤣

---

<div class="post-metadata">

**Author:** ![menno](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/menno/32/770384_2.png) [@menno](https://discourse.mcneel.com/u/menno)\
**Post date:** [November 29, 2019, 11:08am UTC](https://discourse.mcneel.com/t/c-about-objecttable-class/92769/10 "2019-11-29T11:08:52Z")

</div>

There is a difference between the geometry that inherits from `GeometryBase` (classes like `ArcCurve, Curve, NurbsCurve` etc.) and the simple structs, like `Arc, Circle, Line` etc. You will never get these structs from an object that inherits from `GeometryBase` using a cast or `Convert.ChangeType` operation.

If you want to obtain a `Circle` from a `Curve`, use the following:

```auto
var res = RhinoGet.GetOneObject("Circle", false, ObjectType.Curve, out ObjRef cRef);
if (res != Result.Success)
  return res;

Curve curve = cRef.Curve();
if (curve.TryGetCircle(out Circle circle, doc.ModelAbsoluteTolerance))
{
  // now you have a Circle
  for (int i = 1; i < 10; ++i)
  {
    circle.Center.Transform(Transform.Translation(i, 0, 0));
    doc.Objects.AddCircle(circle);
  }
}
else
{
  RhinoApp.WriteLine("Curve is not circular");
}

return Result.Success;

```

```auto

```

---

<div class="post-metadata">

**Author:** ![hk11](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/hk11/32/652249_2.png) [@hk11](https://discourse.mcneel.com/u/hk11)\
**Post date:** [November 30, 2019, 3:53am UTC](https://discourse.mcneel.com/t/c-about-objecttable-class/92769/11 "2019-11-30T03:53:46Z")

</div>

Thank you Menno. it’s completely helped !
