Skip to content

Commit a257f59

Browse files
Utility components native
1 parent b3dd289 commit a257f59

26 files changed

Lines changed: 601 additions & 42 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Advanced_Development_Grasshopper/pcamp-gh-plugin/PCampGHPlugin.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<StartProgram>C:\Program Files\Rhino 7\System\Rhino.exe</StartProgram>
4747
<StartArguments>/runscript="_-RunScript (
4848
Set GH = Rhino.GetPlugInObject(""Grasshopper"")
49-
Call GH.OpenDocument(""C:\Users\jlx\Desktop\components.gh"")
49+
Call GH.OpenDocument(""D:\Dropbox\JL\code\PCamp-TutorialFiles\Advanced_Development_Grasshopper\pcamp-gh-plugin\sample-files\pcamp-components.gh"")
5050
)"</StartArguments>
5151
<StartAction>Program</StartAction>
5252
</PropertyGroup>

Advanced_Development_Grasshopper/pcamp-gh-plugin/Properties/Resources.Designer.cs

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Advanced_Development_Grasshopper/pcamp-gh-plugin/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@
121121
<data name="pc" type="System.Resources.ResXFileRef, System.Windows.Forms">
122122
<value>..\Resources\pc.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
123123
</data>
124+
<data name="pc_inv" type="System.Resources.ResXFileRef, System.Windows.Forms">
125+
<value>..\resources\pc-inv.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
126+
</data>
124127
<data name="plus_sign" type="System.Resources.ResXFileRef, System.Windows.Forms">
125128
<value>..\Resources\plus-sign.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
126129
</data>
2.14 KB
Loading
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
using Grasshopper.Kernel;
5+
using Rhino.Geometry;
6+
7+
namespace PCampGHPlugin.UtilityComps
8+
{
9+
public class AbsoluteComponent : GH_Component
10+
{
11+
/// <summary>
12+
/// Initializes a new instance of the AddNumbersComponent class.
13+
/// </summary>
14+
public AbsoluteComponent()
15+
: base("Abs", "Abs",
16+
"",
17+
"PCamp", "Utilities")
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("NumberA", "A", "", GH_ParamAccess.item, 0);
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("Result", "R", "", GH_ParamAccess.item);
35+
}
36+
37+
/// <summary>
38+
/// This is the method that actually does the work.
39+
/// </summary>
40+
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
41+
protected override void SolveInstance(IGH_DataAccess DA)
42+
{
43+
double a = 0;
44+
45+
if (!DA.GetData(0, ref a)) return;
46+
47+
double result = Math.Abs(a);
48+
49+
DA.SetData(0, result);
50+
}
51+
52+
public override GH_Exposure Exposure => GH_Exposure.primary;
53+
54+
/// <summary>
55+
/// Provides an Icon for the component.
56+
/// </summary>
57+
protected override System.Drawing.Bitmap Icon => Properties.Resources.pc_inv;
58+
59+
/// <summary>
60+
/// Gets the unique ID for this component. Do not change this ID after release.
61+
/// </summary>
62+
public override Guid ComponentGuid
63+
{
64+
get { return new Guid("98B7C9CD-0BFB-4EB3-8FE1-440620B1F889"); }
65+
}
66+
}
67+
}

Advanced_Development_Grasshopper/pcamp-gh-plugin/UtilityComps/AddNumbersComponent.cs renamed to Advanced_Development_Grasshopper/pcamp-gh-plugin/UtilityComps/AdditionComponent.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ namespace PCampGHPlugin
2929
//
3030

3131

32-
public class AddNumbersComponent : GH_Component
32+
public class AdditionComponent : GH_Component
3333
{
3434
/// <summary>
3535
/// Initializes a new instance of the AddNumbersComponent class.
3636
/// </summary>
37-
public AddNumbersComponent()
38-
: base("Add Numbers", "AddNums",
37+
public AdditionComponent()
38+
: base("Addition", "Addition",
3939
"Adds two numbers together",
4040
"PCamp", "Utilities")
4141
{
@@ -84,7 +84,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
8484
/// <summary>
8585
/// Provides an Icon for the component.
8686
/// </summary>
87-
protected override System.Drawing.Bitmap Icon => Properties.Resources.plus_sign;
87+
protected override System.Drawing.Bitmap Icon => Properties.Resources.pc_inv;
8888

8989

9090
/// <summary>

0 commit comments

Comments
 (0)