diff --git a/README.md b/README.md
index 2652b04..ffc3375 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,12 @@
-右键RevitGen项目,打包,生成nuget,可以修改版本。
-在插件项目去引用nuget包,本地路径可能需要修改nuget.config中的相对路径。
-使用RevitCommand生成命令和面板,CommandHandler来定义运行的逻辑方法
-如果是路径的图标的话,需要属性窗口中把生成方式改成嵌入式资源
+- 右键RevitGen项目,打包,生成nuget,可以修改版本。
+- 在插件项目去引用nuget包,本地路径需要修改nuget.config中的相对路径。
+- 使用partial修饰你的命令类
+- 使用RevitCommand生成命令和面板
+- CommandHandler来定义运行的逻辑方法
+- 如果是路径的图标的话,需要属性窗口中把生成方式改成嵌入式资源
+- 命令自带UIApplication,UIDocument,Document,ActiveView等属性
+- 自带事务处理
+- 命令的特性会生成一个RevitGenApplication的类,注册命令,生成面板。
```
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
@@ -13,7 +18,7 @@ using RevitGenTest.Properties;
namespace RevitGenTest
{
[RevitCommand("我的第一个命令", ToolTip = "这是一个自动生成的酷炫命令!", PanelName = "核心功能", Icon = nameof(Resources.CodeList_32px))]
- public partial class RevitAddin
+ public partial class RevitAddinOne
{
[CommandHandler]
private void Run()
@@ -34,8 +39,8 @@ namespace RevitGenTest
TaskDialog.Show("成功", $"找到了 {walls.Count} 面墙。");
}
}
- [RevitCommand("我的第一个命令", ToolTip = "这是一个自动生成的酷炫命令!", PanelName = "核心功能", Icon = "Resources/CodeList_32px.png")]
- public partial class RevitAddinX
+ [RevitCommand("我的第二个命令", ToolTip = "这是自动生成的酷炫命令!", PanelName = "核心功能", Icon = "Resources/CodeList_32px.png")]
+ public partial class RevitAddinTwo
{
[CommandHandler]
private void Run()
diff --git a/RevitGen.Common/Attributes/RevitCommandAttribute.cs b/RevitGen.Common/Attributes/RevitCommandAttribute.cs
index b5767da..572a80c 100644
--- a/RevitGen.Common/Attributes/RevitCommandAttribute.cs
+++ b/RevitGen.Common/Attributes/RevitCommandAttribute.cs
@@ -1,8 +1,4 @@
-// RevitGen.Common/Attributes/RevitCommandAttribute.cs
-
-using System;
-
-using Autodesk.Revit.Attributes;
+using System;
namespace RevitGen.Attributes
{
@@ -35,11 +31,6 @@ namespace RevitGen.Attributes
///
public string ToolTip { get; set; } = "";
- ///
- /// 命令的事务模式。生成器将根据此模式自动处理事务。
- ///
- public TransactionMode TransactionMode { get; set; } = TransactionMode.Manual;
-
///
/// 构造函数
///
@@ -52,5 +43,7 @@ namespace RevitGen.Attributes
}
Text = text;
}
+ public bool UsingTransaction { get; set; }
+
}
}
\ No newline at end of file
diff --git a/RevitGen.Generator/SourceGenerationHelper.cs b/RevitGen.Generator/SourceGenerationHelper.cs
index cd2975e..63375e5 100644
--- a/RevitGen.Generator/SourceGenerationHelper.cs
+++ b/RevitGen.Generator/SourceGenerationHelper.cs
@@ -1,10 +1,10 @@
-using Microsoft.CodeAnalysis;
-
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
+using Microsoft.CodeAnalysis;
+
namespace RevitGen.Generator
{
///
@@ -34,7 +34,7 @@ namespace RevitGen.Generator
}
var attributeData = classSymbol.GetAttributes().First(ad => ad.AttributeClass?.ToDisplayString() == RevitCommandAttributeFullName);
- var transactionMode = GetAttributeProperty(attributeData, "TransactionMode", 1);
+ var usingTransaction = GetAttributeProperty(attributeData, "UsingTransaction", true);
var source = new StringBuilder();
source.AppendLine("// ");
@@ -46,7 +46,7 @@ namespace RevitGen.Generator
source.AppendLine(" using System.ComponentModel;");
source.AppendLine();
- source.AppendLine($" [Transaction((TransactionMode){transactionMode})]");
+ source.AppendLine($" [Transaction(TransactionMode.Manual)]");
source.AppendLine($" public partial class {className} : IExternalCommand");
source.AppendLine(" {");
source.AppendLine(" private ExternalCommandData _commandData;");
@@ -66,7 +66,7 @@ namespace RevitGen.Generator
source.AppendLine();
source.AppendLine(" try");
source.AppendLine(" {");
- if (transactionMode == 1)
+ if (usingTransaction)
{
source.AppendLine($" using (var trans = new Transaction(this.Document, \"{className}\"))");
source.AppendLine(" {");
@@ -170,7 +170,8 @@ namespace RevitGen.Generator
source.AppendLine();
- var commandsWithData = commandClasses.Select(c => new {
+ var commandsWithData = commandClasses.Select(c => new
+ {
Symbol = c,
Attribute = c.GetAttributes().First(ad => ad.AttributeClass?.ToDisplayString() == RevitCommandAttributeFullName)
}).ToList();
diff --git a/RevitGen/RevitGen.csproj b/RevitGen/RevitGen.csproj
index f22ca94..d0e1268 100644
--- a/RevitGen/RevitGen.csproj
+++ b/RevitGen/RevitGen.csproj
@@ -4,7 +4,7 @@
netstandard2.0
RevitGen
- 1.0.1
+ 1.0.2
ShrlAlgo
https://www.shrlalgo.cn/
https://github.com/ShrlAlgo/RevitGen
@@ -23,12 +23,11 @@
-
+
-
@@ -43,7 +42,6 @@
-
\ No newline at end of file
diff --git a/RevitGen/build/RevitGen.targets b/RevitGen/build/RevitGen.targets
deleted file mode 100644
index 1e15c6d..0000000
--- a/RevitGen/build/RevitGen.targets
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- $(MSBuildThisFileDirectory)..\lib\netstandard2.0\RevitGen.Common.dll
- all
-
-
-
\ No newline at end of file