-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakeBlocksComponent.cs
More file actions
92 lines (75 loc) · 2.75 KB
/
Copy pathMakeBlocksComponent.cs
File metadata and controls
92 lines (75 loc) · 2.75 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using System.Collections.Generic;
using System.Drawing;
using Grasshopper.Kernel;
using MinenifyMe.Properties;
using Rhino.Geometry;
namespace MinenifyMe
{
public class MakeBlocksComponent : GH_Component
{
/// <summary>
/// Initializes a new instance of the MakeBlocksComponent class.
/// </summary>
public MakeBlocksComponent()
: base("MakeBlocks", "McB",
"Make block for rendering in rhino",
"MinenifyMe", "Rendering")
{
}
/// <summary>
/// Registers all the input parameters for this component.
/// </summary>
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.Register_PointParam("Points", "P", "Point", GH_ParamAccess.list);
}
/// <summary>
/// Registers all the output parameters for this component.
/// </summary>
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.Register_BRepParam("Brep", "B", "Brep", GH_ParamAccess.list);
}
/// <summary>
/// This is the method that actually does the work.
/// </summary>
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
protected override void SolveInstance(IGH_DataAccess DA)
{
//Inital definitions
List<Point3d> points = new List<Point3d>();
Brep brep = new Brep();
List<Brep> breps = new List<Brep>();
//retrive info from gh
if (!DA.GetDataList(0, points)) return;
//Create a block with a centroid of the input points
foreach (Point3d point in points)
{
brep = Brep.CreateFromBox(new BoundingBox(point, point + new Vector3d(1, 1, 1)));
//DA.SetData(0, brep);
breps.Add(brep);
}
DA.SetDataList(0, breps);
}
/// <summary>
/// Provides an Icon for the component.
/// </summary>
protected override System.Drawing.Bitmap Icon
{
get
{
//You can add image files to your project resources and access them like this:
return new Bitmap(Resources.previewBlocks, new Size(24, 24));
//return null;
}
}
/// <summary>
/// Gets the unique ID for this component. Do not change this ID after release.
/// </summary>
public override Guid ComponentGuid
{
get { return new Guid("B0A1C7D4-ADF5-4A98-9BA9-40388B5463EF"); }
}
}
}