Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GH2 template #20

Merged
merged 4 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"$schema": "http://json.schemastore.org/dotnetcli.host",
"symbolInfo": {
"IncludeSample": {
"longName": "include-sample",
"shortName": "sample"
},
"RhinoVersion": {
"longName": "version",
"shortName": "v"
},
"PlugInDisplayName": {
"longName": "plugin-display-name",
"shortName": "plugin-name"
},
"ComponentClassName": {
"longName": "component-class",
"shortName": "component"
},
"ComponentName": {
"longName": "component-name",
"shortName": "cname"
},
"ComponentInfo": {
"shortName": "info"
},
"ComponentChapter": {
"longName": "chapter",
"shortName": "ch"
},
"ComponentSection": {
"longName": "section",
"shortName": "sec"
},
"UseWpf": {
"longName": "include-wpf",
"shortName": "wpf"
},
"UseWinForms": {
"longName": "include-winforms",
"shortName": "wf"
},
"BuildYak": {
"longName": "build-yak",
"shortName": "yak"
},
"IncludeVSCode": {
"longName": "include-vscode-launch",
"shortName": "vscode"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "http://json.schemastore.org/vs-2017.3.host",
"unsupportedHosts": [
{
"id": "vs"
}
]
}
159 changes: 159 additions & 0 deletions Rhino.Templates/content/CSGrasshopper2/.template.config/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "McNeel",
"classifications": [
"Rhino",
"Grasshopper2",
"GH2"
],
"name": "Grasshopper2 PlugIn (WIP)",
"description": "Build Grasshopper2 components for Rhino 3D in C#",
"identity": "Grasshopper2.Component.CS",
"groupIdentity": "Grasshopper2.PlugIn",
"precedence": 100,
"defaultName": "MyGrasshopper2Components",
"shortName": "gh2",
"tags": {
"language": "C#",
"type": "project"
},
"sourceName": "MyGrasshopper.1",
"preferNameDirectory": true,
"symbols": {
"IncludeSample": {
"type": "parameter",
"description": "Include code sample.",
"dataType": "bool",
"defaultValue": "false"
},
"RhinoVersion": {
"type": "parameter",
"description": "Version of Rhino",
"datatype": "choice",
"defaultValue": "8",
"choices": [
{
"choice": "8",
"description": "Version 8"
}
Comment on lines +34 to +38
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May make sense to include 9 WIP

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think I should add that to all of the templates, or just the GH2 template?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I might add 9 WIP at some later date to all of the templates.

]
},
"BuildYak": {
"type": "parameter",
"description": "Include target to build yak package(s) for your plugin",
"datatype": "bool",
"defaultValue": "false"
},
"IncludeVSCode": {
"type": "parameter",
"description": "Include tasks.json and launch.json to build/debug in VS Code",
"datatype": "bool",
"defaultValue": "true"
},
"PlugInDisplayName": {
"type": "parameter",
"description": "Display name of your Grasshopper2 plug-in",
"datatype": "text",
"replaces": "MyGrasshopper.1 Info"
},
"ComponentClassName": {
"type": "parameter",
"description": "Name of the component class",
"datatype": "text",
"replaces": "MyGrasshopper__1Component",
"fileRename": "MyGrasshopper__1Component"
},
"ComponentName": {
"type": "parameter",
"description": "Display name of the component",
"datatype": "text",
"replaces": "MyGrasshopper.1 Component"
},
"ComponentInfo": {
"type": "parameter",
"description": "Description of the component",
"replaces": "ComponentInfo",
"defaultValue": "Description of component"
},
"ComponentChapter": {
"type": "parameter",
"description": "Chapter of the component",
"replaces": "ComponentChapter",
"defaultValue": "Chapter"
},
"ComponentSection": {
"type": "parameter",
"description": "Section of the component",
"replaces": "ComponentSection",
"defaultValue": "Section"
},

"UseWpf": {
"type": "parameter",
"description": "Enable to use WPF (Windows only)",
"datatype": "bool",
"defaultValue": "false"
},
"UseWinForms": {
"type": "parameter",
"description": "Enable the use of Windows Forms",
"datatype": "bool",
"defaultValue": "false"
},
"UseWindowsDesktop": {
"type": "computed",
"value": "UseWpf || UseWinForms"
},

"HostIdentifier": {
"type": "bind",
"binding": "HostIdentifier"
}
},
"forms": {
"JsonStringEncode": {
"identifier": "replace",
"pattern": "\\\\",
"replacement": "\\\\"
}
},
"sources": [
{
"modifiers": [
{
"condition": "!IncludeVSCode",
"exclude": [ ".vscode/*.*" ]
},
{
"condition": "ComponentClassName == 'MyGrasshopper__1Component'",
"rename": {
"MyGrasshopper__1Component.cs": "MyGrasshopper.1Component.cs",
"MyGrasshopper__1Component.3dm": "MyGrasshopper.1Component.3dm",
"MyGrasshopper__1Component.ghicon": "MyGrasshopper.1Component.ghicon"
}
}
]
}
],
"primaryOutputs": [
{ "path": "MyGrasshopper.1.csproj" },
{ "path": "MyGrasshopper__1Component.cs" }
],
"guids": [
"ee4e2b39-d96b-4e4c-8f9d-9b6561e61b64",
"e79cd2b5-cb9c-4d08-93ec-446cc1f6d923",
"cd826b9b-8dbe-4c31-aac1-6fc7ea2bcfb7"
],
"postActions": [
{
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
"description": "Opens the command in the editor",
"manualInstructions": [],
"actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6",
"args": {
"files": "1"
},
"continueOnError": true
}
]
}
47 changes: 47 additions & 0 deletions Rhino.Templates/content/CSGrasshopper2/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Rhino 8 - netcore",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "",
"osx": {
"program": "/Applications/Rhino 8.app/Contents/MacOS/Rhinoceros",
"args": [
"-runscript=_G2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This never seems to work for me on Mac, and I'm not sure why.

]
},
"windows": {
"program": "C:\\Program Files\\Rhino 8\\System\\Rhino.exe",
"targetArchitecture": "x86_64",
"args": "/netcore /runscript=\"_G2\""
},
"env": {
"RHINO_PACKAGE_DIRS": "${workspaceFolder}/bin/Debug"
},
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": "Rhino 8 Windows - netfx",
"type": "clr",
"request": "launch",
"preLaunchTask": "build",
"windows": {
"program": "C:\\Program Files\\Rhino 8\\System\\Rhino.exe",
"targetArchitecture": "x86_64",
"args": "/netfx /runscript=\"_G2\""
},
"env": {
"RHINO_PACKAGE_DIRS": "${workspaceFolder}/bin/Debug"
},
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole"
},
],
"compounds": []
}
21 changes: 21 additions & 0 deletions Rhino.Templates/content/CSGrasshopper2/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "shell",
"args": [
"build",
"-clp:NoSummary",
"${workspaceFolder}/MyGrasshopper.1.csproj"
],
"problemMatcher": "$msCompile",
"presentation": {
"reveal": "always",
"clear": true
},
"group": "build"
}
]
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
89 changes: 89 additions & 0 deletions Rhino.Templates/content/CSGrasshopper2/MyGrasshopper.1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!-- Select the framework(s) you wish to target.
Rhino 8 Windows: net48, net7.0, net7.0-windows, net7.0-windows10.0.22000.0, etc
Rhino 8 Mac: net7.0, net7.0-macos, net7.0-macos12.0, etc
-->
<!--#if (UseWpf)-->
<TargetFrameworks>net7.0-windows;net48</TargetFrameworks>
<!--#elif (UseWindowsDesktop)-->
<TargetFrameworks>net7.0-windows;net7.0;net48</TargetFrameworks>
<!--#else-->
<TargetFrameworks>net7.0;net48</TargetFrameworks>
<!--#endif-->
<EnableDynamicLoading>true</EnableDynamicLoading>
<TargetExt>.rhp</TargetExt>
<!--#if (UseWinForms)-->
<NoWarn>NU1701;NETSDK1086</NoWarn>
<!--#else-->
<NoWarn>NU1701</NoWarn>
<!--#endif-->
<EnableWindowsTargeting Condition="$(UseWindowsDesktop) == 'True'">true</EnableWindowsTargeting>
</PropertyGroup>

