forked from mdjcad/SampleCsCommands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSampleCsPointCloudPoints.cs
72 lines (61 loc) · 1.86 KB
/
SampleCsPointCloudPoints.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
using System;
using Rhino;
using Rhino.Commands;
using Rhino.DocObjects;
using Rhino.Geometry;
using Rhino.Input.Custom;
namespace SampleCsCommands
{
[System.Runtime.InteropServices.Guid("343b9569-48bf-49ec-97e9-da3f20ad16e0")]
public class SampleCsPointCloudPoints : Command
{
public SampleCsPointCloudPoints()
{
}
public override string EnglishName
{
get { return "SampleCsPointCloudPoints"; }
}
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var go = new GetObject();
go.SetCommandPrompt("Select point cloud");
go.GeometryFilter = ObjectType.PointSet;
go.Get();
if (go.CommandResult() != Result.Success)
return go.CommandResult();
var point_cloud_object = go.Object(0).Object() as PointCloudObject;
if (null == point_cloud_object)
return Result.Failure;
var gp = new GetPointCloudPoints(point_cloud_object.Id);
gp.SetCommandPrompt("Select point cloud points");
gp.GetMultiple(1, 0);
if (gp.CommandResult() != Result.Success)
return gp.CommandResult();
foreach (var objref in gp.Objects())
{
var ci = objref.GeometryComponentIndex;
var pt = point_cloud_object.PointCloudGeometry[ci.Index].Location;
RhinoApp.WriteLine(string.Format("Index {0}: {1}", ci.Index, pt.ToString()));
}
return Result.Success;
}
}
/// <summary>
/// GetPointCloudPoints
/// </summary>
class GetPointCloudPoints : GetObject
{
private readonly Guid m_object_id;
public GetPointCloudPoints(Guid objectId)
{
m_object_id = objectId;
GeometryFilter = ObjectType.Point;
SubObjectSelect = true;
}
public override bool CustomGeometryFilter(RhinoObject obj, GeometryBase geom, ComponentIndex ci)
{
return (null != obj && obj.Id.Equals(m_object_id));
}
}
}