diff --git a/KeyGen/App.config b/KeyGen/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/KeyGen/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/KeyGen/App.xaml b/KeyGen/App.xaml
new file mode 100644
index 0000000..5be5bd3
--- /dev/null
+++ b/KeyGen/App.xaml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WebUITest/App.xaml.cs b/KeyGen/App.xaml.cs
similarity index 93%
rename from WebUITest/App.xaml.cs
rename to KeyGen/App.xaml.cs
index d94725d..0a3a654 100644
--- a/WebUITest/App.xaml.cs
+++ b/KeyGen/App.xaml.cs
@@ -6,7 +6,7 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows;
-namespace WebUITest
+namespace KeyGen
{
///
/// App.xaml 的交互逻辑
diff --git a/KeyGen/KeyGen.csproj b/KeyGen/KeyGen.csproj
new file mode 100644
index 0000000..00ff778
--- /dev/null
+++ b/KeyGen/KeyGen.csproj
@@ -0,0 +1,22 @@
+
+
+ net472
+ WinExe
+ 12.0
+ enable
+ false
+ true
+ true
+ authentication.ico
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/KeyGen/MainWindow.xaml b/KeyGen/MainWindow.xaml
new file mode 100644
index 0000000..50ae2d1
--- /dev/null
+++ b/KeyGen/MainWindow.xaml
@@ -0,0 +1,158 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/KeyGen/MainWindow.xaml.cs b/KeyGen/MainWindow.xaml.cs
new file mode 100644
index 0000000..5ce1e74
--- /dev/null
+++ b/KeyGen/MainWindow.xaml.cs
@@ -0,0 +1,189 @@
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+using System.Windows;
+
+using iNKORE.UI.WPF.Modern;
+
+using Microsoft.Win32;
+
+using Org.BouncyCastle.Crypto;
+using Org.BouncyCastle.Crypto.Generators;
+using Org.BouncyCastle.OpenSsl;
+using Org.BouncyCastle.Security;
+
+namespace KeyGen
+{
+ ///
+ /// MainWindow.xaml 的交互逻辑
+ ///
+ public partial class MainWindow
+ {
+ public MainWindow()
+ {
+ InitializeComponent();
+ }
+ private void LicenseClick(object sender, RoutedEventArgs e)
+ {
+ DateTime issueDate = DateTime.Now;
+ //DateTime expiryDate = issueDate.AddYears(1);
+ var expiryDate = ExpiryDatePicker.SelectedDate;
+ if (expiryDate == null)
+ {
+ Message.Text = ("请选择授权到期时间");
+ return;
+ }
+ if (expiryDate < issueDate)
+ {
+ Message.Text = ("授权到期时间有误,应比发码日期晚");
+ return;
+ }
+ string mCode = MachineCodeTextBox.Text.Trim().ToUpper();
+ if (string.IsNullOrEmpty(mCode))
+ {
+ Message.Text = ("请先获取机器码");
+ return;
+ }
+ string key = SignData(mCode, issueDate, expiryDate, PrivateKeyTextBox.Text);
+ LicenseTextBox.Text = key;
+ Clipboard.SetText(key);
+ Message.Text = "激活码已复制!";
+ }
+ private void GenerateKeyClick(object sender, RoutedEventArgs e)
+ {
+ //using (var rsa = new RSACryptoServiceProvider(2048))
+ //{
+
+ // PublicKeyTextBox.Text = rsa.ToXmlString(false); // 放在插件里
+ // PrivateKeyTextBox.Text = rsa.ToXmlString(true); // 自己妥善保存
+ //}
+ // 1. 生成 RSA 密钥对
+ RsaKeyPairGenerator generator = new RsaKeyPairGenerator();
+ generator.Init(new KeyGenerationParameters(new SecureRandom(), 2048));
+ AsymmetricCipherKeyPair keyPair = generator.GenerateKeyPair();
+
+ // 2. 导出公钥为 PEM 格式 (SubjectPublicKeyInfo - OpenSSL 兼容)
+ using (StringWriter sw = new StringWriter())
+ {
+ PemWriter pemWriter = new PemWriter(sw);
+ pemWriter.WriteObject(keyPair.Public);
+ PublicKeyTextBox.Text = sw.ToString();
+ }
+
+ // 3. 导出私钥为 PEM 格式 (PKCS#1 格式)
+ using (StringWriter sw = new StringWriter())
+ {
+ PemWriter pemWriter = new PemWriter(sw);
+ pemWriter.WriteObject(keyPair.Private);
+ PrivateKeyTextBox.Text = sw.ToString();
+ }
+ }
+
+ public string SignData(string machineCode, DateTime issue, DateTime? expiry, string privateKeyPem)
+ {
+ if (expiry == null)
+ {
+ throw new ArgumentNullException(nameof(expiry), "Expiry date cannot be null.");
+ }
+ // 1. 严格格式化日期
+ string issueStr = issue.ToString("yyyy-MM-dd");
+ string expiryStr = expiry?.ToString("yyyy-MM-dd");
+
+ // 2. 拼接原始数据 (必须带上 |)
+ string dataToSign = $"{machineCode}{issueStr}{expiryStr}";
+
+ // 3. 使用 BouncyCastle 签名
+ ISigner signer = SignerUtilities.GetSigner("SHA-256withRSA");
+
+ using (StringReader sr = new StringReader(privateKeyPem))
+ {
+ PemReader pr = new PemReader(sr);
+ AsymmetricCipherKeyPair keyPair = (AsymmetricCipherKeyPair)pr.ReadObject();
+ signer.Init(true, keyPair.Private);
+ }
+
+ byte[] dataBytes = Encoding.UTF8.GetBytes(dataToSign);
+ signer.BlockUpdate(dataBytes, 0, dataBytes.Length);
+ byte[] sigBytes = signer.GenerateSignature();
+
+ string signature = Convert.ToBase64String(sigBytes);
+
+ // 4. 返回最终激活码
+ return $"{signature}|{machineCode}|{issueStr}|{expiryStr}";
+ }
+ private string CreateLicense(string machineCode, DateTime issue, DateTime expiry)
+ {
+ string issueStr = issue.ToString("yyyy-MM-dd");
+ string expiryStr = expiry.ToString("yyyy-MM-dd");
+
+ // 签名原始数据:机器码 + 发码日期 + 过期日期
+ string dataToSign = $"{machineCode}|{issueStr}|{expiryStr}";
+
+ using (var rsa = new RSACryptoServiceProvider())
+ {
+ rsa.FromXmlString(PrivateKeyTextBox.Text);
+ var formatter = new RSAPKCS1SignatureFormatter(rsa);
+ formatter.SetHashAlgorithm("SHA256");
+
+ byte[] dataBytes = Encoding.UTF8.GetBytes(dataToSign);
+ using (var sha = SHA256.Create())
+ {
+ byte[] hash = sha.ComputeHash(dataBytes);
+ string signature = Convert.ToBase64String(formatter.CreateSignature(hash));
+
+ // 最终格式:签名|机器码|发码日期|过期日期
+ return $"{signature}|{machineCode}|{issueStr}|{expiryStr}";
+ }
+ }
+ }
+ private void SaveKeysClick(object sender, RoutedEventArgs e)
+ {
+ VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog();
+ if (dialog.ShowDialog())
+ {
+ string publicKeyPath = System.IO.Path.Combine(dialog.SelectedPath, "PublicKey.txt");
+ File.WriteAllText(publicKeyPath, PublicKeyTextBox.Text);
+ string privateKeyPath = System.IO.Path.Combine(dialog.SelectedPath, "PrivateKey.txt");
+ File.WriteAllText(privateKeyPath, PrivateKeyTextBox.Text);
+ Message.Text = ($"公私密钥已保存到:{dialog.SelectedPath}");
+ }
+ }
+
+ private void SaveLicenseClick(object sender, RoutedEventArgs e)
+ {
+ VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog();
+ if (dialog.ShowDialog())
+ {
+ string path = System.IO.Path.Combine(dialog.SelectedPath, "license.txt");
+ File.WriteAllText(path, LicenseTextBox.Text);
+ Message.Text = ($"激活码已保存到:{path}");
+ }
+ }
+
+ private void ImportPrivateKeyClick(object sender, RoutedEventArgs e)
+ {
+ OpenFileDialog dialog = new OpenFileDialog()
+ {
+ Filter = "文本文件 (*.txt)|*.txt|所有文件 (*.*)|*.*"
+ };
+ if (dialog.ShowDialog() == true)
+ {
+ string privateKey = File.ReadAllText(dialog.FileName);
+ PrivateKeyTextBox.Text = privateKey;
+ Message.Text = ($"导入文件私钥完成");
+ }
+ }
+ private void Button_ToggleTheme_Click(object sender, RoutedEventArgs e)
+ {
+ if (ThemeManager.Current.ApplicationTheme == ApplicationTheme.Dark)
+ {
+ ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
+ }
+ else
+ {
+ ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
+ }
+ }
+ }
+}
diff --git a/KeyGen/Properties/AssemblyInfo.cs b/KeyGen/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..4910542
--- /dev/null
+++ b/KeyGen/Properties/AssemblyInfo.cs
@@ -0,0 +1,52 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("KeyGen")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("KeyGen")]
+[assembly: AssemblyCopyright("Copyright © 2025")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+//若要开始生成可本地化的应用程序,请设置
+//.csproj 文件中的 CultureYouAreCodingWith
+//在 中。例如,如果你使用的是美国英语。
+//使用的是美国英语,请将 设置为 en-US。 然后取消
+//对以下 NeutralResourceLanguage 特性的注释。 更新
+//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //主题特定资源词典所处位置
+ //(未在页面中找到资源时使用,
+ //或应用程序资源字典中找到时使用)
+ ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
+ //(未在页面中找到资源时使用,
+ //、应用程序或任何主题专用资源字典中找到时使用)
+)]
+
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/RevitAddins/Properties/Resources.Designer.cs b/KeyGen/Properties/Resources.Designer.cs
similarity index 56%
rename from RevitAddins/Properties/Resources.Designer.cs
rename to KeyGen/Properties/Resources.Designer.cs
index edaf169..adf0c60 100644
--- a/RevitAddins/Properties/Resources.Designer.cs
+++ b/KeyGen/Properties/Resources.Designer.cs
@@ -1,83 +1,71 @@
//------------------------------------------------------------------------------
//
// 此代码由工具生成。
-// 运行时版本:4.0.30319.42000
+// 运行时版本: 4.0.30319.42000
//
-// 对此文件的更改可能会导致不正确的行为,并且如果
-// 重新生成代码,这些更改将会丢失。
+// 对此文件的更改可能导致不正确的行为,如果
+// 重新生成代码,则所做更改将丢失。
//
//------------------------------------------------------------------------------
-namespace RevitAddins.Properties {
- using System;
-
-
+namespace KeyGen.Properties
+{
+
+
///
- /// 一个强类型的资源类,用于查找本地化的字符串等。
+ /// 强类型资源类,用于查找本地化字符串等。
///
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources {
-
+ internal class Resources
+ {
+
private static global::System.Resources.ResourceManager resourceMan;
-
+
private static global::System.Globalization.CultureInfo resourceCulture;
-
+
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources() {
+ internal Resources()
+ {
}
-
+
///
- /// 返回此类使用的缓存的 ResourceManager 实例。
+ /// 返回此类使用的缓存 ResourceManager 实例。
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RevitAddins.Properties.Resources", typeof(Resources).Assembly);
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("KeyGen.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
-
+
///
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
return resourceCulture;
}
- set {
+ set
+ {
resourceCulture = value;
}
}
-
- ///
- /// 查找 System.Drawing.Bitmap 类型的本地化资源。
- ///
- internal static System.Drawing.Bitmap folder {
- get {
- object obj = ResourceManager.GetObject("folder", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// 查找 System.Drawing.Bitmap 类型的本地化资源。
- ///
- internal static System.Drawing.Bitmap xlsx {
- get {
- object obj = ResourceManager.GetObject("xlsx", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
}
}
diff --git a/RevitAddins/Properties/Resources.resx b/KeyGen/Properties/Resources.resx
similarity index 81%
rename from RevitAddins/Properties/Resources.resx
rename to KeyGen/Properties/Resources.resx
index d7c636b..af7dbeb 100644
--- a/RevitAddins/Properties/Resources.resx
+++ b/KeyGen/Properties/Resources.resx
@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,7 +60,6 @@
: and then encoded with base64 encoding.
-->
-
@@ -69,10 +68,9 @@
-
+
-
@@ -87,10 +85,9 @@
-
+
-
@@ -112,16 +109,9 @@
2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- ..\Resources\folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- ..\Resources\xlsx.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
\ No newline at end of file
diff --git a/KeyGen/Properties/Settings.Designer.cs b/KeyGen/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..b629b8b
--- /dev/null
+++ b/KeyGen/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace KeyGen.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/KeyGen/Properties/Settings.settings b/KeyGen/Properties/Settings.settings
new file mode 100644
index 0000000..033d7a5
--- /dev/null
+++ b/KeyGen/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/KeyGen/VistaFolderBrowserDialog.cs b/KeyGen/VistaFolderBrowserDialog.cs
new file mode 100644
index 0000000..1418c45
--- /dev/null
+++ b/KeyGen/VistaFolderBrowserDialog.cs
@@ -0,0 +1,453 @@
+using System;
+using Microsoft.Win32;
+using System.Runtime.InteropServices;
+using System.Windows;
+using System.Windows.Interop;
+
+// ReSharper disable UnusedMember.Local
+
+///
+/// Vista风格的文件夹选择对话框,支持多选、初始文件夹设置等功能。
+///
+public sealed class VistaFolderBrowserDialog
+{
+ ///
+ /// 创建原生的IFileOpenDialog实例。
+ ///
+ /// IFileOpenDialog实例。
+ private static IFileOpenDialog CreateNativeDialog() { return (IFileOpenDialog)new FileOpenDialog(); }
+
+ ///
+ /// 获取对话框的选项配置(Fos枚举)。
+ ///
+ /// Fos选项集合。
+ private Fos GetDialogOptions()
+ {
+ var options = Fos.Pickfolders;
+ if (Multiselect)
+ {
+ options |= Fos.Allowmultiselect;
+ }
+
+ if (!AllowNonStoragePlaces)
+ {
+ options |= Fos.Forcefilesystem;
+ }
+
+ return options;
+ }
+
+ ///
+ /// 获取指定Shell项的路径和元素名称。
+ ///
+ /// Shell项。
+ /// 输出:文件系统路径。
+ /// 输出:元素名称。
+ private static void GetPathAndElementName(IShellItem item, out string? path, out string elementName)
+ {
+ item.GetDisplayName(Sigdn.Parentrelativeforaddressbar, out elementName);
+ try
+ {
+ item.GetDisplayName(Sigdn.Filesyspath, out path);
+ }
+ catch (ArgumentException ex) when (ex.HResult == -2147024809)
+ {
+ path = null;
+ }
+ }
+
+ ///
+ /// 设置对话框选择结果到属性(支持单选和多选)。
+ ///
+ /// IFileOpenDialog实例。
+ private void SetDialogResults(IFileOpenDialog dialog)
+ {
+ IShellItem item;
+ if (!Multiselect)
+ {
+ dialog.GetResult(out item);
+ GetPathAndElementName(item, out var path, out var value);
+ SelectedPath = path;
+ SelectedPaths = [path];
+ SelectedElementName = value;
+ SelectedElementNames = [value];
+ }
+ else
+ {
+ dialog.GetResults(out var items);
+
+ items.GetCount(out var count);
+
+ SelectedPaths = new string[count];
+ SelectedElementNames = new string[count];
+
+ for (uint i = 0; i < count; ++i)
+ {
+ items.GetItemAt(i, out item);
+ GetPathAndElementName(item, out var path, out var value);
+ SelectedPaths[i] = path;
+ SelectedElementNames[i] = value;
+ }
+
+ SelectedPath = null;
+ SelectedElementName = null;
+ }
+ }
+
+ ///
+ /// 设置对话框的初始文件夹。
+ ///
+ /// IFileOpenDialog实例。
+ private void SetInitialFolder(IFileOpenDialog dialog)
+ {
+ if (!string.IsNullOrEmpty(SelectedPath))
+ {
+ uint atts = 0;
+ if (NativeMethods.SHILCreateFromPath(SelectedPath, out var idl, ref atts) == 0 &&
+ NativeMethods.SHCreateShellItem(IntPtr.Zero, IntPtr.Zero, idl, out var item) == 0)
+ {
+ dialog.SetFolder(item);
+ }
+ }
+ }
+
+ ///
+ /// 设置对话框的选项。
+ ///
+ /// IFileOpenDialog实例。
+ private void SetOptions(IFileOpenDialog dialog)
+ {
+ var options = GetDialogOptions();
+ if (!ShowNewFolderButton)
+ {
+ options |= Fos.Notestfilecreate;
+ }
+ dialog.SetOptions(options);
+ }
+
+ ///
+ /// 显示对话框,无所有者窗口。
+ ///
+ /// 用户是否选择了文件夹。
+ public bool ShowDialog() { return ShowDialog(IntPtr.Zero); }
+
+ ///
+ /// 显示对话框,指定WPF窗口作为所有者。
+ ///
+ /// WPF窗口。
+ /// 用户是否选择了文件夹。
+ public bool ShowDialog(Window? owner)
+ { return ShowDialog(owner == null ? IntPtr.Zero : new WindowInteropHelper(owner).Handle); }
+
+ ///
+ /// 显示对话框,指定Win32窗口作为所有者。
+ ///
+ /// Win32窗口。
+ /// 用户是否选择了文件夹。
+ public bool ShowDialog(IWin32Window? owner) { return ShowDialog(owner?.Handle ?? IntPtr.Zero); }
+
+ ///
+ /// 显示对话框,指定窗口句柄作为所有者。
+ ///
+ /// 窗口句柄。
+ /// 用户是否选择了文件夹。
+ public bool ShowDialog(IntPtr owner)
+ {
+ if (Environment.OSVersion.Version.Major < 6)
+ {
+ throw new InvalidOperationException("对话框需要至少在Visia系统以上才能使用");
+ }
+
+ var dialog = CreateNativeDialog();
+ try
+ {
+ SetInitialFolder(dialog);
+ SetOptions(dialog);
+
+ if (!string.IsNullOrEmpty(Title))
+ {
+ dialog.SetTitle(Title);
+ }
+
+ if (dialog.Show(owner) != 0)
+ {
+ return false;
+ }
+
+ SetDialogResults(dialog);
+
+ return true;
+ }
+ finally
+ {
+ Marshal.ReleaseComObject(dialog);
+ }
+ }
+
+ ///
+ /// 是否允许选择非存储位置(如库、虚拟文件夹)。
+ ///
+ public bool AllowNonStoragePlaces { get; set; }
+
+ ///
+ /// 是否允许多选文件夹。
+ ///
+ public bool Multiselect { get; set; }
+
+ ///
+ /// 选中的元素名称(单选时)。
+ ///
+ public string? SelectedElementName { get; private set; }
+
+ ///
+ /// 选中的所有元素名称(多选时)。
+ ///
+ public string[]? SelectedElementNames { get; private set; }
+
+ ///
+ /// 选中的文件夹路径(单选时)。
+ ///
+ public string? SelectedPath { get; set; }
+
+ ///
+ /// 选中的所有文件夹路径(多选时)。
+ ///
+ public string?[]? SelectedPaths { get; private set; }
+
+ // 属性声明
+ ///
+ /// 获取或设置对话框的标题。
+ ///
+ public string? Title { get; set; }
+
+ ///
+ /// 是否显示新建文件夹按钮。
+ ///
+ public bool ShowNewFolderButton { get; set; } = true;
+
+ // 以下为内部COM接口和枚举定义,通常无需注释
+ [ComImport]
+ [Guid("DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7")]
+ private class FileOpenDialog
+ {
+ }
+
+ ///
+ /// 提供了与Windows Shell交互所需的一些本地方法。这些方法主要用于实现文件夹浏览器对话框的功能,如获取当前活动窗口句柄、从给定路径创建项目标识符列表以及根据PIDL创建IShellItem接口实例。
+ ///
+ private class NativeMethods
+ {
+ ///
+ /// 获取当前活动窗口的句柄。
+ ///
+ /// 当前活动窗口的句柄。
+ [DllImport("user32.dll")]
+ public static extern IntPtr GetActiveWindow();
+
+ ///
+ /// 从给定的PIDL创建一个IShellItem接口实例。
+ ///
+ /// 父项的PIDL。如果为IntPtr.Zero,则表示桌面。
+ /// 父项的IShellFolder接口指针。如果为IntPtr.Zero,则使用默认的桌面文件夹。
+ /// 要创建IShellItem接口实例的PIDL。
+ /// 输出参数,返回创建的IShellItem接口实例。
+ /// 如果函数成功,则返回0;否则返回错误代码。
+ [DllImport("shell32.dll")]
+ public static extern int SHCreateShellItem(
+ IntPtr pidlParent,
+ IntPtr psfParent,
+ IntPtr pidl,
+ out IShellItem ppsi);
+
+ ///
+ /// 从给定的路径创建一个项目标识符列表。
+ ///
+ /// 要转换为项目标识符列表的路径字符串。
+ /// 输出参数,用于接收指向项目标识符列表的指针。
+ /// 输出参数,返回关于解析路径的信息。
+ /// 如果函数成功,则返回0;否则返回错误代码。
+ [DllImport("shell32.dll")]
+ public static extern int SHILCreateFromPath(
+ [MarshalAs(UnmanagedType.LPWStr)] string? pszPath,
+ out IntPtr ppIdl,
+ ref uint rgflnOut);
+ }
+
+ [Flags]
+ private enum Fos
+ {
+ Allnonstorageitems = 0x80,
+
+ Allowmultiselect = 0x200,
+
+ Createprompt = 0x2000,
+
+ Defaultnominimode = 0x20000000,
+
+ Dontaddtorecent = 0x2000000,
+
+ Filemustexist = 0x1000,
+
+ Forcefilesystem = 0x40,
+
+ Forceshowhidden = 0x10000000,
+
+ Hidemruplaces = 0x20000,
+
+ Hidepinnedplaces = 0x40000,
+
+ Nochangedir = 8,
+
+ Nodereferencelinks = 0x100000,
+
+ Noreadonlyreturn = 0x8000,
+
+ Notestfilecreate = 0x10000,
+
+ Novalidate = 0x100,
+
+ Overwriteprompt = 2,
+
+ Pathmustexist = 0x800,
+
+ Pickfolders = 0x20,
+
+ Shareaware = 0x4000,
+
+ Strictfiletypes = 4
+ }
+
+ [ComImport]
+ [Guid("d57c7288-d4ad-4768-be02-9d969532d960")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ [CoClass(typeof(FileOpenDialog))]
+ private interface IFileOpenDialog
+ {
+ [PreserveSig]
+ int Show([In] IntPtr parent);
+
+ void SetFileTypes([In] uint cFileTypes, [In][MarshalAs(UnmanagedType.Struct)] ref IntPtr rgFilterSpec);
+
+ void SetFileTypeIndex([In] uint iFileType);
+
+ void GetFileTypeIndex(out uint piFileType);
+
+ void Advise([In][MarshalAs(UnmanagedType.Interface)] IntPtr pfde, out uint pdwCookie);
+
+ void Unadvise([In] uint dwCookie);
+
+ void SetOptions([In] Fos fos);
+
+ void GetOptions(out Fos pfos);
+
+ void SetDefaultFolder([In][MarshalAs(UnmanagedType.Interface)] IShellItem psi);
+
+ void SetFolder([In][MarshalAs(UnmanagedType.Interface)] IShellItem psi);
+
+ void GetFolder([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
+
+ void GetCurrentSelection([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
+
+ void SetFileName([In][MarshalAs(UnmanagedType.LPWStr)] string pszName);
+
+ void GetFileName([MarshalAs(UnmanagedType.LPWStr)] out string pszName);
+
+ void SetTitle([In][MarshalAs(UnmanagedType.LPWStr)] string? pszTitle);
+
+ void SetOkButtonLabel([In][MarshalAs(UnmanagedType.LPWStr)] string pszText);
+
+ void SetFileNameLabel([In][MarshalAs(UnmanagedType.LPWStr)] string pszLabel);
+
+ void GetResult([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
+
+ void AddPlace([In][MarshalAs(UnmanagedType.Interface)] IShellItem psi, FileDialogCustomPlace fdcp);
+
+ void SetDefaultExtension([In][MarshalAs(UnmanagedType.LPWStr)] string pszDefaultExtension);
+
+ void Close([MarshalAs(UnmanagedType.Error)] int hr);
+
+ void SetClientGuid([In] ref Guid guid);
+
+ void ClearClientData();
+
+ void SetFilter([MarshalAs(UnmanagedType.Interface)] IntPtr pFilter);
+
+ void GetResults([MarshalAs(UnmanagedType.Interface)] out IShellItemArray ppenum);
+
+ void GetSelectedItems([MarshalAs(UnmanagedType.Interface)] out IShellItemArray ppsai);
+ }
+
+ ///
+ /// 代表一个Shell项,提供了获取项的名称、属性、父项以及与其他项比较等功能。
+ ///
+ [ComImport]
+ [Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ private interface IShellItem
+ {
+ void BindToHandler(
+ [In][MarshalAs(UnmanagedType.Interface)] IntPtr pbc,
+ [In] ref Guid bhid,
+ [In] ref Guid riid,
+ out IntPtr ppv);
+
+ void GetParent([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
+
+ void GetDisplayName([In] Sigdn sigdnName, [MarshalAs(UnmanagedType.LPWStr)] out string ppszName);
+
+ void GetAttributes([In] uint sfgaoMask, out uint psfgaoAttribs);
+
+ void Compare([In][MarshalAs(UnmanagedType.Interface)] IShellItem psi, [In] uint hint, out int piOrder);
+ }
+
+ [ComImport]
+ [Guid("B63EA76D-1F85-456F-A19C-48159EFA858B")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ private interface IShellItemArray
+ {
+ void BindToHandler(
+ [In][MarshalAs(UnmanagedType.Interface)] IntPtr pbc,
+ [In] ref Guid rbhid,
+ [In] ref Guid riid,
+ out IntPtr ppvOut);
+
+ void GetPropertyStore([In] int flags, [In] ref Guid riid, out IntPtr ppv);
+
+ void GetPropertyDescriptionList(
+ [In][MarshalAs(UnmanagedType.Struct)] ref IntPtr keyType,
+ [In] ref Guid riid,
+ out IntPtr ppv);
+
+ void GetAttributes(
+ [In][MarshalAs(UnmanagedType.I4)] IntPtr dwAttribFlags,
+ [In] uint sfgaoMask,
+ out uint psfgaoAttribs);
+
+ void GetCount(out uint pdwNumItems);
+
+ void GetItemAt([In] uint dwIndex, [MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
+
+ void EnumItems([MarshalAs(UnmanagedType.Interface)] out IntPtr ppenumShellItems);
+ }
+
+ private enum Sigdn : uint
+ {
+ Desktopabsoluteediting = 0x8004c000,
+
+ Desktopabsoluteparsing = 0x80028000,
+
+ Filesyspath = 0x80058000,
+
+ Normaldisplay = 0,
+
+ Parentrelative = 0x80080001,
+
+ Parentrelativeediting = 0x80031001,
+
+ Parentrelativeforaddressbar = 0x8007c001,
+
+ Parentrelativeparsing = 0x80018001,
+
+ Url = 0x80068000
+ }
+}
\ No newline at end of file
diff --git a/KeyGen/authentication.ico b/KeyGen/authentication.ico
new file mode 100644
index 0000000..caa9e48
Binary files /dev/null and b/KeyGen/authentication.ico differ
diff --git a/ParameterResolve/App.config b/ParameterResolve/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/ParameterResolve/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ParameterResolve/MainWindow.xaml b/ParameterResolve/MainWindow.xaml
new file mode 100644
index 0000000..4607671
--- /dev/null
+++ b/ParameterResolve/MainWindow.xaml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WebUITest/MainWindow.xaml.cs b/ParameterResolve/MainWindow.xaml.cs
similarity index 60%
rename from WebUITest/MainWindow.xaml.cs
rename to ParameterResolve/MainWindow.xaml.cs
index 00e5067..02b97b2 100644
--- a/WebUITest/MainWindow.xaml.cs
+++ b/ParameterResolve/MainWindow.xaml.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -10,18 +11,26 @@ using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
using System.Windows.Shapes;
-namespace WebUITest
+namespace ParameterResolve
{
///
/// MainWindow.xaml 的交互逻辑
///
public partial class MainWindow : Window
{
+ public ObservableCollection Parameters { get; set; }=new ObservableCollection();
public MainWindow()
{
InitializeComponent();
+ DataContext = this;
}
}
+ public class ParameterData
+ {
+ public string Name { get; set; }
+ public string Value { get; set; }
+ }
}
diff --git a/ParameterResolve/ParameterEdit.cs b/ParameterResolve/ParameterEdit.cs
new file mode 100644
index 0000000..0192cfb
--- /dev/null
+++ b/ParameterResolve/ParameterEdit.cs
@@ -0,0 +1,243 @@
+using System;
+using System.Collections.Generic;
+using System.Data.Common;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Windows.Data;
+
+using Autodesk.Revit.Attributes;
+using Autodesk.Revit.DB;
+using Autodesk.Revit.UI;
+using Autodesk.Revit.UI.Selection;
+
+namespace ParameterResolve
+{
+ ///
+ /// Revit执行命令
+ ///
+ [Transaction(TransactionMode.Manual)]
+ [Regeneration(RegenerationOption.Manual)]
+ public class ParameterEdit : IExternalCommand
+ {
+ public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
+ {
+ //程序UI界面
+ UIApplication uiapp = commandData.Application;
+ //获取元素(选择) 显示元素 视图(活动视图)管理(对象)
+ UIDocument uidoc = uiapp.ActiveUIDocument;
+ //程序
+ Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
+ //获取位置和场地 视图(多个视图)管理 获取元素(Revit 项目里的全部元素)
+ Document doc = uidoc.Document;
+ //获取所有打开文档
+ DocumentSet docset = uiapp.Application.Documents;
+ //当前视图
+ View view = doc.ActiveView;
+
+ var parameterElements = new FilteredElementCollector(doc)
+ .OfClass(typeof(SharedParameterElement)).Cast()
+ .Where(p => IsResolveParameter(p.Name)).ToList();
+ var groups = parameterElements.GroupBy(p => p.Name).Where(g => g.Count() > 1).ToList();
+
+ using (Transaction transaction = new Transaction(doc, "删除重复参数"))
+ {
+ transaction.Start();
+ foreach (var group in groups)
+ {
+ if (group.Key == "TC-100-宽度")
+ {
+
+ }
+ Definition firstDef = null;
+ ElementBinding binding = null;
+ CategorySet cateSet = app.Create.NewCategorySet();
+ //所有的绑定
+ var dict = GetDefinitionBindingDic(doc, group.Key);
+ if (dict.Count == 0)
+ {
+ continue;
+ }
+ firstDef = dict.FirstOrDefault().Key;
+ binding = dict[firstDef];
+ //if (dict.All(d => d.Key.ParameterType == ParameterType.Number))
+ //{
+ // firstDef = dict.First(d => d.Key.ParameterType == ParameterType.Number).Key;
+ // binding = dict[firstDef];
+ //}
+ //else
+ //{
+ // firstDef = dict.First(d => d.Key.ParameterType == ParameterType.Text).Key;
+ // binding = dict[firstDef];
+ //}
+ //所有的绑定的类别
+ foreach (var item in dict)
+ {
+ foreach (Category cate in item.Value.Categories)
+ {
+ if (!cateSet.Contains(cate))
+ {
+ cateSet.Insert(cate);
+ }
+ }
+ }
+ //删除多余参数
+ if (firstDef is InternalDefinition internalDefinition)
+ {
+ var idToDel = group.Where(p => p.GetDefinition().Id.IntegerValue != internalDefinition.Id.IntegerValue)
+ .Select(p => p.Id)
+ .ToList();
+ doc.Delete(idToDel);
+ }
+ binding.Categories = cateSet;
+ var res = doc.ParameterBindings.ReInsert(firstDef, binding);
+ }
+ transaction.Commit();
+ }
+ return Result.Succeeded;
+ }
+
+ private void SystemCommonParameters(Autodesk.Revit.ApplicationServices.Application app, Document doc)
+ {
+ var parameterElements = new FilteredElementCollector(doc)
+ .OfClass(typeof(SharedParameterElement)).Cast()
+ .Where(p => IsResolveParameter(p.Name)).ToList();
+ //存在则使用现有项目参数
+ using (Transaction transaction = new Transaction(doc, "关联项目参数"))
+ {
+ transaction.Start();
+ var cateSet = app.Create.NewCategorySet();
+ cateSet.Insert(Category.GetCategory(doc, BuiltInCategory.OST_Walls));
+ cateSet.Insert(Category.GetCategory(doc, BuiltInCategory.OST_Floors));
+ cateSet.Insert(Category.GetCategory(doc, BuiltInCategory.OST_Roofs));
+ cateSet.Insert(Category.GetCategory(doc, BuiltInCategory.OST_Ceilings));
+ cateSet.Insert(Category.GetCategory(doc, BuiltInCategory.OST_StairsRailing));
+ cateSet.Insert(Category.GetCategory(doc, BuiltInCategory.OST_Ramps));
+ cateSet.Insert(Category.GetCategory(doc, BuiltInCategory.OST_Stairs));
+ cateSet.Insert(Category.GetCategory(doc, BuiltInCategory.OST_DuctCurves));
+ cateSet.Insert(Category.GetCategory(doc, BuiltInCategory.OST_PipeCurves));
+ cateSet.Insert(Category.GetCategory(doc, BuiltInCategory.OST_Conduit));
+ cateSet.Insert(Category.GetCategory(doc, BuiltInCategory.OST_CableTray));
+ try
+ {
+ foreach (var parameterElement in parameterElements)
+ {
+ var exist = IsExistProjectParam(doc, parameterElement.Name, out var def, out ElementBinding binding);
+ //存在但未关联到项目信息
+ //if (!foundBinding.Categories.Contains(Category.GetCategory(doc, BuiltInCategory.OST_ProjectInformation)))
+ //{
+ // foundBinding.Categories.Insert(Category.GetCategory(doc, BuiltInCategory.OST_ProjectInformation));
+ // doc.ParameterBindings.ReInsert(firstDef, foundBinding, BuiltInParameterGroup.PG_IDENTITY_DATA);
+ //}
+ if (exist && binding != null)
+ {
+ binding.Categories = cateSet;
+ var res = doc.ParameterBindings.ReInsert(def, binding);
+ }
+ }
+ }
+ catch (Exception)
+ {
+
+ }
+ transaction.Commit();
+ }
+ }
+
+ public bool IsResolveParameter(string paramName)
+ {
+ var array = paramName.Split('-');
+ if (array.Length >= 3)
+ {
+ var prefix = array[0].Trim();
+ if (prefix is ("ID" or "LC" or "ST" or "GJ" or "MF" or "AM" or "FM" or "TM" or "CM" or "TC"))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ ///
+ /// 是否存在该项目参数
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool IsExistProjectParam(Document doc, string paramName, out Definition definition, out ElementBinding binding)
+ {
+ DefinitionBindingMap map = doc.ParameterBindings;
+ var dep = map.ForwardIterator();
+ var isExist = false;
+ binding = null;
+ definition = null;
+ while (dep.MoveNext())
+ {
+ definition = dep.Key;
+
+ if (definition.Name == paramName)
+ {
+ isExist = true;
+ binding = dep.Current as ElementBinding;
+ break;
+ }
+ }
+
+ return isExist;
+ }
+ ///
+ /// 查找共享参数元素的项目参数的定义和绑定
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool TryGetDefinitionBinding(Document doc, SharedParameterElement param, out Definition foundDefinition, out ElementBinding foundBinding, ParameterType pt = ParameterType.Text)
+ {
+ DefinitionBindingMap map = doc.ParameterBindings;
+ var dep = map.ForwardIterator();
+ foundDefinition = null;
+ foundBinding = null;
+ bool isExist = false;
+ while (dep.MoveNext())
+ {
+ foundDefinition = dep.Key;
+ if (foundDefinition is InternalDefinition internalDefinition && internalDefinition.Id == param.GetDefinition().Id && foundDefinition.Name == param.Name)
+ {
+ isExist = true;
+ foundBinding = dep.Current as ElementBinding;
+ }
+ }
+ return isExist;
+ }
+ ///
+ /// 找到同名的项目参数的定义和绑定
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static Dictionary GetDefinitionBindingDic(Document doc, string paramName)
+ {
+ Dictionary dic = new Dictionary();
+ DefinitionBindingMap map = doc.ParameterBindings;
+ var dep = map.ForwardIterator();
+ ElementBinding binding = null;
+ Definition definition = null;
+ while (dep.MoveNext())
+ {
+ definition = dep.Key;
+
+ if (definition.Name == paramName)
+ {
+ binding = dep.Current as ElementBinding;
+ dic.Add(definition, binding);
+ }
+ }
+
+ return dic;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ParameterResolve/ParameterResolve.csproj b/ParameterResolve/ParameterResolve.csproj
new file mode 100644
index 0000000..7e09464
--- /dev/null
+++ b/ParameterResolve/ParameterResolve.csproj
@@ -0,0 +1,17 @@
+
+
+ net472
+ Library
+ 13.0
+ false
+ true
+ true
+ Debug;DefaultBuild;Release
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ParameterResolve/Properties/AssemblyInfo.cs b/ParameterResolve/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..b8e816c
--- /dev/null
+++ b/ParameterResolve/Properties/AssemblyInfo.cs
@@ -0,0 +1,52 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("ParameterResolve")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ParameterResolve")]
+[assembly: AssemblyCopyright("Copyright © 2026")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+//若要开始生成可本地化的应用程序,请设置
+//.csproj 文件中的 CultureYouAreCodingWith
+//在 中。例如,如果你使用的是美国英语。
+//使用的是美国英语,请将 设置为 en-US。 然后取消
+//对以下 NeutralResourceLanguage 特性的注释。 更新
+//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //主题特定资源词典所处位置
+ //(未在页面中找到资源时使用,
+ //或应用程序资源字典中找到时使用)
+ ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
+ //(未在页面中找到资源时使用,
+ //、应用程序或任何主题专用资源字典中找到时使用)
+)]
+
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/ParameterResolve/Properties/Resources.Designer.cs b/ParameterResolve/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..bec011e
--- /dev/null
+++ b/ParameterResolve/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本: 4.0.30319.42000
+//
+// 对此文件的更改可能导致不正确的行为,如果
+// 重新生成代码,则所做更改将丢失。
+//
+//------------------------------------------------------------------------------
+
+namespace ParameterResolve.Properties
+{
+
+
+ ///
+ /// 强类型资源类,用于查找本地化字符串等。
+ ///
+ // 此类是由 StronglyTypedResourceBuilder
+ // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+ // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+ // (以 /str 作为命令选项),或重新生成 VS 项目。
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// 返回此类使用的缓存 ResourceManager 实例。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ParameterResolve.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 重写当前线程的 CurrentUICulture 属性,对
+ /// 使用此强类型资源类的所有资源查找执行重写。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/ParameterResolve/Properties/Resources.resx b/ParameterResolve/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/ParameterResolve/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/ParameterResolve/Properties/Settings.Designer.cs b/ParameterResolve/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..dcb58b1
--- /dev/null
+++ b/ParameterResolve/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace ParameterResolve.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/ParameterResolve/Properties/Settings.settings b/ParameterResolve/Properties/Settings.settings
new file mode 100644
index 0000000..033d7a5
--- /dev/null
+++ b/ParameterResolve/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/RevitAddins/App.cs b/RevitAddins/App.cs
deleted file mode 100644
index d404d32..0000000
--- a/RevitAddins/App.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-
-using System;
-using System.Diagnostics;
-using System.Drawing;
-using System.Linq;
-using System.Net;
-using System.Reflection;
-using System.Text;
-using System.Windows;
-using System.Windows.Interop;
-using System.Windows.Media.Imaging;
-
-using Autodesk.Revit.DB;
-using Autodesk.Revit.UI;
-using Autodesk.Windows;
-
-using Nice3point.Revit.Toolkit.External;
-using Nice3point.Revit.Toolkit.External.Handlers;
-
-using RevitAddins.Properties;
-
-using RibbonButton = Autodesk.Windows.RibbonButton;
-using RibbonPanel = Autodesk.Revit.UI.RibbonPanel;
-
-namespace RevitAddins;
-
-public class App : ExternalApplication
-{
- public override void OnStartup()
- {
- var panel = UiApplication.CreateRibbonPanel("属性表导出");
-
- PushButtonData export =
- new(nameof(ExportSheetsCmd), "导出属性表", GlobalVariables.AddInPath, typeof(ExportSheetsCmd).FullName)
- {
- LargeImage = ToBitmapSource(Resources.xlsx),
- ToolTip = "导出属性表"
- };
- PushButtonData browser =
- new(nameof(BrowserFolderCmd), "模板文件夹", GlobalVariables.AddInPath, typeof(BrowserFolderCmd).FullName)
- {
- LargeImage = ToBitmapSource(Resources.folder),
- ToolTip = "模板文件夹"
- };
- panel.AddItem(export);
- panel.AddItem(browser);
- }
- public static BitmapSource ToBitmapSource(Bitmap bitmap)
- {
- if (bitmap == null)
- {
- return null;
- }
- return Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
- }
- public RibbonControl RibbonControl => ComponentManager.Ribbon;
-
-}
diff --git a/RevitAddins/BrowserFolderCmd.cs b/RevitAddins/BrowserFolderCmd.cs
deleted file mode 100644
index 0843d38..0000000
--- a/RevitAddins/BrowserFolderCmd.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using Autodesk.Revit.Attributes;
-using Autodesk.Revit.UI;
-
-using Nice3point.Revit.Toolkit.External;
-
-namespace RevitAddins
-{
- ///
- /// Revit执行命令
- ///
- [Transaction(TransactionMode.Manual)]
- [Regeneration(RegenerationOption.Manual)]
- internal class BrowserFolderCmd : ExternalCommand
- {
- public override void Execute()
- {
- var path = Path.Combine(GlobalVariables.DirAssembly, "Templates");
- if (Directory.Exists(path))
- {
- Process.Start(path);
- }
- else
- {
- TaskDialog.Show("错误", "指定文件夹不存在!");
- }
- }
- }
-}
diff --git a/RevitAddins/ExportSheetsCmd.cs b/RevitAddins/ExportSheetsCmd.cs
deleted file mode 100644
index 2733a02..0000000
--- a/RevitAddins/ExportSheetsCmd.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-
-using Autodesk.Revit.Attributes;
-
-using Nice3point.Revit.Toolkit.External;
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using System.Threading.Tasks;
-
-namespace RevitAddins
-{
- ///
- /// 属性表导出
- ///
- [Transaction(TransactionMode.Manual)]
- [Regeneration(RegenerationOption.Manual)]
- public class ExportSheetsCmd : ExternalCommand
- {
- public override void Execute()
- {
- MainWindow window = new MainWindow() { DataContext = new MainViewModel(Application) };
- window.ShowDialog();
- }
- }
-}
diff --git a/RevitAddins/Extensions.cs b/RevitAddins/Extensions.cs
deleted file mode 100644
index d8f28a2..0000000
--- a/RevitAddins/Extensions.cs
+++ /dev/null
@@ -1,566 +0,0 @@
-
-
-using Autodesk.Revit.DB;
-using Autodesk.Revit.DB.Architecture;
-
-using RevitAddins;
-
-using System;
-using System.Collections.Generic;
-
-using System.Linq;
-
-namespace RevitAddins;
-
-public static class Extensions
-{
- ///
- /// 文档的收集器
- ///
- ///
- public static FilteredElementCollector OfCollector(this Document document) => document == null ? throw new ArgumentNullException(nameof(document), "文档为空") : new(document);
- public static object GetValue(this Parameter parameter)
- {
- object result = null;
- switch (parameter.StorageType)
- {
- case StorageType.None:
- break;
-
- case StorageType.Integer:
- result = parameter.AsInteger();
- break;
-
- case StorageType.Double:
- result = parameter.AsDouble();
- break;
-
- case StorageType.String:
- //Revit数据库存储的值
- var str = parameter.AsString();
- if (string.IsNullOrEmpty(str))
- {
- //用户可见的前端显示,如根据单位设置而显示的值
- result = parameter.AsValueString();
- }
- else
- {
- result = str;
- }
- break;
-
- case StorageType.ElementId:
- result = parameter.AsElementId();
- break;
- }
-
- return result;
- }
- ///
- /// 类型的元素集合
- ///
- ///
- ///
- ///
- public static FilteredElementCollector QueryElementsByType(this Document doc)
- where T : Element
- {
- return doc.OfCollector().OfClass(typeof(T));
- }
-
- ///
- /// 收集特定类别
- ///
- ///
- ///
- ///
- public static FilteredElementCollector QueryElementsByCategory(this Document doc, BuiltInCategory builtInCategory)
- {
- return doc.OfCollector().OfCategory(builtInCategory);
- }
-
- ///
- /// 收集特定类型
- ///
- ///
- ///
- ///
- ///
- public static FilteredElementCollector QueryElementsByTypeAndCategory(this Document doc, BuiltInCategory builtInCategory)
- where T : Element
- {
- return doc.OfCollector().OfClass(typeof(T)).OfCategory(builtInCategory);
- }
-
- public static FilteredElementCollector OfCollector(this View view)
- {
- //if (view == null)
- //{
- // throw new ArgumentNullException(nameof(view));
- //}
- //if (!view.IsTemplate)
- //{
- // return new FilteredElementCollector(view.doc, view.Id);
- //}
- return FilteredElementCollector.IsViewValidForElementIteration(view.Document, view.Id)
- ? new FilteredElementCollector(view.Document, view.Id)
- : throw new ArgumentException("当前视图不可应用收集器");
- }
-
- ///
- /// 收集当前平面视图的某类图元
- ///
- ///
- ///
- ///
- public static FilteredElementCollector QueryInstancesByType(this View view)
- where T : Element
- {
- return view.OfCollector().OfClass(typeof(T)).WhereElementIsNotElementType();
- }
-
- ///
- /// 收集当前平面视图的某类别图元
- ///
- ///
- ///
- ///
- public static FilteredElementCollector QueryElementsByCategoryInView(this View view, BuiltInCategory builtInCategory)
- {
- return view.OfCollector().OfCategory(builtInCategory).WhereElementIsNotElementType();
- }
-
- ///
- /// 收集当前平面视图的某类图元
- ///
- ///
- ///
- ///
- ///
- public static FilteredElementCollector QueryElementsByTypeAndCategory(this View view, BuiltInCategory builtInCategory)
- where T : Element
- {
- return view.OfCollector().OfClass(typeof(T)).OfCategory(builtInCategory).WhereElementIsNotElementType();
- }
-
-
- ///
- /// 过滤项目文件独立模型元素,包含依附在主体上的元素,如楼板边缘、屋顶边缘、墙饰条、封檐板,檐沟等等
- ///
- /// 元素集合
- public static FilteredElementCollector OfParentModelCollector(this Document doc)
- {
- var col = doc.OfCollector()
- .WhereElementIsNotElementType()
- .Where(
- e => e is TopographySurface ||
- e is DirectShape ||
- e.CanHaveTypeAssigned()
- && e.IsValidObject
- && e.HasPhases()
- && e.ArePhasesModifiable()
- && e.get_BoundingBox(null) != null
- && e.Category is { CategoryType: CategoryType.Model }
- && (e is HostObject || e.Category.Parent == null)
- && e is not Panel
- && e is not Mullion
- && e is not RevitLinkInstance
- ).Select(e => e.Id).ToList();
- if (col.Count == 0)
- {
- return null;
- }
- return new FilteredElementCollector(doc, col).WhereElementIsNotElementType();
- }
-
- ///
- /// 过滤项目文件的所有模型元素
- ///
- /// 元素集合
- public static FilteredElementCollector OfAllModelCollector(this Document doc)
- {
- if (doc == null)
- {
- throw new ArgumentNullException(nameof(doc), "文档为空");
- }
- var col = doc.OfCollector()
- .WhereElementIsNotElementType()
- .Where(
- e => e is TopographySurface ||
- e is DirectShape ||
- e.CanHaveTypeAssigned() &&
- e.IsValidObject &&
- e.HasPhases() &&
- e.ViewSpecific == false &&
- e.Category is { CategoryType: CategoryType.Model, AllowsBoundParameters: true } &&
- e.get_BoundingBox(null) != null &&
- e is not RevitLinkInstance).Select(e => e.Id).ToList();
- if (col.Count == 0)
- {
- return null;
- }
- return new FilteredElementCollector(doc, col).WhereElementIsNotElementType();
- }
- /////
- ///// 获取所有最高层级的模型元素,不包含子模型
- /////
- /////
- /////
- //public static IEnumerable OfModelElements(this Document doc)
- //{
- // return doc.OfCollector()
- // .WhereElementIsNotElementType()
- // .Where(
- // e => e is TopographySurface || (
- // e.CanHaveTypeAssigned()
- // && e.IsValidObject
- // && e.get_BoundingBox(null) != null
- // && e.HasPhases()
- // && e.ViewSpecific == false
- // && e.Category is { Parent: null, CategoryType: CategoryType.Model, AllowsBoundParameters: true }
- // && e is not Panel
- // && e is not Mullion
- // && e is not RevitLinkInstance)
- // );
- //}
- /////
- ///// 所有元素不包括幕墙嵌板,幕墙竖梃、依附图元等等
- /////
- /////
- /////
- //public static FilteredElementCollector OfModelCollector(this Document doc)
- //{
- // if (doc == null)
- // {
- // throw new ArgumentNullException(nameof(doc), "文档为空");
- // }
- // var li = doc.OfCollector().WhereElementIsNotElementType()
- // .Where(
- // e => e is TopographySurface ||
- // (e.CanHaveTypeAssigned() &&
- // e.HasPhases() &&
- // e.Category is { Parent: null, CategoryType: CategoryType.Model } &&
- // e is not Panel &&
- // e is not Mullion &&
- // e is not RevitLinkInstance)).Select(e => e.Id).ToList();
- // return new FilteredElementCollector(doc, li).WhereElementIsNotElementType();
- //}
- ///
- /// 获取对应类型的元素收集器
- ///
- ///
- ///
- ///
- public static IEnumerable OfType(this Document doc)
- where T : Element => doc.OfCollector().OfClass(typeof(T)).OfType();
- public static FilteredElementCollector OfClass(this Document doc)
- where T : Element
- {
- return doc.OfCollector().OfClass(typeof(T));
- }
- ///
- /// 射线法查找所有的Element
- ///
- /// Dcument
- /// 例如:ElementClassFilter filter = new ElementClassFilter(typeof(CableTray))
- /// 目标对象
- /// 射源
- /// 方向
- /// 返回该射线
- public static IList XRayFindAll(
- this Document doc,
- ElementFilter filter,
- FindReferenceTarget targetRef,
- XYZ center,
- XYZ direction
- )
- {
- FilteredElementCollector collector = new(doc);
- Func isNotTemplate = v3 => !v3.IsTemplate;
- var view3D = collector.OfClass(typeof(View3D)).Cast().First(isNotTemplate);
- ReferenceIntersector refIntersector = new(filter, targetRef, view3D);
- var refWithContexts = refIntersector.Find(center, direction);
- if (null == refWithContexts)
- {
- return null;
- }
-
- IList resultElements = [];
- foreach (var rwc in refWithContexts)
- {
- var reference = rwc.GetReference();
- var hitElement = doc.GetElement(reference);
- if (hitElement != null)
- {
- resultElements.Add(hitElement);
- }
- }
-
- return resultElements;
- }
- ///
- /// 获取标高范围框
- ///
- /// 最低标高除了包含以上部分,还包含以下部分,最高标高包含以上部分
- ///
- ///
- public static Dictionary GetLevelRanges(this Document doc)
- {
- var levels = doc.OfType().Cast().OrderBy(l => l.Elevation).ToList();
- Dictionary levelOutlines = [];
- //获取标高范围
- for (var i = 0; i < levels.Count; i++)
- {
- var baseLevel = levels[i];
- XYZ min = new(double.MinValue, double.MinValue, baseLevel.Elevation);
- XYZ max;
- Outline outline;
- if (i == 0)
- {
- min = new XYZ(double.MinValue, double.MinValue, double.MinValue);
- var topLevel = levels[i + 1];
- max = new XYZ(double.MaxValue, double.MaxValue, topLevel.Elevation);
- outline = new Outline(min, max);
- }
- else if (i < levels.Count - 1)
- {
- var topLevel = levels[i + 1];
- max = new XYZ(double.MaxValue, double.MaxValue, topLevel.Elevation);
- outline = new Outline(min, max);
- }
- else//最后一个标高以上
- {
- max = new XYZ(double.MaxValue, double.MaxValue, double.MaxValue);
- outline = new Outline(min, max);
- }
-
- levelOutlines.Add(baseLevel, outline);
- }
-
- return levelOutlines;
- }
-
- ///
- /// 射线法查找最近的Element
- ///
- /// Dcument
- /// 例如:ElementClassFilter filter = new ElementClassFilter(typeof(CableTray))
- /// 目标对象
- /// 射源
- /// 方向
- /// 被击中的Element
- /// 返回该射线
- public static Line XRayFindNearest(
- this Document doc,
- ElementFilter filter,
- FindReferenceTarget targetRef,
- XYZ center,
- XYZ direction,
- ref Element hitElement
- )
- {
- FilteredElementCollector collector = new(doc);
- var view3D = collector.OfClass(typeof(View3D)).Cast().First(v3 => !v3.IsTemplate);
- var rwc = new ReferenceIntersector(filter, targetRef, view3D).FindNearest(center, direction);
- if (null == rwc)
- {
- return null;
- }
-
- var reference = rwc.GetReference();
- var intersection = reference.GlobalPoint;
- hitElement = doc.GetElement(reference);
- Line result = null;
- if (!center.IsAlmostEqualTo(intersection))
- {
- result = Line.CreateBound(center, intersection);
- }
- else
- {
- hitElement = null;
- }
-
- return result;
- }
-
- public static TResult Invoke(this Document doc, Func func, string name = "default")
- {
- using var tr = new Transaction(doc, name);
- tr.Start();
-
- var result = func(tr);
-
- var status = tr.GetStatus();
- switch (status)
- {
- case TransactionStatus.Started:
- tr.Commit();
- return result;
-
- case TransactionStatus.Committed:
- case TransactionStatus.RolledBack:
- return result;
-
- case TransactionStatus.Error:
- tr.RollBack();
- return result;
-
- default:
- return result;
- }
- }
-
- public static TResult InvokeGroup(this Document doc, Func func, string name = "default")
- {
- using var tg = new TransactionGroup(doc, name);
- tg.Start();
-
- var result = func(tg);
-
- var status = tg.GetStatus();
- switch (status)
- {
- case TransactionStatus.Started:
- tg.Assimilate();
- //tr.Commit();
- return result;
-
- case TransactionStatus.Committed:
- case TransactionStatus.RolledBack:
- return result;
-
- case TransactionStatus.Error:
- tg.RollBack();
- return result;
-
- default:
- return result;
- }
- }
-
- public static TResult InvokeSub(this Document doc, Func func)
- {
- using var st = new SubTransaction(doc);
- st.Start();
-
- var result = func(st);
-
- var status = st.GetStatus();
- switch (status)
- {
- case TransactionStatus.Started:
- st.Commit();
- return result;
-
- case TransactionStatus.Committed:
- case TransactionStatus.RolledBack:
- return result;
-
- case TransactionStatus.Error:
- st.RollBack();
- return result;
-
- default:
- return result;
- }
- }
-
- //private static void UsingThisClass(doc doc)
- //{
- // //无返回值
- // doc.Invoke(m => { }, "x");
- // //有返回值
- // doc.Invoke(m =>
- // {
- // return Level.Create(doc, 5);
- // }, "x");
-
- // doc.InvokeGroup(m => { doc.Invoke(mn => { }, "x"); }, "x");
- // doc.InvokeGroup(m => { doc.Invoke(mn => { }, "x"); doc.Invoke(mn => { }, "Y"); return Level.Create(doc, 5); }, "x");
- // doc.InvokeSub(m => { });
- // doc.InvokeSub(m => { return Level.Create(doc, 5); });
- //}
-
- public static void Invoke(this Document doc, Action action, string name = "default")
- {
- using var tr = new Transaction(doc, name);
- tr.Start();
-
- action(tr);
-
- var status = tr.GetStatus();
-
- switch (status)
- {
- case TransactionStatus.Started:
- tr.Commit();
- return;
-
- case TransactionStatus.Committed:
- case TransactionStatus.RolledBack:
- return;
-
- case TransactionStatus.Error:
- tr.RollBack();
- return;
-
- default:
- return;
- }
- }
-
- public static void InvokeGroup(this Document doc, Action action, string name = "default")
- {
- using var tg = new TransactionGroup(doc, name);
- tg.Start();
-
- action(tg);
-
- var status = tg.GetStatus();
- switch (status)
- {
- case TransactionStatus.Started:
- //tr.Commit();
- tg.Assimilate();
- return;
-
- case TransactionStatus.Committed:
- case TransactionStatus.RolledBack:
- break;
-
- case TransactionStatus.Error:
- tg.RollBack();
- return;
-
- default:
- return;
- }
- }
-
- public static void InvokeSub(this Document doc, Action action)
- {
- using var st = new SubTransaction(doc);
- st.Start();
-
- action(st);
-
- var status = st.GetStatus();
- switch (status)
- {
- case TransactionStatus.Started:
- st.Commit();
- return;
-
- case TransactionStatus.Committed:
- case TransactionStatus.RolledBack:
- break;
-
- case TransactionStatus.Error:
- st.RollBack();
- return;
-
- default:
- return;
- }
- }
-}
diff --git a/RevitAddins/FolderBrowserDialog.cs b/RevitAddins/FolderBrowserDialog.cs
deleted file mode 100644
index 1a1e195..0000000
--- a/RevitAddins/FolderBrowserDialog.cs
+++ /dev/null
@@ -1,362 +0,0 @@
-
-using Microsoft.Win32;
-
-using System;
-using System.Runtime.InteropServices;
-using System.Windows;
-
-using System.Windows.Interop;
-
-namespace RevitAddins;
-
-///
-/// Prompts the user to select a folder with a vista style dialog.
-///
-public sealed class FolderBrowserDialog
-{
- #region Properties
-
- ///
- /// Gets or sets the path selected by the user.
- ///
- public string SelectedPath { get; set; }
-
- ///
- /// Gets the name of the element selected by the user.
- ///
- public string SelectedElementName { get; private set; }
-
- ///
- /// Gets an array of paths selected by the user.
- ///
- public string[] SeletcedPaths { get; private set; }
-
- ///
- /// Gets an array of element names selected by the user.
- ///
- public string[] SelectedElementNames { get; private set; }
-
- ///
- /// Gets or sets a valie indicating whether the user is able to select non storage places.
- ///
- public bool AllowNonStoragePlaces { get; set; }
-
- ///
- /// Gets or sets a valie indicating whether the user can select multiple folders or elements.
- ///
- public bool Multiselect { get; set; }
-
- #endregion Properties
-
- #region Public Methods
-
- ///
- /// Shows the dialog with the default owner.
- ///
- /// true if the user clicks OK in the dialog box; otherwise false
- public bool ShowDialog()
- {
- return ShowDialog(IntPtr.Zero);
- }
-
- ///
- /// Shows the dialog with as the owner.
- ///
- /// The owner of the dialog box.
- /// true if the user clicks OK in the dialog box; otherwise false
- public bool ShowDialog(Window owner)
- {
- return ShowDialog(owner == null ? IntPtr.Zero : new WindowInteropHelper(owner).Handle);
- }
-
- ///
- /// Shows the dialog with as the owner.
- ///
- /// The owner of the dialog box.
- /// true if the user clicks OK in the dialog box; otherwise false
- public bool ShowDialog(IWin32Window owner)
- {
- return ShowDialog(owner == null ? IntPtr.Zero : owner.Handle);
- }
-
- ///
- /// Shows the dialog with as the owner.
- ///
- /// The owner of the dialog box.
- /// true if the user clicks OK in the dialog box; otherwise false
- public bool ShowDialog(IntPtr owner)
- {
- if (Environment.OSVersion.Version.Major < 6)
- {
- throw new InvalidOperationException("The dialog need at least Windows Vista to work.");
- }
-
- var dialog = CreateNativeDialog();
- try
- {
- SetInitialFolder(dialog);
- SetOptions(dialog);
-
- if (dialog.Show(owner) != 0)
- {
- return false;
- }
-
- SetDialogResults(dialog);
-
- return true;
- }
- finally
- {
- Marshal.ReleaseComObject(dialog);
- }
- }
-
- #endregion Public Methods
-
- #region Helper
-
- private void GetPathAndElementName(IShellItem item, out string path, out string elementName)
- {
- item.GetDisplayName(SIGDN.PARENTRELATIVEFORADDRESSBAR, out elementName);
- try
- {
- item.GetDisplayName(SIGDN.FILESYSPATH, out path);
- }
- catch (ArgumentException ex) when (ex.HResult == -2147024809)
- {
- path = null;
- }
- }
-
- private IFileOpenDialog CreateNativeDialog()
- {
- return new FileOpenDialog() as IFileOpenDialog;
- }
-
- private void SetInitialFolder(IFileOpenDialog dialog)
- {
- if (!string.IsNullOrEmpty(SelectedPath))
- {
- uint atts = 0;
- if (NativeMethods.SHILCreateFromPath(SelectedPath, out var idl, ref atts) == 0
- && NativeMethods.SHCreateShellItem(IntPtr.Zero, IntPtr.Zero, idl, out var item) == 0)
- {
- dialog.SetFolder(item);
- }
- }
- }
-
- private void SetOptions(IFileOpenDialog dialog)
- {
- dialog.SetOptions(GetDialogOptions());
- }
-
- private FOS GetDialogOptions()
- {
- var options = FOS.PICKFOLDERS;
- if (Multiselect)
- {
- options |= FOS.ALLOWMULTISELECT;
- }
-
- if (!AllowNonStoragePlaces)
- {
- options |= FOS.FORCEFILESYSTEM;
- }
-
- return options;
- }
-
- private void SetDialogResults(IFileOpenDialog dialog)
- {
- IShellItem item;
- if (!Multiselect)
- {
- dialog.GetResult(out item);
- GetPathAndElementName(item, out var path, out var value);
- SelectedPath = path;
- SeletcedPaths = new[] { path };
- SelectedElementName = value;
- SelectedElementNames = new[] { value };
- }
- else
- {
- dialog.GetResults(out var items);
-
- items.GetCount(out var count);
-
- SeletcedPaths = new string[count];
- SelectedElementNames = new string[count];
-
- for (uint i = 0; i < count; ++i)
- {
- items.GetItemAt(i, out item);
- GetPathAndElementName(item, out var path, out var value);
- SeletcedPaths[i] = path;
- SelectedElementNames[i] = value;
- }
-
- SelectedPath = null;
- SelectedElementName = null;
- }
- }
-
- #endregion Helper
-
- #region Types
-
- private class NativeMethods
- {
- [DllImport("shell32.dll")]
- public static extern int SHCreateShellItem(IntPtr pidlParent, IntPtr psfParent, IntPtr pidl, out IShellItem ppsi);
-
- [DllImport("shell32.dll")]
- public static extern int SHILCreateFromPath([MarshalAs(UnmanagedType.LPWStr)] string pszPath, out IntPtr ppIdl, ref uint rgflnOut);
-
- [DllImport("user32.dll")]
- public static extern IntPtr GetActiveWindow();
- }
-
- [ComImport]
- [Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE")]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- private interface IShellItem
- {
- void BindToHandler([In][MarshalAs(UnmanagedType.Interface)] IntPtr pbc, [In] ref Guid bhid, [In] ref Guid riid, out IntPtr ppv);
-
- void GetParent([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
-
- void GetDisplayName([In] SIGDN sigdnName, [MarshalAs(UnmanagedType.LPWStr)] out string ppszName);
-
- void GetAttributes([In] uint sfgaoMask, out uint psfgaoAttribs);
-
- void Compare([In][MarshalAs(UnmanagedType.Interface)] IShellItem psi, [In] uint hint, out int piOrder);
- }
-
- [ComImport]
- [Guid("B63EA76D-1F85-456F-A19C-48159EFA858B")]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- private interface IShellItemArray
- {
- void BindToHandler([In][MarshalAs(UnmanagedType.Interface)] IntPtr pbc, [In] ref Guid rbhid, [In] ref Guid riid, out IntPtr ppvOut);
-
- void GetPropertyStore([In] int Flags, [In] ref Guid riid, out IntPtr ppv);
-
- void GetPropertyDescriptionList([In][MarshalAs(UnmanagedType.Struct)] ref IntPtr keyType, [In] ref Guid riid, out IntPtr ppv);
-
- void GetAttributes([In][MarshalAs(UnmanagedType.I4)] IntPtr dwAttribFlags, [In] uint sfgaoMask, out uint psfgaoAttribs);
-
- void GetCount(out uint pdwNumItems);
-
- void GetItemAt([In] uint dwIndex, [MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
-
- void EnumItems([MarshalAs(UnmanagedType.Interface)] out IntPtr ppenumShellItems);
- }
-
- [ComImport]
- [Guid("d57c7288-d4ad-4768-be02-9d969532d960")]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- [CoClass(typeof(FileOpenDialog))]
- private interface IFileOpenDialog //: IFileDialog
- {
- [PreserveSig]
- int Show([In] IntPtr parent);
-
- void SetFileTypes([In] uint cFileTypes, [In][MarshalAs(UnmanagedType.Struct)] ref IntPtr rgFilterSpec);
-
- void SetFileTypeIndex([In] uint iFileType);
-
- void GetFileTypeIndex(out uint piFileType);
-
- void Advise([In][MarshalAs(UnmanagedType.Interface)] IntPtr pfde, out uint pdwCookie);
-
- void Unadvise([In] uint dwCookie);
-
- void SetOptions([In] FOS fos);
-
- void GetOptions(out FOS pfos);
-
- void SetDefaultFolder([In][MarshalAs(UnmanagedType.Interface)] IShellItem psi);
-
- void SetFolder([In][MarshalAs(UnmanagedType.Interface)] IShellItem psi);
-
- void GetFolder([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
-
- void GetCurrentSelection([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
-
- void SetFileName([In][MarshalAs(UnmanagedType.LPWStr)] string pszName);
-
- void GetFileName([MarshalAs(UnmanagedType.LPWStr)] out string pszName);
-
- void SetTitle([In][MarshalAs(UnmanagedType.LPWStr)] string pszTitle);
-
- void SetOkButtonLabel([In][MarshalAs(UnmanagedType.LPWStr)] string pszText);
-
- void SetFileNameLabel([In][MarshalAs(UnmanagedType.LPWStr)] string pszLabel);
-
- void GetResult([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
-
- void AddPlace([In][MarshalAs(UnmanagedType.Interface)] IShellItem psi, FileDialogCustomPlace fdcp);
-
- void SetDefaultExtension([In][MarshalAs(UnmanagedType.LPWStr)] string pszDefaultExtension);
-
- void Close([MarshalAs(UnmanagedType.Error)] int hr);
-
- void SetClientGuid([In] ref Guid guid);
-
- void ClearClientData();
-
- void SetFilter([MarshalAs(UnmanagedType.Interface)] IntPtr pFilter);
-
- void GetResults([MarshalAs(UnmanagedType.Interface)] out IShellItemArray ppenum);
-
- void GetSelectedItems([MarshalAs(UnmanagedType.Interface)] out IShellItemArray ppSzmedi);
- }
-
- [ComImport]
- [Guid("DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7")]
- private class FileOpenDialog
- {
- }
-
- private enum SIGDN : uint
- {
- DESKTOPABSOLUTEEDITING = 0x8004c000,
- DESKTOPABSOLUTEPARSING = 0x80028000,
- FILESYSPATH = 0x80058000,
- NORMALDISPLAY = 0,
- PARENTRELATIVE = 0x80080001,
- PARENTRELATIVEEDITING = 0x80031001,
- PARENTRELATIVEFORADDRESSBAR = 0x8007c001,
- PARENTRELATIVEPARSING = 0x80018001,
- URL = 0x80068000
- }
-
- [Flags]
- private enum FOS
- {
- ALLNONSTORAGEITEMS = 0x80,
- ALLOWMULTISELECT = 0x200,
- CREATEPROMPT = 0x2000,
- DEFAULTNOMINIMODE = 0x20000000,
- DONTADDTORECENT = 0x2000000,
- FILEMUSTEXIST = 0x1000,
- FORCEFILESYSTEM = 0x40,
- FORCESHOWHIDDEN = 0x10000000,
- HIDEMRUPLACES = 0x20000,
- HIDEPINNEDPLACES = 0x40000,
- NOCHANGEDIR = 8,
- NODEREFERENCELINKS = 0x100000,
- NOREADONLYRETURN = 0x8000,
- NOTESTFILECREATE = 0x10000,
- NOVALIDATE = 0x100,
- OVERWRITEPROMPT = 2,
- PATHMUSTEXIST = 0x800,
- PICKFOLDERS = 0x20,
- SHAREAWARE = 0x4000,
- STRICTFILETYPES = 4
- }
-
- #endregion Types
-}
\ No newline at end of file
diff --git a/RevitAddins/GlobalVariables.cs b/RevitAddins/GlobalVariables.cs
deleted file mode 100644
index 8900d64..0000000
--- a/RevitAddins/GlobalVariables.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-
-using Autodesk.Windows;
-
-using OfficeOpenXml;
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-
-using System.Linq;
-
-using System.Timers;
-
-namespace RevitAddins
-{
- public static class GlobalVariables
- {
- public static IntPtr RevitWindowPtr => ComponentManager.ApplicationWindow;
- public static string AddInPath = typeof(GlobalVariables).Assembly.Location;
- public static string DirAssembly = Path.GetDirectoryName(AddInPath);
- public static Timer Timer { get; } = new();
- public static void TrimLastEmptyRows(this ExcelWorksheet worksheet)
- {
- while (worksheet.IsLastRowEmpty())
- {
- worksheet.DeleteRow(worksheet.Dimension.End.Row, 1);
- }
- }
- public static bool IsLastRowEmpty(this ExcelWorksheet worksheet)
- {
- List empties = [];
-
- for (var index = 1; index <= worksheet.Dimension.End.Column; index++)
- {
- var value = worksheet.Cells[worksheet.Dimension.End.Row, index].Value;
- empties.Add(value == null || string.IsNullOrWhiteSpace(value.ToString()));
- }
-
- return empties.All(e => e);
- }
- }
-}
diff --git a/RevitAddins/License.txt b/RevitAddins/License.txt
deleted file mode 100644
index 80a10a0..0000000
--- a/RevitAddins/License.txt
+++ /dev/null
@@ -1 +0,0 @@
-本插件用于导出Excel属性表二次开发。
\ No newline at end of file
diff --git a/RevitAddins/MainViewModel.cs b/RevitAddins/MainViewModel.cs
deleted file mode 100644
index f8f0c4a..0000000
--- a/RevitAddins/MainViewModel.cs
+++ /dev/null
@@ -1,211 +0,0 @@
-
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Windows;
-
-using Autodesk.Revit.DB;
-using Autodesk.Revit.DB.Architecture;
-
-using CommunityToolkit.Mvvm.ComponentModel;
-using CommunityToolkit.Mvvm.Input;
-
-using EPPlus.Core.Extensions;
-
-using OfficeOpenXml;
-using OfficeOpenXml.Style;
-
-namespace RevitAddins
-{
- public partial class MainViewModel : ObservableObject
- {
- private readonly Autodesk.Revit.ApplicationServices.Application application;
- [ObservableProperty]
- [NotifyCanExecuteChangedFor(nameof(ExportExcelCommand))]
- private FileInfo selectedFileInfo;
- [ObservableProperty]
- private Dictionary excelTemplates;
- public MainViewModel(Autodesk.Revit.ApplicationServices.Application application)
- {
- this.ExcelTemplates = new Dictionary();
- if (Directory.Exists(Path.Combine(GlobalVariables.DirAssembly, "Templates")))
- {
- DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(GlobalVariables.DirAssembly, "Templates"));
- var files = directoryInfo.GetFiles("*.xlsx");
- foreach (var item in files)
- {
- ExcelTemplates.Add(item.Name, item);
- }
- }
-
- this.application = application;
- }
- private bool CanExport()
- {
- if (SelectedFileInfo == null)
- {
- return false;
- }
- return true;
- }
- [RelayCommand(CanExecute = nameof(CanExport))]
- private void ExportExcel()
- {
- StringBuilder sb = new StringBuilder();
- //选择文件夹,并获取文件夹内的所有*.rvt文件
- var folderDialog = new FolderBrowserDialog() { Multiselect = false };
- if (folderDialog.ShowDialog() == false)
- {
- return;
- }
- var path = folderDialog.SelectedPath;
- if (Directory.Exists(path))
- {
- DirectoryInfo directoryInfo = new DirectoryInfo(path);
- var files = directoryInfo.GetFiles("*.rvt");
- foreach (var file in files)
- {
- Document document = null;
-
- try
- {
- document = application.OpenDocumentFile(file.FullName);
- var groups = document.OfParentModelCollector().WhereElementIsNotElementType()
- .GroupBy(e => e.GetParameters("深圳构件标识").FirstOrDefault().AsString());
-
-
- var targetExcelPath = Path.Combine(path, Path.GetFileNameWithoutExtension(document.PathName) + ".xlsx");
- var fileInfo = SelectedFileInfo.CopyTo(targetExcelPath, true);
-
- using var pkg = new ExcelPackage(fileInfo);
- var sheetToDel = new List();
- foreach (var worksheet in pkg.Workbook.Worksheets)
- {
- var elements = groups.FirstOrDefault(g => g.Key == worksheet.Name)?.ToList();
- if (worksheet.Name == "房间")
- {
- elements = [.. document.OfCollector().OfCategory(BuiltInCategory.OST_Rooms).Cast().Where(r => r.Area > 0)];
- }
- if (elements == null || elements.Count == 0)
- {
- sheetToDel.Add(worksheet);
- continue;
- }
- // 获取到第三行的所有单元格的值,转成列号和值的字典
- var range = worksheet.Cells[3, 1, 3, worksheet.Dimension.End.Column];
- var values = new Dictionary();
-
- foreach (var cell in range)
- {
- if (cell.Value != null)
- {
- values[cell.Start.Column] = cell.Text;
- }
- }
-
- for (var i = 0; i < elements.Count; i++)
- {
- var element = elements[i];
- var row = 4 + i;
- foreach (var item in values)
- {
- var parameter = element.GetParameters(item.Value)?.FirstOrDefault(p => p.HasValue);
- if (parameter != null)
- {
- string value = string.Empty;
- switch (parameter.StorageType)
- {
- case StorageType.None:
- break;
-
- case StorageType.Integer:
- value = parameter.AsInteger().ToString();
- break;
-
- case StorageType.Double:
- value = parameter.AsValueString();
- break;
-
- case StorageType.String:
- //Revit数据库存储的值
- var str = parameter.AsString();
- if (string.IsNullOrEmpty(str))
- {
- //用户可见的前端显示,如根据单位设置而显示的值
- value = parameter.AsValueString();
- }
- else
- {
- value = str;
- }
- break;
-
- case StorageType.ElementId:
- value = parameter.AsElementId().ToString();
- break;
- }
-
- worksheet.Cells[row, item.Key].Value = value;
- //单元格宽度自适应
- worksheet.Cells[row, item.Key].AutoFitColumns();
- //单元格样式,边框线,水平居中
- worksheet.Cells[row, item.Key].Style.Border.BorderAround(ExcelBorderStyle.Thin);
- worksheet.Cells[row, item.Key].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
-
-
- }
- //else
- //{
- // MessageBox.Show($"参数{item}不存在!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
- //}
- }
- }
- }
-
- foreach (var item in sheetToDel)
- {
- pkg.Workbook.Worksheets.Delete(item);
- }
- pkg.Save();
- if (document != null)
- {
- document.Close(false);
- }
-
- //var package = Items
- // .ToWorksheet("参数表")
- // .WithConfiguration(cfg => cfg.WithColumnConfiguration(c => c.AutoFit()))
- // .ToExcelPackage();
-
- }
- catch (Exception ex)
- {
- if (document != null)
- {
- document.Close(false);
- }
- sb.AppendLine(ex.Message);
- sb.AppendLine(ex.StackTrace);
- }
- }
- if (sb.Length > 0)
- {
- MessageBox.Show(sb.ToString());
- }
- var result = MessageBox.Show(
- "是否打开文件夹?",
- "提示",
- MessageBoxButton.YesNo,
- MessageBoxImage.Question);
- if (result == MessageBoxResult.Yes)
- {
- Process.Start(path);
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/RevitAddins/MainWindow.xaml b/RevitAddins/MainWindow.xaml
deleted file mode 100644
index 8846a22..0000000
--- a/RevitAddins/MainWindow.xaml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/RevitAddins/MainWindow.xaml.cs b/RevitAddins/MainWindow.xaml.cs
deleted file mode 100644
index dd5c4a5..0000000
--- a/RevitAddins/MainWindow.xaml.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-using Autodesk.Revit.DB;
-
-using EPPlus.Core.Extensions;
-
-using OfficeOpenXml;
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-
-using System.Linq;
-
-using System.Windows;
-
-using System.Windows.Documents;
-
-namespace RevitAddins
-{
- ///
- /// MainWindow.xaml 的交互逻辑
- ///
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/RevitAddins/Properties/AssemblyInfo.cs b/RevitAddins/Properties/AssemblyInfo.cs
deleted file mode 100644
index 2292d4c..0000000
--- a/RevitAddins/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// 有关程序集的一般信息由以下
-// 控制。更改这些特性值可修改
-// 与程序集关联的信息。
-[assembly: AssemblyTitle("RevitAddins")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("RevitAddins")]
-[assembly: AssemblyCopyright("Copyright © 2025")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 将 ComVisible 设置为 false 会使此程序集中的类型
-//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
-//请将此类型的 ComVisible 特性设置为 true。
-[assembly: ComVisible(false)]
-
-// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
-[assembly: Guid("985886d3-5c16-4b4a-8971-28c635adc035")]
-
-// 程序集的版本信息由下列四个值组成:
-//
-// 主版本
-// 次版本
-// 生成号
-// 修订号
-//
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/RevitAddins/Resources/folder.png b/RevitAddins/Resources/folder.png
deleted file mode 100644
index 99f782e..0000000
Binary files a/RevitAddins/Resources/folder.png and /dev/null differ
diff --git a/RevitAddins/Resources/xlsx.png b/RevitAddins/Resources/xlsx.png
deleted file mode 100644
index 4699791..0000000
Binary files a/RevitAddins/Resources/xlsx.png and /dev/null differ
diff --git a/RevitAddins/RevitAddins.csproj b/RevitAddins/RevitAddins.csproj
deleted file mode 100644
index 1d2154b..0000000
--- a/RevitAddins/RevitAddins.csproj
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
- net48
- Library
- True
- false
- 13.0
- Debug;Release
- false
-
-
-
-
-
-
-
-
-
-
-
- True
- True
- Resources.resx
-
-
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
-
\ No newline at end of file
diff --git a/RevitAddins/RevitAddins.iss b/RevitAddins/RevitAddins.iss
deleted file mode 100644
index d0b78e6..0000000
--- a/RevitAddins/RevitAddins.iss
+++ /dev/null
@@ -1,60 +0,0 @@
-; 脚本由 Inno Setup 脚本向导生成。
-; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
-
-; 定义应用程序的名称
-#define MyAppName "RevitAddins"
-; 定义应用程序的版本号
-#define MyAppVersion "1.0.0.0"
-; 定义应用程序的发布者
-#define MyAppPublisher "Zhanggg"
-; 定义应用程序的网址
-#define MyAppURL "https://www.shrlalgo.cn/"
-; 定义应用程序的可执行文件名
-#define MyAppExeName "RevitAddins.exe"
-#define MyDllName "RevitAddins"
-
-[Setup]
-; 注意:AppId 的值唯一标识此应用程序。不要在其他应用程序的安装程序中使用相同的 AppId 值。
-; (若要生成新的 GUID,请在 IDE 中单击 "工具|生成 GUID"。)
-AppId={{5DCDD684-EFA0-4CC7-8155-58A84E85A04F}
-; 程序名称
-AppName={#MyAppName}
-; 版本
-AppVersion={#MyAppVersion}
-; AppVerName={#MyAppName} {#MyAppVersion}
-AppPublisher={#MyAppPublisher}
-AppPublisherURL={#MyAppURL}
-AppSupportURL={#MyAppURL}
-AppUpdatesURL={#MyAppURL}
-;控制面板显示的名称
-UninstallDisplayName={#MyAppName}
-;安装包构建模型
-ArchitecturesInstallIn64BitMode=x64os
-;管理员权限
-PrivilegesRequired=admin
-; 是否创建应用程序目录
-CreateAppDir=no
-; 许可证文件路径
-LicenseFile=.\bin\Debug\License.txt
-InfoBeforeFile=.\bin\Debug\License.txt
-InfoAfterFile=.\bin\Debug\License.txt
-; 取消对以下行的注释以在非管理安装模式下运行(仅针对当前用户进行安装)。
-; PrivilegesRequired=lowest
-; exe输出目录
-OutputDir=.\Setup
-; 输出文件名
-OutputBaseFilename={#MyAppName}
-; 密码
-;Password=SZMEDI
-; 是否加密
-;Encryption=yes
-; 压缩方式
-Compression=lzma
-; 是否使用固体压缩
-SolidCompression=yes
-; 向导样式
-WizardStyle=modern
-
-[Files]
-Source: ".\bin\Debug\*"; DestDir: "C:\ProgramData\Autodesk\Revit\Addins\2020\RevitAddins"; Flags: ignoreversion recursesubdirs createallsubdirs
-Source: ".\bin\RevitAddins.addin"; DestDir: "C:\ProgramData\Autodesk\Revit\Addins\2020"; Flags: ignoreversion
\ No newline at end of file
diff --git a/RevitAddins/Setup/RevitAddins.exe b/RevitAddins/Setup/RevitAddins.exe
deleted file mode 100644
index d28b28c..0000000
Binary files a/RevitAddins/Setup/RevitAddins.exe and /dev/null differ
diff --git a/RevitAddins/Templates/市政.xlsx b/RevitAddins/Templates/市政.xlsx
deleted file mode 100644
index 3b5471f..0000000
Binary files a/RevitAddins/Templates/市政.xlsx and /dev/null differ
diff --git a/RevitAddins/Templates/建筑.xlsx b/RevitAddins/Templates/建筑.xlsx
deleted file mode 100644
index 0869c92..0000000
Binary files a/RevitAddins/Templates/建筑.xlsx and /dev/null differ
diff --git a/RevitAddins/Templates/结构.xlsx b/RevitAddins/Templates/结构.xlsx
deleted file mode 100644
index 0c1fb0e..0000000
Binary files a/RevitAddins/Templates/结构.xlsx and /dev/null differ
diff --git a/Szmedi.CADkits/Properties/AssemblyInfo.cs b/Szmedi.CADkits/Properties/AssemblyInfo.cs
deleted file mode 100644
index bc6dc3b..0000000
--- a/Szmedi.CADkits/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// 有关程序集的一般信息由以下
-// 控制。更改这些特性值可修改
-// 与程序集关联的信息。
-[assembly: AssemblyTitle("Szmedi.CADkits")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Szmedi.CADkits")]
-[assembly: AssemblyCopyright("Copyright © 2025")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 将 ComVisible 设置为 false 会使此程序集中的类型
-//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
-//请将此类型的 ComVisible 特性设置为 true。
-[assembly: ComVisible(false)]
-
-// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
-[assembly: Guid("a8343f78-b04d-4c75-bde3-8133314b5597")]
-
-// 程序集的版本信息由下列四个值组成:
-//
-// 主版本
-// 次版本
-// 生成号
-// 修订号
-//
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Szmedi.CADkits/ReviewAndMatchWindow.xaml b/Szmedi.CADkits/ReviewAndMatchWindow.xaml
index 6685377..50407dd 100644
--- a/Szmedi.CADkits/ReviewAndMatchWindow.xaml
+++ b/Szmedi.CADkits/ReviewAndMatchWindow.xaml
@@ -17,9 +17,8 @@
-
-
+ Text="双击列表项可定位并选中块。使用“手动匹配”按钮可重新指定标高。"
+ TextWrapping="Wrap" />
+ Content="定位选中"
+ ToolTip="选择点的块,快速定位到列表中的位置" />
+ FontWeight="Bold"
+ ToolTip="选中列表中的行,选择文字,手动匹配" />
-
+ Content="隐藏面板" />-->
\ No newline at end of file
diff --git a/Szmedi.CADkits/ReviewAndMatchWindow.xaml.cs b/Szmedi.CADkits/ReviewAndMatchWindow.xaml.cs
index 28537c7..89b71c3 100644
--- a/Szmedi.CADkits/ReviewAndMatchWindow.xaml.cs
+++ b/Szmedi.CADkits/ReviewAndMatchWindow.xaml.cs
@@ -87,9 +87,12 @@ namespace Szmedi.CADkits
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
-
- // 通过控制父面板来隐藏
- _parentPalette.Visible = false;
+ if (_parentPalette.Dock == DockSides.None)
+ {
+ // 通过控制父面板来隐藏
+ _parentPalette.Visible = false;
+ }
+ MatchButton.IsEnabled = false;
try
{
@@ -111,8 +114,13 @@ namespace Szmedi.CADkits
}
finally
{
- // 操作结束后,重新显示父面板
- _parentPalette.Visible = true;
+ if (_parentPalette.Dock == DockSides.None)
+ {
+ // 操作结束后,重新显示父面板
+ _parentPalette.Visible = true;
+ }
+ MatchButton.IsEnabled = true;
+
}
}
@@ -160,14 +168,18 @@ namespace Szmedi.CADkits
}
}
- private void CloseButton_Click(object sender, RoutedEventArgs e)
- {
- _parentPalette.Visible = false;
- }
+ //private void CloseButton_Click(object sender, RoutedEventArgs e)
+ //{
+ // _parentPalette.Visible = false;
+ //}
// 辅助方法:缩放到实体
private void ZoomToEntity(ObjectId entId)
{
+ if (!entId.IsValid)
+ {
+ return;
+ }
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
if (doc == null) return;
Editor ed = doc.Editor;
@@ -241,8 +253,8 @@ namespace Szmedi.CADkits
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
ObjectId targetId = ObjectId.Null;
-
_isListeningToSelection = false; // 暂时关闭自动监听,避免冲突
+ LocateInListButton.IsEnabled = false;
try
{
@@ -255,8 +267,16 @@ namespace Szmedi.CADkits
}
else
{
- // 2. 如果没有选中,则提示用户去选择
- _parentPalette.Visible = false; // 隐藏面板方便用户选择
+ if (_parentPalette.Dock == DockSides.None)
+ {
+ // 2. 如果没有选中,则提示用户去选择
+ _parentPalette.Visible = false; // 隐藏面板方便用户选择
+ }
+ else
+ {
+ LocateInListButton.IsEnabled = false;
+ }
+
PromptEntityOptions peo = new PromptEntityOptions("\n请在图中选择一个地形点块进行定位: ");
peo.SetRejectMessage("\n选择的不是块参照。");
@@ -279,7 +299,13 @@ namespace Szmedi.CADkits
{
// 4. 无论如何都恢复UI状态
_isListeningToSelection = true; // 重新开启监听
- _parentPalette.Visible = true;
+ if (_parentPalette.Dock == DockSides.None)
+ {
+ // 操作结束后,重新显示父面板
+ _parentPalette.Visible = true;
+ }
+ LocateInListButton.IsEnabled = true;
+
this.Focus();
}
}
diff --git a/Szmedi.CADkits/SpatialExtractCommand.cs b/Szmedi.CADkits/SpatialExtractCommand.cs
index 59d941a..f2d8711 100644
--- a/Szmedi.CADkits/SpatialExtractCommand.cs
+++ b/Szmedi.CADkits/SpatialExtractCommand.cs
@@ -10,7 +10,7 @@ using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
-using Newtonsoft.Json;
+//using Newtonsoft.Json;
namespace BoreholeTool
{
@@ -146,10 +146,12 @@ namespace BoreholeTool
}
// 输出
- string json = JsonConvert.SerializeObject(finalLogs, Formatting.Indented);
- string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "BoreholeHybrid.json");
- File.WriteAllText(path, json);
- ed.WriteMessage($"\n处理完成!共 {finalLogs.Count} 个钻孔。文件: {path}");
+ #region Json
+ //string json = JsonConvert.SerializeObject(finalLogs, Formatting.Indented);
+ //string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "BoreholeHybrid.json");
+ //File.WriteAllText(path, json);
+ //ed.WriteMessage($"\n处理完成!共 {finalLogs.Count} 个钻孔。文件: {path}");
+ #endregion
}
// ----------------------------------------------------------------
diff --git a/Szmedi.CADkits/Szmedi.CADkits.csproj b/Szmedi.CADkits/Szmedi.CADkits.csproj
index 4236e57..fb985b9 100644
--- a/Szmedi.CADkits/Szmedi.CADkits.csproj
+++ b/Szmedi.CADkits/Szmedi.CADkits.csproj
@@ -7,7 +7,16 @@
10.0
True
Debug;DefaultBuild;Release
+ True
False
+
+
+ Szmedi.CADkits
+ $(AssemblyName)
+ Szmedi
+ 2.0.0.0
+ $(AssemblyVersion)
+ $(AssemblyVersion)
@@ -18,6 +27,8 @@
1.0.0
-
+
+
+
\ No newline at end of file
diff --git a/Szmedi.RvKits.sln b/Szmedi.RvKits.sln
index db70863..873b56e 100644
--- a/Szmedi.RvKits.sln
+++ b/Szmedi.RvKits.sln
@@ -22,16 +22,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Szmedi.AIScriptRunner", "Sz
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeologyToolkit", "GeologyToolkit\GeologyToolkit.csproj", "{91219472-86E9-9135-3F20-915D63EFC7D1}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitAddins", "RevitAddins\RevitAddins.csproj", "{985886D3-5C16-4B4A-8971-28C635ADC035}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvdLiteSnoop", "MvdLiteSnoop\MvdLiteSnoop.csproj", "{5845A999-9AEC-4787-9EBC-B1D176E37D6C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Szmedi.CADkits", "Szmedi.CADkits\Szmedi.CADkits.csproj", "{A8343F78-B04D-4C75-BDE3-8133314B5597}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebUITest", "WebUITest\WebUITest.csproj", "{976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BoreholeExtract", "BoreholeExtract\BoreholeExtract.csproj", "{BBB28329-D187-48B6-BA11-C2DFBA96FDD6}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeyGen", "KeyGen\KeyGen.csproj", "{C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParameterResolve", "ParameterResolve\ParameterResolve.csproj", "{F37AC122-0C1F-4481-8762-F3E043501CB5}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -153,24 +153,6 @@ Global
{91219472-86E9-9135-3F20-915D63EFC7D1}.Release|x64.Build.0 = Release|Any CPU
{91219472-86E9-9135-3F20-915D63EFC7D1}.Release|x86.ActiveCfg = Release|Any CPU
{91219472-86E9-9135-3F20-915D63EFC7D1}.Release|x86.Build.0 = Release|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.Debug|x64.ActiveCfg = Debug|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.Debug|x64.Build.0 = Debug|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.Debug|x86.ActiveCfg = Debug|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.Debug|x86.Build.0 = Debug|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.DefaultBuild|Any CPU.ActiveCfg = Release|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.DefaultBuild|Any CPU.Build.0 = Release|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.DefaultBuild|x64.ActiveCfg = Release|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.DefaultBuild|x64.Build.0 = Release|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.DefaultBuild|x86.ActiveCfg = Release|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.DefaultBuild|x86.Build.0 = Release|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.Release|Any CPU.Build.0 = Release|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.Release|x64.ActiveCfg = Release|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.Release|x64.Build.0 = Release|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.Release|x86.ActiveCfg = Release|Any CPU
- {985886D3-5C16-4B4A-8971-28C635ADC035}.Release|x86.Build.0 = Release|Any CPU
{5845A999-9AEC-4787-9EBC-B1D176E37D6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5845A999-9AEC-4787-9EBC-B1D176E37D6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5845A999-9AEC-4787-9EBC-B1D176E37D6C}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -207,24 +189,6 @@ Global
{A8343F78-B04D-4C75-BDE3-8133314B5597}.Release|x64.Build.0 = Release|Any CPU
{A8343F78-B04D-4C75-BDE3-8133314B5597}.Release|x86.ActiveCfg = Release|Any CPU
{A8343F78-B04D-4C75-BDE3-8133314B5597}.Release|x86.Build.0 = Release|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.Debug|x64.ActiveCfg = Debug|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.Debug|x64.Build.0 = Debug|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.Debug|x86.ActiveCfg = Debug|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.Debug|x86.Build.0 = Debug|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.DefaultBuild|Any CPU.ActiveCfg = Release|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.DefaultBuild|Any CPU.Build.0 = Release|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.DefaultBuild|x64.ActiveCfg = Release|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.DefaultBuild|x64.Build.0 = Release|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.DefaultBuild|x86.ActiveCfg = Release|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.DefaultBuild|x86.Build.0 = Release|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.Release|Any CPU.Build.0 = Release|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.Release|x64.ActiveCfg = Release|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.Release|x64.Build.0 = Release|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.Release|x86.ActiveCfg = Release|Any CPU
- {976F4EE6-7EFC-AFBF-BC2D-C15F273A38C1}.Release|x86.Build.0 = Release|Any CPU
{BBB28329-D187-48B6-BA11-C2DFBA96FDD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBB28329-D187-48B6-BA11-C2DFBA96FDD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBB28329-D187-48B6-BA11-C2DFBA96FDD6}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -243,6 +207,42 @@ Global
{BBB28329-D187-48B6-BA11-C2DFBA96FDD6}.Release|x64.Build.0 = Release|Any CPU
{BBB28329-D187-48B6-BA11-C2DFBA96FDD6}.Release|x86.ActiveCfg = Release|Any CPU
{BBB28329-D187-48B6-BA11-C2DFBA96FDD6}.Release|x86.Build.0 = Release|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.Debug|x64.Build.0 = Debug|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.Debug|x86.Build.0 = Debug|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.DefaultBuild|Any CPU.ActiveCfg = Release|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.DefaultBuild|Any CPU.Build.0 = Release|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.DefaultBuild|x64.ActiveCfg = Release|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.DefaultBuild|x64.Build.0 = Release|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.DefaultBuild|x86.ActiveCfg = Release|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.DefaultBuild|x86.Build.0 = Release|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.Release|x64.ActiveCfg = Release|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.Release|x64.Build.0 = Release|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.Release|x86.ActiveCfg = Release|Any CPU
+ {C3A385A3-EDE1-C0F9-052D-59C1B0CFDF8D}.Release|x86.Build.0 = Release|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.Debug|x64.Build.0 = Debug|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.Debug|x86.Build.0 = Debug|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.DefaultBuild|Any CPU.ActiveCfg = Release|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.DefaultBuild|Any CPU.Build.0 = Release|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.DefaultBuild|x64.ActiveCfg = Release|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.DefaultBuild|x64.Build.0 = Release|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.DefaultBuild|x86.ActiveCfg = Release|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.DefaultBuild|x86.Build.0 = Release|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.Release|x64.ActiveCfg = Release|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.Release|x64.Build.0 = Release|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.Release|x86.ActiveCfg = Release|Any CPU
+ {F37AC122-0C1F-4481-8762-F3E043501CB5}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Szmedi.RvKits/InfoManager/EAMTools/EAMCodeCheckViewModel.cs b/Szmedi.RvKits/InfoManager/EAMTools/EAMCodeCheckViewModel.cs
index fb6bf3d..1774d15 100644
--- a/Szmedi.RvKits/InfoManager/EAMTools/EAMCodeCheckViewModel.cs
+++ b/Szmedi.RvKits/InfoManager/EAMTools/EAMCodeCheckViewModel.cs
@@ -53,9 +53,9 @@ namespace Szmedi.RvKits.InfoManager.EAMTools
SelectedStation = result;
}
}
- catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException)
+ catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException ex)
{
- MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行。");
+ MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行或多余文字。", ex.Message);
}
finally
{
diff --git a/Szmedi.RvKits/InfoManager/EAMTools/EAMCodingViewModel.cs b/Szmedi.RvKits/InfoManager/EAMTools/EAMCodingViewModel.cs
index af34722..c6fa658 100644
--- a/Szmedi.RvKits/InfoManager/EAMTools/EAMCodingViewModel.cs
+++ b/Szmedi.RvKits/InfoManager/EAMTools/EAMCodingViewModel.cs
@@ -192,9 +192,9 @@ public partial class EAMCodingViewModel : ObservableObject
IsComparison = false;
Instances.ForEach(ins => ins.IsMapped = false);
}
- catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException)
+ catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException ex)
{
- System.Windows.MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行。");
+ System.Windows.MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行或多余文字。", ex.Message);
}
finally
{
@@ -525,9 +525,9 @@ public partial class EAMCodingViewModel : ObservableObject
LogAssists.WriteTxtFile("EAM编码写入失败", sb.ToString());
}
}
- catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException)
+ catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException ex)
{
- System.Windows.MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行。");
+ System.Windows.MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行或多余文字。", ex.Message);
}
finally
{
diff --git a/Szmedi.RvKits/InfoManager/PropEditor/WriteParametersViewModel.cs b/Szmedi.RvKits/InfoManager/PropEditor/WriteParametersViewModel.cs
index 0f70fb2..f0fbb6d 100644
--- a/Szmedi.RvKits/InfoManager/PropEditor/WriteParametersViewModel.cs
+++ b/Szmedi.RvKits/InfoManager/PropEditor/WriteParametersViewModel.cs
@@ -319,9 +319,9 @@ public partial class WriteParametersViewModel : ObservableObject
//IsComparison = false;
//Instances.ForEach(ins => ins.IsMapped = false);
}
- catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException)
+ catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException ex)
{
- System.Windows.MessageBox.Show("列名不存在或不匹配或检查表头是否存在换行。");
+ System.Windows.MessageBox.Show("列名不存在或不匹配或检查表头是否存在换行或多余文字。", ex.Message);
}
finally
{
diff --git a/Szmedi.RvKits/MEPTools/FacilityInfoProcessCmd.cs b/Szmedi.RvKits/MEPTools/FacilityInfoProcessCmd.cs
index eeba853..8630c12 100644
--- a/Szmedi.RvKits/MEPTools/FacilityInfoProcessCmd.cs
+++ b/Szmedi.RvKits/MEPTools/FacilityInfoProcessCmd.cs
@@ -14,6 +14,9 @@ namespace Szmedi.RvKits.MEPTools
{
public override void Execute()
{
+#if DEBUG
+ GlobalVariables.UIApplication=this.UiApplication;
+#endif
WinDialogAssists.ShowOrActivate();
}
}
diff --git a/Szmedi.RvKits/MEPTools/FacilityInfoProcessView.xaml b/Szmedi.RvKits/MEPTools/FacilityInfoProcessView.xaml
index a3dd329..f4141e5 100644
--- a/Szmedi.RvKits/MEPTools/FacilityInfoProcessView.xaml
+++ b/Szmedi.RvKits/MEPTools/FacilityInfoProcessView.xaml
@@ -9,8 +9,8 @@
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="设备信息"
- Width="800"
- Height="450"
+ Width="900"
+ Height="600"
d:DataContext="{d:DesignInstance Type=local:FacilityInfoProcessViewModel}"
mc:Ignorable="d">
@@ -34,13 +34,15 @@
-
+
-
+
-
-
-
+
+
+
-
-
-
-
-
+
+
@@ -87,9 +84,10 @@
-
-
-
+
";
- // var jsInjected = $"";
-
- // // 确保注入 CSS
- // int headEndIndex = htmlContent.IndexOf("");
- // if (headEndIndex >= 0)
- // {
- // htmlContent = htmlContent.Insert(headEndIndex, cssInjected);
- // }
-
- // // 确保注入 JS,通常放在
或
- var jsTag = $"";
- htmlContent = htmlContent.Replace("", $"{jsTag} 前
- // int bodyEndIndex = htmlContent.IndexOf("");
- // if (bodyEndIndex >= 0)
- // {
- // htmlContent = htmlContent.Insert(bodyEndIndex, jsInjected);
- // }
-
- // return htmlContent;
- //}
-
- private string InjectCssAndJs(string htmlContent, string cssContent, string jsContent)
- {
- // 注入 CSS 到
- var cssTag = $"";
- htmlContent = htmlContent.Replace("", $"{cssTag}");
-
- // 注入 JS 到
");
-
- return htmlContent;
- }
- private string GetEmbeddedResource(string resourceName)
- {
- var assembly = Assembly.GetExecutingAssembly();
- using (Stream stream = assembly.GetManifestResourceStream(resourceName))
- using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
- {
- return reader.ReadToEnd();
- }
- }
-
- private void WebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e)
- {
- string json = e.WebMessageAsJson;
- dynamic data = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
- string newTag = data.newTag;
- ApplyTagToWalls(newTag);
- }
-
- private void ApplyTagToWalls(string tagValue)
- {
- // 执行墙标记批量修改操作
- Document doc = _uiDoc.Document;
- var walls = new FilteredElementCollector(doc)
- .OfCategory(BuiltInCategory.OST_Walls)
- .WhereElementIsNotElementType()
- .Cast()
- .ToList();
-
- using (Transaction tx = new Transaction(doc, "批量修改墙标记"))
- {
- tx.Start();
- foreach (var wall in walls)
- {
- Parameter p = wall.get_Parameter(BuiltInParameter.ALL_MODEL_MARK);
- if (p != null && !p.IsReadOnly)
- p.Set(tagValue);
- }
- tx.Commit();
- }
-
- MessageBox.Show($"共修改 {walls.Count} 面墙的标记为 '{tagValue}'。", "完成", MessageBoxButton.OK, MessageBoxImage.Information);
- }
- }
-}
diff --git a/WebUITest/background.avif b/WebUITest/background.avif
deleted file mode 100644
index 0328316..0000000
Binary files a/WebUITest/background.avif and /dev/null differ