<PropertyGroup>
<!-- Specifies information for Assembly, Yak, and GH2 PlugIn Info -->
<Version>1.0</Version>
<Title>MyGrasshopper.1</Title>
<Company>MyGrasshopper.1 Authors</Company>
<Description>Description of MyGrasshopper.1</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Grasshopper2" Version="2.0.9114-wip.27439" ExcludeAssets="runtime" />
</ItemGroup>

<!--#if (UseWindowsDesktop)-->
<!-- For Windows only builds -->
<PropertyGroup Condition="$(TargetFramework.Contains('-windows')) or $(TargetFramework.StartsWith('net4'))">
<!--#if (UseWinForms)-->
<UseWindowsForms>true</UseWindowsForms>
<!--#endif-->
<!--#if (UseWpf)-->
<UseWpf>true</UseWpf>
<!--#endif-->
</PropertyGroup>

<!--#endif-->
<ItemGroup>
<EmbeddedResource Include="Icons\*.ghicon" />
<EmbeddedResource Include="Icons\*.ico" />
</ItemGroup>
<!--#if (UseWinForms)-->
<!-- Reference WinForms for .NET 7.0 on macOS -->
<ItemGroup Condition="!($(TargetFramework.Contains('-windows')) or $(TargetFramework.StartsWith('net4')))">
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WindowsForms" />
</ItemGroup>

