NurbsCurve.TryGetEllipse(out ellipse, tolerance) or IsEllipse returns false on Rhino Ellipses


#1

Hello,

I’m reading 3DM files using RhinoIO.NET. Using samples files that have NurbsCurves that Rhino recognizes as ellipses (Properties->Details: Valid curve. Ellipse). I try to detect them but IsEllipse and TryGetEllipse return false even with a low tolerance like .001. Anything else I could try?

Thanks,

Alex

I’ve read this topic in the wiki.


(Dale Fugier) #2

Hi Alex,

Can you post the 3dm file with the “ellipse?”


#3

Hello Dale.

Sure. See attached a simple ellipse created in RhinoV5.RhinoV5Ellipse.3dm (14.8 KB)

Alex


#4

The code looks like something like this and works great for Arcs:

if (curve is NurbsCurve)
{
NurbsCurve nurbsCurve = (NurbsCurve)curve;

if (nurbsCurve.IsPlanar(Tolerance))
{
Arc arc;
if (nurbsCurve.TryGetArc(out arc, Tolerance))
{
return arc.ToMyArc();
}

Ellipse ellipse;
if (nurbsCurve.TryGetEllipse(out ellipse, Tolerance))
{
MessageBox.Show("Found an Ellipse!");
return ellipse.ToMyEllipse();
}
}
}

(Dale Fugier) #5

Hi Alex,

Your file works with this sample.

https://github.com/dalefugier/SampleCsCommands/blob/master/SampleCsClassifyCurve.cs

What tolerance value are you passing (and why)?


#6

Hello Dale,

Thanks for the code. I’ve quickly inserted the IsEllipse method and I get the same result. Let me cook a little command line example.

I ended up trying to input a tolerance, when nothing else was working.

brb with the little project.

Alex


#7

Hello Dale,

Please see attached console app. It’s a stripped version of rhinocommon-master\examples\opennurbs_build\cs\example_read

ReadEllipseNET.zip (1.9 MB)

Thanks for looking into this.

Alex


(Dale Fugier) #8

Ok, I see what’s going on. ON_NurbsCurve::IsEllipse() is not implemented in the openNURBS toolkit.

Here are some other things that are not implemented.

http://wiki.mcneel.com/developer/opennurbs/limitations

Sorry for the confusion.


#9

No problem. It’s good to know I’m not imagining things.

I actually saw that wiki article, but since IsArc, IsPlanar, IsPolyline were all working it never occurred to me that IsEllipse was not implemented. It’s OK I have other means to recognize the ellipse.

BTW the OpenNURBS toolkit is amazing. It is very intuitive and with minimal help I find everything I need.

Thanks.

Alex


#10

Alex,

This thread is great! I have exactly the same issue? However, I don’t have any other tricks up my sleeve to recognize Ellipses and aside from converting them ToNurbsCurve() I haven’t figured out a way to recreate those. Ideas?

Dale,

Will this functionality ever be implemented in Open Nurbs? Can you help with filtering out Ellipses? Any other way to recognize it than IsEllipse ?

Thank you!


(Dale Fugier) #11

Keeping in mind that the purpose of openNURBS is to read and write Rhino’s 3DM file format, and that ON_NurbsCurve::IsEllipse is not required for this, I’ll go out on a limb and say no, I don’t see this ever being added to the toolkit. But who knows…

Why do you need this function?

Not that I know of.


#12

Dale,

Thanks for a quick response. I thought that you will say that so i went ahead and basically converted Ellipses to Nurbs Curve using ToNurbsCurve() and then went on to break it down to Control Points, weight, knots and degree so that i can recreate it in other software. I am writing a importer for 3dm files into Dynamo(Revit) that is using Design Script. It would be great to be able to simply create Ellipses from Radii and Plane, but since I dont have access to that information through Open Nurbs then i guess i will have to live with it :frowning:

Thanks again,

-K


(Dale Fugier) #13

openNURBS does not have an ellipse curve. So there is no reason to convert an ellipse to NURBS curve, as it already is one.

Here is sample Rhino command that classifies curves. This might be helpful to you in your conversion efforts. Just keep in mind the the ellipse test will not work with just openNURBS.

https://github.com/mcneel/Rhino5Samples_CPP/blob/master/SampleCommands/cmdSampleClassifyCurve.cpp


#14

Hi ksobon,

We developed our own sorting algorithm to create more specific entities from generic NurbsCurve entities. Similar to Dale’s proposed SampleClassifyCurve command it analyses various curve properties and generates the specific Arc, Ellipse, etc. entity when appropriate. We use it with other generic formats (IGS and STEP) because sometime source software output generic NurbsCurve.

Good luck with your development.

Alex