-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRPHCommand.cs
74 lines (65 loc) · 2.4 KB
/
RPHCommand.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
67
68
69
70
71
72
73
74
using Rhino;
using Rhino.Commands;
using Rhino.Geometry;
using Rhino.Input;
using Rhino.Input.Custom;
using System;
using System.Collections.Generic;
namespace RPH
{
public class RPHCommand : Command
{
public RPHCommand()
{
// Rhino only creates one instance of each command class defined in a
// plug-in, so it is safe to store a refence in a static property.
Instance = this;
}
///<summary>The only instance of this command.</summary>
public static RPHCommand Instance
{
get; private set;
}
///<returns>The command name as it appears on the Rhino command line.</returns>
public override string EnglishName
{
get { return "RPHCommand"; }
}
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
// TODO: start here modifying the behaviour of your command.
// ---
RhinoApp.WriteLine("The {0} command will add a line right now.", EnglishName);
Point3d pt0;
using (GetPoint getPointAction = new GetPoint())
{
getPointAction.SetCommandPrompt("Please select the start point");
if (getPointAction.Get() != GetResult.Point)
{
RhinoApp.WriteLine("No start point was selected.");
return getPointAction.CommandResult();
}
pt0 = getPointAction.Point();
}
Point3d pt1;
using (GetPoint getPointAction = new GetPoint())
{
getPointAction.SetCommandPrompt("Please select the end point");
getPointAction.SetBasePoint(pt0, true);
getPointAction.DynamicDraw +=
(sender, e) => e.Display.DrawLine(pt0, e.CurrentPoint, System.Drawing.Color.DarkRed);
if (getPointAction.Get() != GetResult.Point)
{
RhinoApp.WriteLine("No end point was selected.");
return getPointAction.CommandResult();
}
pt1 = getPointAction.Point();
}
doc.Objects.AddLine(pt0, pt1);
doc.Views.Redraw();
RhinoApp.WriteLine("The {0} command added one line to the document.", EnglishName);
// ---
return Result.Success;
}
}
}