Skip to content

Commit

Permalink
Merge pull request #9 from ricaun-io/develop
Browse files Browse the repository at this point in the history
Version 1.0.5
  • Loading branch information
ricaun authored May 9, 2023
2 parents 3e4a652 + 70c1edc commit 9ae9c3a
Show file tree
Hide file tree
Showing 19 changed files with 659 additions and 128 deletions.
3 changes: 3 additions & 0 deletions Build/.nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
"MainName": {
"type": "string"
},
"MiddleVersions": {
"type": "boolean"
},
"Name": {
"type": "string"
},
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ 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.5] / 2023-05-05
### Features
- Support C# version 7.3 in Revit 2021+ with `DotNetCompilerPlatform`.
- Gist Download Files and compile.
- Support `CodeDomService` with Defines - `Revit20$$` and `REVIT20$$`.
### Updated
- Update `InfoCenterUtils` to show download update.

## [1.0.4] / 2023-02-03
### Updated
- Update example `Command` to `Revit Version`
Expand All @@ -30,6 +38,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- [x] AutoUpdater

[vNext]: ../../compare/1.0.0...HEAD
[1.0.5]: ../../compare/1.0.4...1.0.5
[1.0.4]: ../../compare/1.0.3...1.0.4
[1.0.3]: ../../compare/1.0.2...1.0.3
[1.0.2]: ../../compare/1.0.1...1.0.2
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ This project was generated by the [AppLoader](https://ricaun.com/apploader/) Rev

## Limitations

In Revit 2021+ the `CodeDom.Compiler` uses the (Roslyn)[https://github.com/aspnet/RoslynCodeDomProvider] version compiler.
The Roslyn compiler is a new compiler that supports C# version 6 and above.

`CodeDom.Compiler` only work with C# compiler version `v4.0` maximum, the following features do not work in C# version 4.
* Async Features (C# version 5)
* String interpolation (C# version 6)
Expand Down
35 changes: 23 additions & 12 deletions RevitAddin.CommandLoader.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("{FD2A9150-BC8F-4112-B3C1-0F6778EB3CBC}") = "RevitAddin.CommandLoader", "RevitAddin.CommandLoader\RevitAddin.CommandLoader.csproj", "{82070359-36DA-4441-A59D-9018B6A8B348}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RevitAddin.CommandLoader", "RevitAddin.CommandLoader\RevitAddin.CommandLoader.csproj", "{82070359-36DA-4441-A59D-9018B6A8B348}"
EndProject
Project("{FD2A9150-BC8F-4112-B3C1-0F6778EB3CBC}") = "Build", "Build\Build.csproj", "{34853418-411C-4B27-82AF-DDE5309AEE10}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Build", "Build\Build.csproj", "{34853418-411C-4B27-82AF-DDE5309AEE10}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{E6AC2FD0-D488-44FE-9390-3CADFB37E99D}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -16,18 +16,29 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{E6
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
2017|Any CPU = 2017|Any CPU
2021|Any CPU = 2021|Any CPU
Debug 2017|Any CPU = Debug 2017|Any CPU
Debug 2021|Any CPU = Debug 2021|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{82070359-36DA-4441-A59D-9018B6A8B348}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82070359-36DA-4441-A59D-9018B6A8B348}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82070359-36DA-4441-A59D-9018B6A8B348}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82070359-36DA-4441-A59D-9018B6A8B348}.Release|Any CPU.Build.0 = Release|Any CPU
{34853418-411C-4B27-82AF-DDE5309AEE10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34853418-411C-4B27-82AF-DDE5309AEE10}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82070359-36DA-4441-A59D-9018B6A8B348}.2017|Any CPU.ActiveCfg = 2017|Any CPU
{82070359-36DA-4441-A59D-9018B6A8B348}.2017|Any CPU.Build.0 = 2017|Any CPU
{82070359-36DA-4441-A59D-9018B6A8B348}.2021|Any CPU.ActiveCfg = 2021|Any CPU
{82070359-36DA-4441-A59D-9018B6A8B348}.2021|Any CPU.Build.0 = 2021|Any CPU
{82070359-36DA-4441-A59D-9018B6A8B348}.Debug 2017|Any CPU.ActiveCfg = Debug 2017|Any CPU
{82070359-36DA-4441-A59D-9018B6A8B348}.Debug 2017|Any CPU.Build.0 = Debug 2017|Any CPU
{82070359-36DA-4441-A59D-9018B6A8B348}.Debug 2021|Any CPU.ActiveCfg = Debug 2021|Any CPU
{82070359-36DA-4441-A59D-9018B6A8B348}.Debug 2021|Any CPU.Build.0 = Debug 2021|Any CPU
{34853418-411C-4B27-82AF-DDE5309AEE10}.2017|Any CPU.ActiveCfg = Release|Any CPU
{34853418-411C-4B27-82AF-DDE5309AEE10}.2021|Any CPU.ActiveCfg = Release|Any CPU
{34853418-411C-4B27-82AF-DDE5309AEE10}.Debug 2017|Any CPU.ActiveCfg = Debug|Any CPU
{34853418-411C-4B27-82AF-DDE5309AEE10}.Debug 2021|Any CPU.ActiveCfg = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {98A9768C-D450-4125-8057-441B3C106F5E}
EndGlobalSection
EndGlobal
5 changes: 5 additions & 0 deletions RevitAddin.CommandLoader/Extensions/AppName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@ public static string GetInfo()

