Skip to content

Commit 7fe1a28

Browse files
Vector components native
1 parent a257f59 commit 7fe1a28

17 files changed

Lines changed: 875 additions & 27 deletions

Advanced_Development_Grasshopper/pcamp-gh-plugin/UtilityComps/PConsoleLogger.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,13 @@ protected override void SolveInstance(IGH_DataAccess DA)
5858
DA.SetDataList(0, logs);
5959
}
6060

61+
public override GH_Exposure Exposure => GH_Exposure.quarternary;
62+
63+
6164
/// <summary>
6265
/// Provides an Icon for the component.
6366
/// </summary>
64-
protected override System.Drawing.Bitmap Icon
65-
{
66-
get
67-
{
68-
//You can add image files to your project resources and access them like this:
69-
// return Resources.IconForThisComponent;
70-
return null;
71-
}
72-
}
67+
protected override System.Drawing.Bitmap Icon => Properties.Resources.pc_inv;
7368

7469
/// <summary>
7570
/// Gets the unique ID for this component. Do not change this ID after release.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
using Grasshopper.Kernel;
5+
using Rhino.Geometry;
6+
7+
namespace PCampGHPlugin.VectorComps
8+
{
9+
public class ConstructPointComponent : GH_Component
10+
{
11+
/// <summary>
12+
/// Initializes a new instance of the ConstructVectorComponent class.
13+
/// </summary>
14+
public ConstructPointComponent()
15+
: base("Construct Point", "Construct Point",
16+
"",
17+
"PCamp", "Vector")
18+
{
19+
}
20+
21+
/// <summary>
22+
/// Registers all the input parameters for this component.
23+
/// </summary>
24+
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
25+
{
26+
pManager.AddNumberParameter("X", "X", "X component", GH_ParamAccess.item, 0);
27+
pManager.AddNumberParameter("Y", "Y", "Y component", GH_ParamAccess.item, 0);
28+
pManager.AddNumberParameter("Z", "Z", "Z component", GH_ParamAccess.item, 0);
29+
}
30+
31+
/// <summary>
32+
/// Registers all the output parameters for this component.
33+
/// </summary>
34+
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
35+
{
36+
pManager.AddPointParameter("R", "R", "", GH_ParamAccess.item);
37+
}
38+
39+
/// <summary>
40+
/// This is the method that actually does the work.
41+
/// </summary>
42+
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
43+
protected override void SolveInstance(IGH_DataAccess DA)
44+
{
45+
double x = 0,
46+
y = 0,
47+
z = 0;
48+
49+
DA.GetData(0, ref x);
50+
DA.GetData(1, ref y);
51+
DA.GetData(2, ref z);
52+
53+
Point3d p = new Point3d(x, y, z);
54+
55+
DA.SetData(0, p);
56+
}
57+
58+
public override GH_Exposure Exposure => GH_Exposure.primary;
59+
60+
/// <summary>
61+
/// Provides an Icon for the component.
62+
/// </summary>
63+
protected override System.Drawing.Bitmap Icon => Properties.Resources.pc_inv;
64+
65+
/// <summary>
66+
/// Gets the unique ID for this component. Do not change this ID after release.
67+
/// </summary>
68+
public override Guid ComponentGuid
69+
{
70+
get { return new Guid("8030B90B-D94F-42F0-AA47-1B85ADB972F8"); }
71+
}
72+
}
73+
}

Advanced_Development_Grasshopper/pcamp-gh-plugin/VectorComps/ConstructVectorComponent.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,12 @@ protected override void SolveInstance(IGH_DataAccess DA)
5555
DA.SetData(0, v);
5656
}
5757

58+
public override GH_Exposure Exposure => GH_Exposure.primary;
59+
5860
/// <summary>
5961
/// Provides an Icon for the component.
6062
/// </summary>
61-
protected override System.Drawing.Bitmap Icon
62-
{
63-
get
64-
{
65-
//You can add image files to your project resources and access them like this:
66-
// return Resources.IconForThisComponent;
67-
return null;
68-
}
69-
}
63+
protected override System.Drawing.Bitmap Icon => Properties.Resources.pc_inv;
7064

