Skip to content

Commit

Permalink
Create Example Project
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Apr 10, 2023
1 parent 8a9b2b5 commit 5cf2ab5
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 5 deletions.
158 changes: 158 additions & 0 deletions Revit.Busy.Example/Revit.Busy.Example.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<PlatformTarget>AnyCPU</PlatformTarget>
<UseWPF>true</UseWPF>
<LangVersion>latest</LangVersion>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<Configurations>Debug; Release</Configurations>
</PropertyGroup>

<!-- RevitVersion -->
<Choose>
<When Condition="$(Configuration.Contains('2017'))">
<PropertyGroup>
<RevitVersion>2017</RevitVersion>
<TargetFramework>net46</TargetFramework>
</PropertyGroup>
</When>
<When Condition="$(Configuration.Contains('2018'))">
<PropertyGroup>
<RevitVersion>2018</RevitVersion>
<TargetFramework>net46</TargetFramework>
</PropertyGroup>
</When>
<When Condition="$(Configuration.Contains('2019'))">
<PropertyGroup>
<RevitVersion>2019</RevitVersion>
<TargetFramework>net47</TargetFramework>
</PropertyGroup>
</When>
<When Condition="$(Configuration.Contains('2020'))">
<PropertyGroup>
<RevitVersion>2020</RevitVersion>
<TargetFramework>net47</TargetFramework>
</PropertyGroup>
</When>
<When Condition="$(Configuration.Contains('2021'))">
<PropertyGroup>
<RevitVersion>2021</RevitVersion>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>
</When>
<When Condition="$(Configuration.Contains('2022'))">
<PropertyGroup>
<RevitVersion>2022</RevitVersion>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>
</When>
<When Condition="$(Configuration.Contains('2023'))">
<PropertyGroup>
<RevitVersion>2023</RevitVersion>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>
</When>
<When Condition="$(Configuration.Contains('2024'))">
<PropertyGroup>
<RevitVersion>2024</RevitVersion>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<RevitVersion>2017</RevitVersion>
<TargetFramework>net46</TargetFramework>
</PropertyGroup>
</Otherwise>
</Choose>

<!-- Release -->
<PropertyGroup Condition="!$(Configuration.Contains('Debug'))">
<Optimize>true</Optimize>
<OutputPath>bin\Release\$(RevitVersion)</OutputPath>
<DefineConstants>REVIT$(RevitVersion)</DefineConstants>
<NoWarn>MSB3052</NoWarn>
<DebugType>None</DebugType>
</PropertyGroup>

<!-- Debug -->
<PropertyGroup Condition="$(Configuration.Contains('Debug'))">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;REVIT$(RevitVersion)</DefineConstants>
<DebugType>Full</DebugType>
</PropertyGroup>

<!-- DebugRevitVersion -->
<PropertyGroup Condition="$(Configuration.Contains('Debug'))">
<DebugRevitVersion>$(RevitVersion)</DebugRevitVersion>
<StartAction>Program</StartAction>
<StartProgram>C:\Program Files\Autodesk\Revit $(DebugRevitVersion)\Revit.exe</StartProgram>
</PropertyGroup>

<PropertyGroup>
<PackageId>Revit.Busy.Example</PackageId>
<Version>1.0.0</Version>
<ProjectGuid>{ce1d2870-abe0-4096-95db-6d6db724a2e9}</ProjectGuid>
</PropertyGroup>

<PropertyGroup>
<PackageAssemblyVersion></PackageAssemblyVersion>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Debug'))">
<IncludePackageReferencesDuringMarkupCompilation>false</IncludePackageReferencesDuringMarkupCompilation>
<Revision>$([MSBuild]::Divide($([System.DateTime]::Now.TimeOfDay.TotalSeconds), 4).ToString('F0'))</Revision>
<PackageAssemblyVersion>.Dev.$(Version).$(Revision)</PackageAssemblyVersion>
</PropertyGroup>

<PropertyGroup>
<Company>Company</Company>
<Authors>Authors</Authors>
<Description>Revit Add-In Description for $(PackageId).</Description>
<CopyrightYears>$([System.DateTime]::Now.ToString('yyyy'))</CopyrightYears>
</PropertyGroup>

<PropertyGroup>
<AssemblyName>$(PackageId)$(PackageAssemblyVersion)</AssemblyName>
<Product>$(PackageId)</Product>
<Copyright>Copyright © $(CopyrightYears) $(Company)</Copyright>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ricaun.Revit.UI" Version="*" />
<PackageReference Include="ricaun.Revit.Mvvm" Version="*" />
</ItemGroup>

<ItemGroup>
<Folder Include="Revit\Commands" />
</ItemGroup>

<ItemGroup>
<None Include="Revit\App.cs" />
<None Include="Revit\Commands\Command.cs" />
</ItemGroup>