return result;
}

public static string GetUri()
{
return "https://github.com/ricaun-io/RevitAddin.CommandLoader";
}
}
}
15 changes: 8 additions & 7 deletions RevitAddin.CommandLoader/Revit/App.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using ricaun.Revit.UI;
using Revit.Async;
using RevitAddin.CommandLoader.Extensions;
using ricaun.Revit.Github;
using ricaun.Revit.UI;
using System;
using System.Threading.Tasks;
using System.Reflection;
using System.Linq;
using RevitAddin.CommandLoader.Extensions;
using System.ComponentModel;
using Revit.Async;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

namespace RevitAddin.CommandLoader.Revit
{
Expand All @@ -29,7 +29,7 @@ public Result OnStartup(UIControlledApplication application)
.SetLargeImage(Properties.Resources.CommandLoader.GetBitmapSource())
.SetToolTip("Open CommandLoader window that compiles Revit code and creates pushbuttons for each `IExternalCommand`, `IExternalCommandAvailability` could be used in the same class to enable the availability features.")
.SetLongDescription(AppName.GetInfo())
.SetContextualHelp("https://github.com/ricaun-io/RevitAddin.CommandLoader");
.SetContextualHelp(AppName.GetUri());

service = new GithubRequestService("ricaun-io", "RevitAddin.CommandLoader");

Expand Down Expand Up @@ -57,6 +57,7 @@ private void ControlledApplication_ApplicationInitialized(object sender, Autodes
bool downloadedNewVersion = await service.Initialize();
if (downloadedNewVersion)
{
InfoCenterUtils.ShowBalloon("Download New Release!", null, AppName.GetUri());
Console.WriteLine($"RevitAddin.CommandLoader: {downloadedNewVersion}");
}
});
Expand Down
146 changes: 146 additions & 0 deletions RevitAddin.CommandLoader/Revit/CodeSamples.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
using System;
using System.Net.NetworkInformation;
using System.Security.Policy;

namespace RevitAddin.CommandLoader.Revit
{
public class CodeSamples
{
public static string CommandVersionGist => "https://gist.github.com/ricaun/200a576c3baa45cba034ceedac1e708e";
public static string Command =>
@"using System;
using System.ComponentModel;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace RevitAddin
{
[DisplayName(""Revit\rVersion"")]
[Description(""Show a Window with the Revit VersionName."")]
[Designer(""/UIFrameworkRes;component/ribbon/images/revit.ico"")]
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;
System.Windows.MessageBox.Show(uiapp.Application.VersionName);
return Result.Succeeded;
}
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return true;
}
}
}";