<!--#endif-->
<!--#if (RhinoVersion < '8')-->
<Target Name="CopyPdbForMonoDebugging" AfterTargets="AfterBuild">
<!-- Enable debugging in Rhino 6/7 on Mac -->
<Copy SourceFiles="$(TargetDir)$(TargetName).pdb" DestinationFiles="$(TargetDir)$(TargetName).gha.pdb" Condition="$([MSBuild]::IsOSPlatform(OSX)) and $(TargetFramework.StartsWith('net4')) and Exists('$(TargetDir)$(TargetName).pdb')" />
</Target>

<!--#endif-->
<!--#if (BuildYak)-->
<Target Name="BuildYakPackage" AfterTargets="DispatchToInnerBuilds">
<PropertyGroup>
<YakExecutable Condition="$(YakExecutable) == '' and $([MSBuild]::IsOSPlatform(windows)) and Exists('C:\Program Files\Rhino 8\System\Yak.exe')">C:\Program Files\Rhino 8\System\Yak.exe</YakExecutable>
<YakExecutable Condition="$(YakExecutable) == '' and $([MSBuild]::IsOSPlatform(macos)) and Exists('/Applications/Rhino 8.app/Contents/Resources/bin/yak')">/Applications/Rhino 8.app/Contents/Resources/bin/yak</YakExecutable>

<BuildYakPackage Condition="$(BuildYakPackage) == '' and $(YakExecutable) != '' and Exists($(YakExecutable))">True</BuildYakPackage>
</PropertyGroup>

<Warning Text="Could not find Yak executable" Condition="$(YakExecutable) == ''" />

<ItemGroup>
<YakPackagesToDelete Include="$(OutputPath)\*.yak;$(OutputPath)\**\manifest.yml" />
</ItemGroup>

<Delete Files="@(YakPackagesToDelete)" />

<Exec Command="&quot;$(YakExecutable)&quot; spec" WorkingDirectory="$(OutputPath)" Condition="$(BuildYakPackage) == 'True'" />
<Exec Command="&quot;$(YakExecutable)&quot; build" WorkingDirectory="$(OutputPath)" Condition="$(BuildYakPackage) == 'True'" />
</Target>

<!--#endif-->
</Project>
Loading