7165
/// <summary>
7266
/// Gets the unique ID for this component. Do not change this ID after release.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
using Grasshopper.Kernel;
5+
using Rhino.Geometry;
6+
7+
namespace PCampGHPlugin.VectorComps
8+
{
9+
public class CrossProductComponent : GH_Component
10+
{
11+
/// <summary>
12+
/// Initializes a new instance of the VectorLengthComponent class.
13+
/// </summary>
14+
public CrossProductComponent()
15+
: base("CrossProduct", "CrossProduct",
16+
"",
17+
"PCamp", "Vector")
18+
{
19+
}
20+
21+
/// <summary>
22+
/// Registers all the input parameters for this component.
23+
/// </summary>
24+
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
25+
{
26+
pManager.AddVectorParameter("A", "A", "", GH_ParamAccess.item);
27+
pManager.AddVectorParameter("B", "B", "", GH_ParamAccess.item);
28+
pManager.AddBooleanParameter("U", "U", "", GH_ParamAccess.item);
29+
}
30+
31+
/// <summary>
32+
/// Registers all the output parameters for this component.
33+
/// </summary>
34+
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
35+
{
36+
pManager.AddVectorParameter("V", "V", "", GH_ParamAccess.item);
37+
pManager.AddNumberParameter("L", "L", "", GH_ParamAccess.item);
38+
39+
}
40+
41+
/// <summary>
42+
/// This is the method that actually does the work.
43+
/// </summary>
44+
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
45+
protected override void SolveInstance(IGH_DataAccess DA)
46+
{
47+
Vector3d a = Vector3d.Unset;
48+
Vector3d b = Vector3d.Unset;
49+
bool u = false;
50+
51+
DA.GetData(0, ref a);
52+
DA.GetData(1, ref b);
53+
DA.GetData(2, ref u);
54+
55+
Vector3d cross = Vector3d.CrossProduct(a, b);
56+
57+
if (u)
58+
{
59+
cross.Unitize();
60+
}
61+
62+
DA.SetData(0, cross);
63+
DA.SetData(1, cross.Length);
64+
}
65+
66+
public override GH_Exposure Exposure => GH_Exposure.tertiary;
67+
68+
/// <summary>
69+
/// Provides an Icon for the component.
70+
/// </summary>
71+
protected override System.Drawing.Bitmap Icon => Properties.Resources.pc_inv;
72+
73+
/// <summary>
74+
/// Gets the unique ID for this component. Do not change this ID after release.
75+
/// </summary>
76+
public override Guid ComponentGuid
77+
{
78+
get { return new Guid("C9BB261B-79C6-447F-8E49-80873B969853"); }
79+
}
80+
}
81+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
using Grasshopper.Kernel;
5+
using Rhino.Geometry;
6+
7+
namespace PCampGHPlugin.VectorComps
8+
{
9+
public class DeconstructPointComponent : GH_Component
10+
{
11+
/// <summary>
12+
/// Initializes a new instance of the DeconstructPointComponent class.
13+
/// </summary>
14+
public DeconstructPointComponent()
15+
: base("DeconstructPoint", "DeconstructPoint",
16+
"",
17+
"PCamp", "Vector")
18+
{
19+
}
20+
21+
/// <summary>
22+
/// Registers all the input parameters for this component.
23+
/// </summary>
24+
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
25+
{
26+
pManager.AddPointParameter("P", "P", "", GH_ParamAccess.item);
27+
}
28+
29+
/// <summary>
30+
/// Registers all the output parameters for this component.
31+
/// </summary>
32+
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
33+
{
34+
pManager.AddNumberParameter("X", "X", "X component", GH_ParamAccess.item);
35+
pManager.AddNumberParameter("Y", "Y", "Y component", GH_ParamAccess.item);
36+
pManager.AddNumberParameter("Z", "Z", "Z component", GH_ParamAccess.item);
37+
}
38+
39+
/// <summary>
40+
/// This is the method that actually does the work.
41+
/// </summary>
42+
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
43+
protected override void SolveInstance(IGH_DataAccess DA)
44+
{
45+
Point3d p = Point3d.Unset;
46+
47+
DA.GetData(0, ref p);
48+
49+
DA.SetData(0, p.X);
50+
DA.SetData(1, p.Y);
51+
DA.SetData(2, p.Z);
52+
}
53+
54+
public override GH_Exposure Exposure => GH_Exposure.primary;
55+
56+
/// <summary>
57+
/// Provides an Icon for the component.
58+
/// </summary>
59+
protected override System.Drawing.Bitmap Icon => Properties.Resources.pc_inv;
60+
61+
/// <summary>
62+
/// Gets the unique ID for this component. Do not change this ID after release.
63+
/// </summary>
64+
public override Guid ComponentGuid
65+
{
66+
get { return new Guid("FDA5FC8B-A792-4244-9F0C-7E265783F74F"); }
67+
}
68+
}
69+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
using Grasshopper.Kernel;
5+
using Rhino.Geometry;
6+
7+
namespace PCampGHPlugin.VectorComps
8+
{
9+
public class LineComponent : GH_Component
10+
{
11+
/// <summary>
12+
/// Initializes a new instance of the DeconstructPointComponent class.
13+
/// </summary>
14+
public LineComponent()
15+
: base("Line", "Line",
16+
"",
17+
"PCamp", "Vector")
18+
{
19+
}
20+
21+
/// <summary>
22+
/// Registers all the input parameters for this component.
23+
/// </summary>
24+
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
25+
{
26+
pManager.AddPointParameter("A", "A", "", GH_ParamAccess.item);
27+
pManager.AddPointParameter("B", "B", "", GH_ParamAccess.item);
28+
}
29+
30+
/// <summary>
31+
/// Registers all the output parameters for this component.
32+
/// </summary>
33+
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
34+
{
35+
pManager.AddLineParameter("L", "L", "", GH_ParamAccess.item);
36+
}
37+
38+
/// <summary>
39+
/// This is the method that actually does the work.
40+
/// </summary>
41+
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
42+
protected override void SolveInstance(IGH_DataAccess DA)
43+
{
44+
Point3d p0 = Point3d.Unset;
45+
Point3d p1 = Point3d.Unset;
46+
47+
DA.GetData(0, ref p0);
48+
DA.GetData(1, ref p1);
49+
50+
Line line = new Line(p0, p1);
51+
52+
DA.SetData(0, line);
53+
}
54+
55+
public override GH_Exposure Exposure => GH_Exposure.primary;
56+
57+
/// <summary>
58+
/// Provides an Icon for the component.
59+
/// </summary>
60+
protected override System.Drawing.Bitmap Icon => Properties.Resources.pc_inv;
61+
62+
/// <summary>
63+
/// Gets the unique ID for this component. Do not change this ID after release.
64+
/// </summary>
65+
public override Guid ComponentGuid
66+
{
67+
get { return new Guid("963930DD-C871-41A6-B306-DAE3116E6232"); }
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)