C# About ObjectTable Class

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…


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

What do you want to achieve?

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

Here are examples of adding objects to the document:

Here some with translating objects:

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

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?

You can use Geometry.ObjectType to figure out what type your object is, then cast.

Probably shorter is even:

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

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.:sweat_smile:

There is no any warning but it’s still can’t convert to a circle.:rofl:

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:

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));
  RhinoApp.WriteLine("Curve is not circular");

return Result.Success;

Thank you Menno. it’s completely helped !