-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
658 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# ------------------------------------------------------------------------------ | ||
# Build.yml | ||
# ------------------------------------------------------------------------------ | ||
|
||
name: Build | ||
|
||
on: | ||
push: | ||
pull_request: | ||
branches-ignore: | ||
- master | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
Build: | ||
name: Build | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Run './build/build.cmd' | ||
run: ./build/build.cmd --root ./build | ||
env: | ||
GitHubToken: ${{ secrets.GITHUB_TOKEN }} | ||
SignFile: ${{ secrets.SIGN_FILE }} | ||
SignPassword: ${{ secrets.SIGN_PASSWORD }} | ||
InstallationFiles: ${{ secrets.INSTALLATION_FILES }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[*.cs] | ||
dotnet_style_qualification_for_field = false:warning | ||
dotnet_style_qualification_for_property = false:warning | ||
dotnet_style_qualification_for_method = false:warning | ||
dotnet_style_qualification_for_event = false:warning | ||
dotnet_style_require_accessibility_modifiers = never:warning | ||
|
||
csharp_style_expression_bodied_methods = true:silent | ||
csharp_style_expression_bodied_properties = true:warning | ||
csharp_style_expression_bodied_indexers = true:warning | ||
csharp_style_expression_bodied_accessors = true:warning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"$schema": "./build.schema.json", | ||
"Solution": "../RevitAddin.Icon.Example.sln" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Nuke.Common; | ||
using Nuke.Common.Execution; | ||
using ricaun.Nuke; | ||
using ricaun.Nuke.Components; | ||
|
||
class Build : NukeBuild, IPublishRevit | ||
{ | ||
string IHazRevitPackageBuilder.Application => "Revit.App"; | ||
public static int Main() => Execute<Build>(x => x.From<IPublishRevit>().Build); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<RootNamespace></RootNamespace> | ||
<NoWarn>CS0649;CS0169</NoWarn> | ||
<NukeRootDirectory>.</NukeRootDirectory> | ||
<NukeScriptDirectory>.</NukeScriptDirectory> | ||
<NukeTelemetryVersion>1</NukeTelemetryVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="ricaun.Nuke.PackageBuilder" Version="*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\.github\workflows\*.yml" LinkBase="ci" /> | ||
<None Include=".github\**\*"/> | ||
<None Include=".nuke\*"/> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
:; set -eo pipefail | ||
:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) | ||
:; ${SCRIPT_DIR}/build.sh "$@" | ||
:; exit $? | ||
|
||
@ECHO OFF | ||
powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
[CmdletBinding()] | ||
Param( | ||
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] | ||
[string[]]$BuildArguments | ||
) | ||
|
||
Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)" | ||
|
||
Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 } | ||
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent | ||
|
||
########################################################################### | ||
# CONFIGURATION | ||
########################################################################### | ||
|
||
$BuildProjectFile = "$PSScriptRoot\Build.csproj" | ||
$TempDirectory = "$PSScriptRoot\\.nuke\temp" | ||
|
||
$DotNetGlobalFile = "$PSScriptRoot\\global.json" | ||
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1" | ||
$DotNetChannel = "Current" | ||
|
||
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 | ||
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 | ||
$env:DOTNET_MULTILEVEL_LOOKUP = 0 | ||
|
||
########################################################################### | ||
# EXECUTION | ||
########################################################################### | ||
|
||
function ExecSafe([scriptblock] $cmd) { | ||
& $cmd | ||
if ($LASTEXITCODE) { exit $LASTEXITCODE } | ||
} | ||
|
||
# If dotnet CLI is installed globally and it matches requested version, use for execution | ||
if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and ` | ||
$(dotnet --version) -and $LASTEXITCODE -eq 0) { | ||
$env:DOTNET_EXE = (Get-Command "dotnet").Path | ||
} | ||
else { | ||
# Download install script | ||
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" | ||
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null | ||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | ||
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile) | ||
|
||
# If global.json exists, load expected version | ||
if (Test-Path $DotNetGlobalFile) { | ||
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json) | ||
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) { | ||
$DotNetVersion = $DotNetGlobal.sdk.version | ||
} | ||
} | ||
|
||
# Install by channel or version | ||
$DotNetDirectory = "$TempDirectory\dotnet-win" | ||
if (!(Test-Path variable:DotNetVersion)) { | ||
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath } | ||
} else { | ||
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } | ||
} | ||
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe" | ||
} | ||
|
||
Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)" | ||
|
||
ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet } | ||
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env bash | ||
|
||
bash --version 2>&1 | head -n 1 | ||
|
||
set -eo pipefail | ||
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) | ||
|
||
########################################################################### | ||
# CONFIGURATION | ||
########################################################################### | ||
|
||
BUILD_PROJECT_FILE="$SCRIPT_DIR/Build.csproj" | ||
TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp" | ||
|
||
DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json" | ||
DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh" | ||
DOTNET_CHANNEL="Current" | ||
|
||
export DOTNET_CLI_TELEMETRY_OPTOUT=1 | ||
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 | ||
export DOTNET_MULTILEVEL_LOOKUP=0 | ||
|
||
########################################################################### | ||
# EXECUTION | ||
########################################################################### | ||
|
||
function FirstJsonValue { | ||
perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}" | ||
} | ||
|
||
# If dotnet CLI is installed globally and it matches requested version, use for execution | ||
if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then | ||
export DOTNET_EXE="$(command -v dotnet)" | ||
else | ||
# Download install script | ||
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh" | ||
mkdir -p "$TEMP_DIRECTORY" | ||
curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL" | ||
chmod +x "$DOTNET_INSTALL_FILE" | ||
|
||
# If global.json exists, load expected version | ||
if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then | ||
DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")") | ||
if [[ "$DOTNET_VERSION" == "" ]]; then | ||
unset DOTNET_VERSION | ||
fi | ||
fi | ||
|
||
# Install by channel or version | ||
DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" | ||
if [[ -z ${DOTNET_VERSION+x} ]]; then | ||
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path | ||
else | ||
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path | ||
fi | ||
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet" | ||
fi | ||
|
||
echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)" | ||
|
||
"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet | ||
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). | ||
|
||
## [1.0.0] / 2024-01-11 | ||
- First Release | ||
|
||
[vNext]: ../../compare/1.0.0...HEAD | ||
[1.0.0]: ../../compare/1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 ricaun | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# RevitAddin.Icon.Example | ||
|
||
[](../..) | ||
[](../..) | ||
[](https://nuke.build/) | ||
[](LICENSE) | ||
[](../../actions) | ||
|
||
Example to swap the icons when theme change in Revit 2024. | ||
|
||
This project was generated by the [ricaun.AppLoader](https://ricaun.com/AppLoader/) Revit plugin. | ||
|
||
## Installation | ||
|
||
* Download and install [RevitAddin.Icon.Example.exe](../../releases/latest/download/RevitAddin.Icon.Example.zip) | ||
|
||
## License | ||
|
||
This project is [licensed](LICENSE) under the [MIT Licence](https://en.wikipedia.org/wiki/MIT_License). | ||
|
||
--- | ||
|
||
Do you like this project? Please [star this project on GitHub](../../stargazers)! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.8.34316.72 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RevitAddin.Icon.Example", "RevitAddin.Icon.Example\RevitAddin.Icon.Example.csproj", "{A206D7F5-A69C-4011-BD5B-9E419B5DE41E}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Build", "Build\Build.csproj", "{D1EE1E8F-357F-4FCC-929B-78DFC6900C6B}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{372F3C47-52A7-4DB1-BC05-3F8056E317A8}" | ||
ProjectSection(SolutionItems) = preProject | ||
CHANGELOG.md = CHANGELOG.md | ||
LICENSE = LICENSE | ||
README.md = README.md | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
2024|Any CPU = 2024|Any CPU | ||
Debug 2024|Any CPU = Debug 2024|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{A206D7F5-A69C-4011-BD5B-9E419B5DE41E}.2024|Any CPU.ActiveCfg = 2024|Any CPU | ||
{A206D7F5-A69C-4011-BD5B-9E419B5DE41E}.2024|Any CPU.Build.0 = 2024|Any CPU | ||
{A206D7F5-A69C-4011-BD5B-9E419B5DE41E}.Debug 2024|Any CPU.ActiveCfg = Debug 2024|Any CPU | ||
{A206D7F5-A69C-4011-BD5B-9E419B5DE41E}.Debug 2024|Any CPU.Build.0 = Debug 2024|Any CPU | ||
{D1EE1E8F-357F-4FCC-929B-78DFC6900C6B}.2024|Any CPU.ActiveCfg = Debug|Any CPU | ||
{D1EE1E8F-357F-4FCC-929B-78DFC6900C6B}.2024|Any CPU.Build.0 = Debug|Any CPU | ||
{D1EE1E8F-357F-4FCC-929B-78DFC6900C6B}.Debug 2024|Any CPU.ActiveCfg = Debug|Any CPU | ||
{D1EE1E8F-357F-4FCC-929B-78DFC6900C6B}.Debug 2024|Any CPU.Build.0 = Debug|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Autodesk.Revit.DB; | ||
using Autodesk.Revit.UI; | ||
using ricaun.Revit.UI; | ||
using System.IO; | ||
|
||
namespace RevitAddin.Icon.Example.Revit | ||
{ | ||
[AppLoader] | ||
public class App : IExternalApplication | ||
{ | ||
private static RibbonPanel ribbonPanel; | ||
private static RibbonImageThemeSelector ribbonImageThemeSelector; | ||
public Result OnStartup(UIControlledApplication application) | ||
{ | ||
ribbonImageThemeSelector = new RibbonImageThemeSelector(application); | ||
|
||
var icons = new[] { "Grey", "Red", "Yellow", "Green", "Cyan", "Blue", "Purple", "Pink", "Brown" }; | ||
|
||
ribbonPanel = application.CreatePanel("RevitAddin.Icon.Example"); | ||
foreach (var icon in icons) | ||
{ | ||
ribbonPanel.CreatePushButton<Commands.Command>(icon) | ||
.SetLargeImage($"Resources/Images/Cube-{icon}.ico"); | ||
} | ||
|
||
ribbonImageThemeSelector.AddRibbonItem(ribbonPanel.GetRibbonItems()); | ||
|
||
ribbonImageThemeSelector.UpdateImages(); | ||
|
||
return Result.Succeeded; | ||
} | ||
|
||
public Result OnShutdown(UIControlledApplication application) | ||
{ | ||
ribbonPanel?.Remove(); | ||
ribbonImageThemeSelector?.Dispose(); | ||
return Result.Succeeded; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Autodesk.Revit.Attributes; | ||
using Autodesk.Revit.DB; | ||
using Autodesk.Revit.UI; | ||
using System; | ||
|
||
namespace RevitAddin.Icon.Example.Revit.Commands | ||
{ | ||
[Transaction(TransactionMode.Manual)] | ||
public class Command : IExternalCommand | ||
{ | ||
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) | ||
{ | ||
UIApplication uiapp = commandData.Application; | ||
|
||
UIThemeManager.CurrentTheme = UIThemeManager.CurrentTheme == UITheme.Light ? UITheme.Dark : UITheme.Light; | ||
|
||
return Result.Succeeded; | ||
} | ||
} | ||
} |
Oops, something went wrong.