<!-- Fody -->
<ItemGroup>
<PackageReference Include="PropertyChanged.Fody" Version="3.*" IncludeAssets="build; compile" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup>
<WeaverConfiguration>
<Weavers>
<PropertyChanged />
</Weavers>
</WeaverConfiguration>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Revit_All_Main_Versions_API_x64" Version="$(RevitVersion).*" IncludeAssets="build; compile" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Revit.Busy\Revit.Busy.csproj" />
</ItemGroup>

</Project>
53 changes: 53 additions & 0 deletions Revit.Busy.Example/Revit/App.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using ricaun.Revit.UI;
using System;

namespace Revit.Busy.Example.Revit
{
[AppLoader]
public class App : IExternalApplication
{
private static RibbonPanel ribbonPanel;
private static RibbonItem ribbonItem;
public Result OnStartup(UIControlledApplication application)
{
ribbonPanel = application.CreatePanel("Example");
ribbonItem = ribbonPanel.CreatePushButton<Commands.Command>("RevitBusy")
.SetLargeImage("/UIFrameworkRes;component/ribbon/images/revit.ico");

RevitBusyControl.Initialize(application);
RevitBusyControl.Control.PropertyChanged += RevitBusyControlPropertyChanged;

UpdateLargeImageBusy(ribbonItem, RevitBusyControl.Control);

return Result.Succeeded;
}

private void RevitBusyControlPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
Console.WriteLine($"RevitBusyControl PropertyChanged {e.PropertyName} {RevitBusyControl.Control.IsRevitBusy}");

var control = sender as RevitBusyService;
UpdateLargeImageBusy(ribbonItem, control);
}

public Result OnShutdown(UIControlledApplication application)
{
ribbonPanel?.Remove();
if (RevitBusyControl.Control is not null)
RevitBusyControl.Control.PropertyChanged -= RevitBusyControlPropertyChanged;
return Result.Succeeded;
}

private static void UpdateLargeImageBusy(RibbonItem ribbonItem, RevitBusyService control)
{
const string LargeImageIsBusy = "/UIFrameworkRes;component/ribbon/images/close.ico";
const string LargeImageNoBusy = "/UIFrameworkRes;component/ribbon/images/add.ico";
if (control.IsRevitBusy)
ribbonItem.SetLargeImage(LargeImageIsBusy);
else
ribbonItem.SetLargeImage(LargeImageNoBusy);
}
}
}
20 changes: 20 additions & 0 deletions Revit.Busy.Example/Revit/Commands/Command.cs
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 Revit.Busy.Example.Revit.Commands
{
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;

System.Windows.MessageBox.Show(uiapp.Application.VersionName);

return Result.Succeeded;
}
}
}
14 changes: 10 additions & 4 deletions Revit.Busy.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
# Visual Studio Version 17
VisualStudioVersion = 17.5.33424.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{74BA0492-6BFD-4F77-9C37-70F47D31787D}") = "Revit.Busy", "Revit.Busy\Revit.Busy.csproj", "{3BAB660A-FADA-4AF0-BE2E-23B7FC5067FC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Revit.Busy", "Revit.Busy\Revit.Busy.csproj", "{3BAB660A-FADA-4AF0-BE2E-23B7FC5067FC}"
EndProject
Project("{74BA0492-6BFD-4F77-9C37-70F47D31787D}") = "Build", "Build\Build.csproj", "{A64A0CA4-19A5-4F53-8F22-19D1FDF0F6B4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Build", "Build\Build.csproj", "{A64A0CA4-19A5-4F53-8F22-19D1FDF0F6B4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{44AA1F9A-165C-4BB6-A9EB-5B7A1DBC5EB2}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{44
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Revit.Busy.Example", "Revit.Busy.Example\Revit.Busy.Example.csproj", "{CE1D2870-ABE0-4096-95DB-6D6DB724A2E9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -26,6 +28,10 @@ Global
{3BAB660A-FADA-4AF0-BE2E-23B7FC5067FC}.Release|Any CPU.Build.0 = Release|Any CPU
{A64A0CA4-19A5-4F53-8F22-19D1FDF0F6B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A64A0CA4-19A5-4F53-8F22-19D1FDF0F6B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE1D2870-ABE0-4096-95DB-6D6DB724A2E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE1D2870-ABE0-4096-95DB-6D6DB724A2E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE1D2870-ABE0-4096-95DB-6D6DB724A2E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE1D2870-ABE0-4096-95DB-6D6DB724A2E9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion Revit.Busy/Revit/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class App : IExternalApplication
public Result OnStartup(UIControlledApplication application)
{
ribbonPanel = application.CreatePanel("Revit.Busy");
ribbonItem = ribbonPanel.CreatePushButton<Commands.Command>()
ribbonItem = ribbonPanel.CreatePushButton<Commands.Command>("View")
.SetLargeImage("/UIFrameworkRes;component/ribbon/images/revit.ico");

RevitBusyControl.Initialize(application);
Expand Down

0 comments on commit 5cf2ab5

Please sign in to comment.