public static string CommandVersion =>
@"using System;
using System.ComponentModel;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace RevitAddin
{
[DisplayName(""Revit\rVersion"")]
[Description(""Show a Window with the Revit VersionName."")]
[Designer(""/UIFrameworkRes;component/ribbon/images/revit.ico"")]
[Transaction(TransactionMode.Manual)]
public class CommandVersion : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;
System.Windows.MessageBox.Show(uiapp.Application.VersionName);
return Result.Succeeded;
}
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return true;
}
}
}";

public static string CommandDeleteWalls =>
@"using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace RevitAddin
{
[Transaction(TransactionMode.Manual)]
public class DeleteWalls : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
// Get all walls in the document
List<Wall> walls = new FilteredElementCollector(doc)
.OfClass(typeof(Wall))
.Cast<Wall>()
.ToList();
// Delete all walls
using (Transaction trans = new Transaction(doc))
{
trans.Start(""Delete Walls"");
foreach (Wall wall in walls)
{
doc.Delete(wall.Id);
}
trans.Commit();
}
return Result.Succeeded;
}
}
}";

public static string CommandTask =>
@"using System;
using System.ComponentModel;
using System.Threading.Tasks;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace RevitAddin
{
[DisplayName(""Task"")]
[Designer(""/UIFrameworkRes;component/ribbon/images/revit.ico"")]
[Transaction(TransactionMode.Manual)]
public class CommandTask : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;
Task.Run(async () =>
{
await Task.Delay(100);
System.Windows.MessageBox.Show(uiapp.Application.VersionName);
});
return Result.Succeeded;
}
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return true;
}
}
}";
}
}



1 change: 1 addition & 0 deletions RevitAddin.CommandLoader/Revit/Commands/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Autodesk.Revit.UI;
using System;
using System.ComponentModel;
using System.Threading.Tasks;

namespace RevitAddin.CommandLoader.Revit.Commands
{
Expand Down
74 changes: 8 additions & 66 deletions RevitAddin.CommandLoader/Revit/Commands/CommandTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using Autodesk.Revit.UI;
using RevitAddin.CommandLoader.Services;
using System.ComponentModel;
using System.IO;
using System.Reflection;

namespace RevitAddin.CommandLoader.Revit.Commands
{
Expand All @@ -14,81 +16,21 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme
{
UIApplication uiapp = commandData.Application;


var source = @"
using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace Revit_Delete_Walls
{
[Transaction(TransactionMode.Manual)]
public class DeleteWalls2 : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
// Get all walls in the document
List<Wall> walls = new FilteredElementCollector(doc)
.OfClass(typeof(Wall))
.Cast<Wall>()
.ToList();
// Delete all walls
using (Transaction trans = new Transaction(doc))
{
trans.Start(""Delete Walls"");
foreach (Wall wall in walls)
{
doc.Delete(wall.Id);
}
trans.Commit();
}
return Result.Succeeded;
}
}
[DisplayName(""Command Name"")]
[Description(""This is a command tooltip"")]
[Designer("" / UIFrameworkRes;component/ribbon/images/revit.ico"")]
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;
System.Windows.MessageBox.Show(uiapp.Application.VersionName);
return Result.Succeeded;
}
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return true;
}
}
}
";

try
{
var assembly = new CodeDomService().GenerateCode(source);
CodeDomService codeDomService = new CodeDomService();
var assembly = codeDomService.GenerateCode(
CodeSamples.CommandVersion,
CodeSamples.CommandTask,
CodeSamples.CommandDeleteWalls);

App.CreateCommands(assembly);
}
catch (System.Exception ex)
{
System.Windows.MessageBox.Show(ex.ToString());
}

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

return Result.Succeeded;
}

Expand Down
Loading

0 comments on commit 9ae9c3a

Please sign in to comment.