From 74532b77be929b57d33fde8067daedba4f9527ec Mon Sep 17 00:00:00 2001 From: GG Z <903524121@qq.com> Date: Mon, 5 May 2025 17:03:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ShrlAlgo.Addin.Test/CheckCollision.cs | 93 ----------------- ShrlAlgo.Addin.Test/InsertInfo.cs | 12 --- ShrlAlgo.Addin.Test/SeparateModel.cs | 20 ---- ShrlAlgo.Addin.Test/SeparateModelWin.xaml | 31 ------ ShrlAlgo.Addin.Test/SeparateModelWin.xaml.cs | 99 ------------------- ShrlAlgo.Addin.Test/SetHeight.cs | 50 ---------- .../ModelManager}/RemoveParamCmd.cs | 0 .../Services/Contracts/IWindow.cs | 13 --- WPFluent/Controls/ControlsServices.cs | 27 ----- 9 files changed, 345 deletions(-) delete mode 100644 ShrlAlgo.Addin.Test/CheckCollision.cs delete mode 100644 ShrlAlgo.Addin.Test/InsertInfo.cs delete mode 100644 ShrlAlgo.Addin.Test/SeparateModel.cs delete mode 100644 ShrlAlgo.Addin.Test/SeparateModelWin.xaml delete mode 100644 ShrlAlgo.Addin.Test/SeparateModelWin.xaml.cs delete mode 100644 ShrlAlgo.Addin.Test/SetHeight.cs rename {ShrlAlgo.Addin.Test => ShrlAlgoToolkit.RevitAddins/ModelManager}/RemoveParamCmd.cs (100%) delete mode 100644 WPFluent.Gallery/Services/Contracts/IWindow.cs delete mode 100644 WPFluent/Controls/ControlsServices.cs diff --git a/ShrlAlgo.Addin.Test/CheckCollision.cs b/ShrlAlgo.Addin.Test/CheckCollision.cs deleted file mode 100644 index 66e6991..0000000 --- a/ShrlAlgo.Addin.Test/CheckCollision.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System.IO; -using System.Text; - -using Autodesk.Revit.Attributes; -using Autodesk.Revit.DB; -using Autodesk.Revit.UI; - -namespace ShrlAlgo.Addin.Test -{ - [Transaction(TransactionMode.Manual)] - [Regeneration(RegenerationOption.Manual)] - internal class CheckCollision : IExternalCommand - { - public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) - { - //程序UI界面 - var uiapp = commandData.Application; - //获取元素(选择) 显示元素 视图(活动视图)管理(对象) - var uidoc = uiapp.ActiveUIDocument; - //获取位置和场地 视图(多个视图)管理 获取元素(Revit 项目里的全部元素) - var doc = uidoc.Document; - //当前视图 - var view = doc.ActiveView; - var collector = new FilteredElementCollector(doc, view.Id) - .OfClass(typeof(MEPCurve)) - .WhereElementIsNotElementType().ToList(); - // 检查管线之间的碰撞 - var collisions = CheckPipeCollisionsParallel(doc, collector); - - // 显示碰撞结果 - ShowCollisionResults(collisions); - return Result.Succeeded; - } - public List> CheckPipeCollisionsParallel(Document doc, List pipes) - { - var collisions = new List>(); - // 使用 Parallel.For 并行检查碰撞 - Parallel.For(0, pipes.Count, i => - { - for (var j = i + 1; j < pipes.Count; j++) - { - var pipe1 = pipes[i]; - var pipe2 = pipes[j]; - - // 使用 ElementIntersectsElementFilter 检查碰撞 - var filter = new ElementIntersectsElementFilter(pipe1); - var collector = new FilteredElementCollector(doc, [pipe2.Id]); - collector.WherePasses(filter); - - if (collector.Any()) - { - // 如果检测到碰撞,记录下来 - lock (collisions) - { - collisions.Add(new Tuple(pipe1, pipe2)); - } - } - } - }); - - return collisions; - } - public void ShowCollisionResults(List> collisions) - { - if (collisions.Count == 0) - { - TaskDialog.Show("碰撞检查", "未发现碰撞"); - } - else - { - var message = new StringBuilder(); - message.AppendLine("发现碰撞:"); - foreach (var collision in collisions) - { - message.AppendLine($"管线 {collision.Item1.Id} 与管线 {collision.Item2.Id} 发生碰撞"); - } - ExportCollisionResultsToFile(message.ToString()); - //TaskDialog.Show("碰撞检查", message.ToString()); - } - } - public void ExportCollisionResultsToFile(string content) - { - // 获取桌面路径 - var desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); - - // 创建文件路径 - var filePath = Path.Combine(desktopPath, "碰撞检查.txt"); - - // 写入文件 - File.WriteAllText(filePath, content); - } - } -} diff --git a/ShrlAlgo.Addin.Test/InsertInfo.cs b/ShrlAlgo.Addin.Test/InsertInfo.cs deleted file mode 100644 index ee4eb6d..0000000 --- a/ShrlAlgo.Addin.Test/InsertInfo.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Autodesk.Revit.DB; - -namespace ShrlAlgo.Addin.Test; - -public class InsertInfo -{ - - public string Name { get; set; } - public XYZ InsertPoint { get; set; } - public double Radian { get; set; } - public double Length { get; set; } -} \ No newline at end of file diff --git a/ShrlAlgo.Addin.Test/SeparateModel.cs b/ShrlAlgo.Addin.Test/SeparateModel.cs deleted file mode 100644 index d08d55e..0000000 --- a/ShrlAlgo.Addin.Test/SeparateModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; - -using Autodesk.Revit.Attributes; -using Autodesk.Revit.DB; -using Autodesk.Revit.UI; -using Autodesk.Revit.UI.Selection; - -using Nice3point.Revit.Toolkit.External; - -namespace ShrlAlgo.Addin.Test; -[Transaction(TransactionMode.Manual)] -[Regeneration(RegenerationOption.Manual)] -public class SeparateModel : ExternalCommand -{ - public override void Execute() - { - SeparateModelWin win = new SeparateModelWin(); - win.Show(); - } -} \ No newline at end of file diff --git a/ShrlAlgo.Addin.Test/SeparateModelWin.xaml b/ShrlAlgo.Addin.Test/SeparateModelWin.xaml deleted file mode 100644 index 6b9477e..0000000 --- a/ShrlAlgo.Addin.Test/SeparateModelWin.xaml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - diff --git a/ShrlAlgo.Addin.Test/SeparateModelWin.xaml.cs b/ShrlAlgo.Addin.Test/SeparateModelWin.xaml.cs deleted file mode 100644 index bd4d1ab..0000000 --- a/ShrlAlgo.Addin.Test/SeparateModelWin.xaml.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.IO; -using System.Windows; - -using Autodesk.Revit.DB; - -using Nice3point.Revit.Toolkit.External.Handlers; -using ShrlAlgoToolkit.Revit.Assists; -using Exception = System.Exception; - -using UIFrameworkServices; - -namespace ShrlAlgo.Addin.Test; -/// -/// SeparateModelWin.xaml 的交互逻辑 -/// -public partial class SeparateModelWin -{ - ActionEventHandler separate = new ActionEventHandler(); - public SeparateModelWin() - { - InitializeComponent(); - TbFolder.Text = "F:\\燃气改造项目\\归档"; - } - - private void MetroButton_Click(object sender, RoutedEventArgs e) - { - separate.Raise( - uiapp => - { - - var uidoc = uiapp.ActiveUIDocument; - var doc = uidoc.Document; - var list = uidoc.Selection.GetElementIds(); - - if (list.Count == 0) - { - MessageBox.Show("未选中元素", "提示"); - return; - } - var walls = list.Select(id => doc.GetElement(id)).Where(e => e is Wall).Select(e => e.Id).ToList(); - var others = list.Select(id => doc.GetElement(id)).Where(e => e is not Wall).Select(e => e.Id).ToList(); - SpearateByIds(doc, walls, true); - SpearateByIds(doc, others, false); - using (Transaction trans = new Transaction(doc, "删除选中")) - { - try - { - trans.Start(); - doc.Delete(list); - trans.Commit(); - } - catch (Exception ex) - { - throw ex; - } - } - }); - } - - private void SpearateByIds(Document doc, System.Collections.Generic.ICollection list, bool isA) - { - var allOthers = doc.OfModelCollector()? - .Excluding(list) - .ToElementIds(); - if (allOthers == null) - { - return; - } - var ids = doc.OfClass().ToElementIds(); - var modelLineIds = doc.OfCollector().OfCategory(BuiltInCategory.OST_Lines).Select(e => e.Id).ToList(); - var texts = doc.OfCollector().OfCategory(BuiltInCategory.OST_TextNotes).Select(e => e.Id).ToList(); - using (Transaction trans = new Transaction(doc, "拆分模型")) - { - try - { - trans.Start(); - doc.Delete(allOthers); - doc.Delete(ids); - doc.Delete(modelLineIds); - doc.Delete(texts); - trans.Commit(); - } - catch (Exception ex) - { - throw ex; - } - } - if (!Directory.Exists(TbFolder.Text)) - { - Directory.CreateDirectory(TbFolder.Text); - } - var fileName = isA ? TbFileName.Text + "-A" : TbFileName.Text + "-GE"; - var filePath = Path.Combine(TbFolder.Text, $"{fileName}.rvt"); - SaveAsOptions options = new SaveAsOptions() { OverwriteExistingFile = true, PreviewViewId = doc.ActiveView.Id, Compact = true }; - - doc.SaveAs(filePath, options); - QuickAccessToolBarService.performMultipleUndoRedoOperations(true, 1); - } -} diff --git a/ShrlAlgo.Addin.Test/SetHeight.cs b/ShrlAlgo.Addin.Test/SetHeight.cs deleted file mode 100644 index 28bb29c..0000000 --- a/ShrlAlgo.Addin.Test/SetHeight.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Autodesk.Revit.Attributes; -using Autodesk.Revit.DB; -using Autodesk.Revit.UI; - -namespace ShrlAlgo.Addin.Test -{ - [Transaction(TransactionMode.Manual)] - [Regeneration(RegenerationOption.Manual)] - public class SetHeight : IExternalCommand - { - public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) - { - //程序UI界面 - var uiapp = commandData.Application; - //获取元素(选择) 显示元素 视图(活动视图)管理(对象) - var uidoc = uiapp.ActiveUIDocument; - //程序 - var app = uiapp.Application; - //获取位置和场地 视图(多个视图)管理 获取元素(Revit 项目里的全部元素) - var doc = uidoc.Document; - //获取所有打开文档 - var docset = uiapp.Application.Documents; - //当前视图 - var view = doc.ActiveView; - - var ids = uidoc.Selection.GetElementIds(); - using (var ts = new Transaction(doc, "设置净高")) - { - ts.Start(); - try - { - foreach (var id in ids) - { - var elem = doc.GetElement(id); - var param = elem.GetParameters("h").FirstOrDefault(); - var height = elem.GetParameters("净高").FirstOrDefault(); - height.Set(param.AsValueString()); - } - } - catch (Exception) - { - return Result.Failed; - } - - ts.Commit(); - } - return Result.Succeeded; - } - } -} diff --git a/ShrlAlgo.Addin.Test/RemoveParamCmd.cs b/ShrlAlgoToolkit.RevitAddins/ModelManager/RemoveParamCmd.cs similarity index 100% rename from ShrlAlgo.Addin.Test/RemoveParamCmd.cs rename to ShrlAlgoToolkit.RevitAddins/ModelManager/RemoveParamCmd.cs diff --git a/WPFluent.Gallery/Services/Contracts/IWindow.cs b/WPFluent.Gallery/Services/Contracts/IWindow.cs deleted file mode 100644 index ea40419..0000000 --- a/WPFluent.Gallery/Services/Contracts/IWindow.cs +++ /dev/null @@ -1,13 +0,0 @@ -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. -// Copyright (C) Leszek Pomianowski and WPF UI Contributors. -// All Rights Reserved. - -namespace WPFluent.Gallery.Services.Contracts; - -public interface IWindow -{ - event RoutedEventHandler Loaded; - - void Show(); -} diff --git a/WPFluent/Controls/ControlsServices.cs b/WPFluent/Controls/ControlsServices.cs deleted file mode 100644 index 4ca60ba..0000000 --- a/WPFluent/Controls/ControlsServices.cs +++ /dev/null @@ -1,27 +0,0 @@ - - - -namespace WPFluent.Controls; - -/// -/// Used to initialize the library controls with static values. -/// -public static class ControlsServices -{ -#if NET48_OR_GREATER || NETCOREAPP3_0_OR_GREATER - internal static IServiceProvider? ControlsServiceProvider { get; private set; } - - /// - /// Accepts a ServiceProvider for configuring dependency injection. - /// - public static void Initialize(IServiceProvider? serviceProvider) - { - if (serviceProvider == null) - { - throw new ArgumentNullException(nameof(serviceProvider)); - } - - ControlsServiceProvider = serviceProvider; - } -#endif -}