-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSampleCsSmash.cs
54 lines (45 loc) · 1.64 KB
/
SampleCsSmash.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
using System;
using Rhino;
using Rhino.Commands;
namespace SampleCsCommands
{
[System.Runtime.InteropServices.Guid("397f98ec-e57c-4649-bee4-afe99aa61b68")]
public class SampleCsSmash : Command
{
public SampleCsSmash()
{
}
public override string EnglishName
{
get { return "SampleCsSmash"; }
}
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
Rhino.Input.Custom.GetObject go = new Rhino.Input.Custom.GetObject();
go.SetCommandPrompt("Select surface or polysurface to smash");
go.GeometryFilter = Rhino.DocObjects.ObjectType.Surface | Rhino.DocObjects.ObjectType.PolysrfFilter;
go.Get();
if (go.CommandResult() != Rhino.Commands.Result.Success)
return go.CommandResult();
Rhino.Geometry.Brep brep = go.Object(0).Brep();
if (null == brep)
return Rhino.Commands.Result.Failure;
Rhino.Geometry.Unroller unroller = new Rhino.Geometry.Unroller(brep);
unroller.AbsoluteTolerance = doc.ModelAbsoluteTolerance;
unroller.RelativeTolerance = 1.0; // big relative tolerance for smash
unroller.ExplodeSpacing = 2.0;
unroller.ExplodeOutput = true;
Rhino.Geometry.Curve[] unrolledCurves = null;
Rhino.Geometry.Point3d[] unrolledPoints = null;
Rhino.Geometry.TextDot[] unrolledDots = null;
Rhino.Geometry.Brep[] output = unroller.PerformUnroll(out unrolledCurves, out unrolledPoints, out unrolledDots);
if (null != output)
{
for (int i = 0; i < output.Length; i++)
doc.Objects.Add(output[i]);
}
doc.Views.Redraw();
return Rhino.Commands.Result.Success;
}
}
}