-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSampleCsCurveGetter.cs
66 lines (60 loc) · 1.99 KB
/
SampleCsCurveGetter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using Rhino;
using Rhino.Commands;
namespace SampleCsCommands
{
[System.Runtime.InteropServices.Guid("5c16e399-76ea-4361-824f-aa049e0211fc")]
public class SampleCsCurveGetter : Command
{
public SampleCsCurveGetter()
{
}
public override string EnglishName
{
get { return "SampleCsCurveGetter"; }
}
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
Rhino.Input.Custom.GetObject go = new Rhino.Input.Custom.GetObject();
go.SetCommandPrompt("Select curves");
go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;
go.GetMultiple(1, 0);
if (go.CommandResult() != Result.Success)
return go.CommandResult();
for (int i = 0; i < go.ObjectCount; i++)
{
Rhino.Geometry.Curve curve = go.Object(i).Curve();
if (null == curve)
return Result.Failure;
if (null != curve as Rhino.Geometry.LineCurve)
RhinoApp.WriteLine("Curve {0} is a line.", i);
else if (null != curve as Rhino.Geometry.ArcCurve)
{
if (curve.IsClosed)
RhinoApp.WriteLine("Curve {0} is a circle.", i);
else
RhinoApp.WriteLine("Curve {0} is an arc.", i);
}
else if (null != curve as Rhino.Geometry.PolylineCurve)
RhinoApp.WriteLine("Curve {0} is a polyline.", i);
else if (null != curve as Rhino.Geometry.PolyCurve)
RhinoApp.WriteLine("Curve {0} is a polycurve.", i);
else if (null != curve as Rhino.Geometry.NurbsCurve)
{
if (curve.IsEllipse())
{
if (curve.IsClosed)
RhinoApp.WriteLine("Curve {0} is an ellipse.", i);
else
RhinoApp.WriteLine("Curve {0} is an elliptical arc.", i);
}
else
RhinoApp.WriteLine("Curve {0} is a NURBS curve.", i);
}
else
RhinoApp.WriteLine("Curve {0} is an unknown type.", i);
}
return Result.Success;
}
}
}