修复bug和新增部分功能
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -15,6 +16,8 @@ namespace ConsoleApp
|
|||||||
string str = "";
|
string str = "";
|
||||||
double a = 10.0;
|
double a = 10.0;
|
||||||
double b = 100;
|
double b = 100;
|
||||||
|
|
||||||
|
Debug.Assert(a == b);
|
||||||
//确保str满足条件才能继续执行,不满足即抛出异常
|
//确保str满足条件才能继续执行,不满足即抛出异常
|
||||||
Guard.IsNotNullOrEmpty(str);//抛出异常
|
Guard.IsNotNullOrEmpty(str);//抛出异常
|
||||||
Guard.IsLessThan(a,b);
|
Guard.IsLessThan(a,b);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ using OfficeOpenXml;
|
|||||||
|
|
||||||
using Sai.Toolkit.Revit.Helpers;
|
using Sai.Toolkit.Revit.Helpers;
|
||||||
|
|
||||||
|
|
||||||
namespace RvAddinTest;
|
namespace RvAddinTest;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -282,6 +283,6 @@ public class Order
|
|||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
public Decimal OrderValue { get; set; }
|
public decimal OrderValue { get; set; }
|
||||||
public bool Shipped { get; set; }
|
public bool Shipped { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
using System;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using Autodesk.Revit.Attributes;
|
using Autodesk.Revit.Attributes;
|
||||||
using Autodesk.Revit.DB;
|
using Autodesk.Revit.DB;
|
||||||
using Autodesk.Revit.DB.Plumbing;
|
|
||||||
using Autodesk.Revit.UI;
|
using Autodesk.Revit.UI;
|
||||||
|
|
||||||
namespace RvAddinTest
|
namespace RvAddinTest
|
||||||
@@ -19,22 +14,18 @@ namespace RvAddinTest
|
|||||||
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
||||||
{
|
{
|
||||||
//程序UI界面
|
//程序UI界面
|
||||||
UIApplication uiapp = commandData.Application;
|
var uiapp = commandData.Application;
|
||||||
//获取元素(选择) 显示元素 视图(活动视图)管理(对象)
|
//获取元素(选择) 显示元素 视图(活动视图)管理(对象)
|
||||||
UIDocument uidoc = uiapp.ActiveUIDocument;
|
var uidoc = uiapp.ActiveUIDocument;
|
||||||
//程序
|
|
||||||
Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
|
|
||||||
//获取位置和场地 视图(多个视图)管理 获取元素(Revit 项目里的全部元素)
|
//获取位置和场地 视图(多个视图)管理 获取元素(Revit 项目里的全部元素)
|
||||||
Document doc = uidoc.Document;
|
var doc = uidoc.Document;
|
||||||
//获取所有打开文档
|
|
||||||
DocumentSet docset = uiapp.Application.Documents;
|
|
||||||
//当前视图
|
//当前视图
|
||||||
View view = doc.ActiveView;
|
var view = doc.ActiveView;
|
||||||
List<Element> collector = new FilteredElementCollector(doc, view.Id)
|
var collector = new FilteredElementCollector(doc, view.Id)
|
||||||
.OfClass(typeof(MEPCurve))
|
.OfClass(typeof(MEPCurve))
|
||||||
.WhereElementIsNotElementType().ToList();
|
.WhereElementIsNotElementType().ToList();
|
||||||
// 检查管线之间的碰撞
|
// 检查管线之间的碰撞
|
||||||
List<Tuple<Element, Element>> collisions = CheckPipeCollisionsParallel(doc, collector);
|
var collisions = CheckPipeCollisionsParallel(doc, collector);
|
||||||
|
|
||||||
// 显示碰撞结果
|
// 显示碰撞结果
|
||||||
ShowCollisionResults(collisions);
|
ShowCollisionResults(collisions);
|
||||||
@@ -42,18 +33,18 @@ namespace RvAddinTest
|
|||||||
}
|
}
|
||||||
public List<Tuple<Element, Element>> CheckPipeCollisionsParallel(Document doc, List<Element> pipes)
|
public List<Tuple<Element, Element>> CheckPipeCollisionsParallel(Document doc, List<Element> pipes)
|
||||||
{
|
{
|
||||||
List<Tuple<Element, Element>> collisions = new List<Tuple<Element, Element>>();
|
var collisions = new List<Tuple<Element, Element>>();
|
||||||
// 使用 Parallel.For 并行检查碰撞
|
// 使用 Parallel.For 并行检查碰撞
|
||||||
Parallel.For(0, pipes.Count, i =>
|
Parallel.For(0, pipes.Count, i =>
|
||||||
{
|
{
|
||||||
for (int j = i + 1; j < pipes.Count; j++)
|
for (var j = i + 1; j < pipes.Count; j++)
|
||||||
{
|
{
|
||||||
Element pipe1 = pipes[i];
|
var pipe1 = pipes[i];
|
||||||
Element pipe2 = pipes[j];
|
var pipe2 = pipes[j];
|
||||||
|
|
||||||
// 使用 ElementIntersectsElementFilter 检查碰撞
|
// 使用 ElementIntersectsElementFilter 检查碰撞
|
||||||
ElementIntersectsElementFilter filter = new ElementIntersectsElementFilter(pipe1);
|
var filter = new ElementIntersectsElementFilter(pipe1);
|
||||||
FilteredElementCollector collector = new FilteredElementCollector(doc, new ElementId[] { pipe2.Id });
|
var collector = new FilteredElementCollector(doc, [pipe2.Id]);
|
||||||
collector.WherePasses(filter);
|
collector.WherePasses(filter);
|
||||||
|
|
||||||
if (collector.Any())
|
if (collector.Any())
|
||||||
@@ -77,9 +68,9 @@ namespace RvAddinTest
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder message = new StringBuilder();
|
var message = new StringBuilder();
|
||||||
message.AppendLine("发现碰撞:");
|
message.AppendLine("发现碰撞:");
|
||||||
foreach (Tuple<Element, Element> collision in collisions)
|
foreach (var collision in collisions)
|
||||||
{
|
{
|
||||||
message.AppendLine($"管线 {collision.Item1.Id} 与管线 {collision.Item2.Id} 发生碰撞");
|
message.AppendLine($"管线 {collision.Item1.Id} 与管线 {collision.Item2.Id} 发生碰撞");
|
||||||
}
|
}
|
||||||
@@ -90,10 +81,10 @@ namespace RvAddinTest
|
|||||||
public void ExportCollisionResultsToFile(string content)
|
public void ExportCollisionResultsToFile(string content)
|
||||||
{
|
{
|
||||||
// 获取桌面路径
|
// 获取桌面路径
|
||||||
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
var desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
||||||
|
|
||||||
// 创建文件路径
|
// 创建文件路径
|
||||||
string filePath = Path.Combine(desktopPath, "碰撞检查.txt");
|
var filePath = Path.Combine(desktopPath, "碰撞检查.txt");
|
||||||
|
|
||||||
// 写入文件
|
// 写入文件
|
||||||
File.WriteAllText(filePath, content);
|
File.WriteAllText(filePath, content);
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ public class RevitAddin : ExternalCommand
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var reference = UiDocument.Selection.PickObject(ObjectType.PointOnElement, new DwgBlockSelection(), "请选择dwg块");
|
var reference = UiDocument.Selection.PickObject(ObjectType.PointOnElement, new DwgBlockSelection(), "请选择dwg链接的块参照");
|
||||||
var dwg = Document.GetElement(reference) as ImportInstance;
|
var dwg = Document.GetElement(reference) as ImportInstance;
|
||||||
var dwgTransform = dwg!.GetTotalTransform();
|
var dwgTransform = dwg!.GetTotalTransform();
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Bogus" Version="35.5.1" />
|
<PackageReference Include="Bogus" Version="35.5.1" />
|
||||||
|
<PackageReference Include="EleCho.WpfSuite.FluentDesign" Version="0.0.1" />
|
||||||
<PackageReference Include="iNKORE.UI.WPF.Modern" Version="0.9.30" />
|
<PackageReference Include="iNKORE.UI.WPF.Modern" Version="0.9.30" />
|
||||||
<PackageReference Include="LiteDB" Version="5.0.21" />
|
<PackageReference Include="LiteDB" Version="5.0.21" />
|
||||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.122" />
|
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.122" />
|
||||||
@@ -29,11 +30,15 @@
|
|||||||
<PackageReference Include="Nice3point.Revit.Api.RevitAPI" Version="2018.*" PrivateAssets="All" />
|
<PackageReference Include="Nice3point.Revit.Api.RevitAPI" Version="2018.*" PrivateAssets="All" />
|
||||||
<PackageReference Include="Nice3point.Revit.Api.RevitAPIUI" Version="2018.*" PrivateAssets="All" />
|
<PackageReference Include="Nice3point.Revit.Api.RevitAPIUI" Version="2018.*" PrivateAssets="All" />
|
||||||
<PackageReference Include="Nice3point.Revit.Api.UIFrameworkServices" Version="2020.2.60" PrivateAssets="All" />
|
<PackageReference Include="Nice3point.Revit.Api.UIFrameworkServices" Version="2020.2.60" PrivateAssets="All" />
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
|
<PackageReference Include="CommunityToolkit.Common" Version="8.3.2" />
|
||||||
|
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.3.2" />
|
||||||
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
|
||||||
<PackageReference Include="EPPlus.Core.Extensions" Version="2.4.0" />
|
<PackageReference Include="EPPlus.Core.Extensions" Version="2.4.0" />
|
||||||
<PackageReference Include="JerryShaw.AduSkin" Version="1.1.1.11" />
|
<PackageReference Include="JerryShaw.AduSkin" Version="1.1.1.11" />
|
||||||
<PackageReference Include="Nice3point.Revit.Toolkit" Version="2019.0.12" PrivateAssets="All" />
|
<PackageReference Include="Nice3point.Revit.Toolkit" Version="2019.0.12" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<Import Project="..\Sai.Toolkit.Revit\Sai.Toolkit.Revit.projitems" Label="Shared" />
|
||||||
|
<Import Project="..\Sai.Toolkit.Core\Sai.Toolkit.Core.projitems" Label="Shared" />
|
||||||
|
|
||||||
<!--<Target Name="PreventRevitSDKCopyLocal" AfterTargets="ResolveReferences">
|
<!--<Target Name="PreventRevitSDKCopyLocal" AfterTargets="ResolveReferences">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -41,8 +46,4 @@
|
|||||||
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' == 'Autodesk.Revit.SDK'" />
|
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' == 'Autodesk.Revit.SDK'" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Target>-->
|
</Target>-->
|
||||||
|
|
||||||
<Import Project="..\Sai.Toolkit.Revit\Sai.Toolkit.Revit.projitems" Label="Shared" />
|
|
||||||
|
|
||||||
<Import Project="..\Sai.Toolkit.Core\Sai.Toolkit.Core.projitems" Label="Shared" />
|
|
||||||
</Project>
|
</Project>
|
||||||
64
RvAddinTest/TestGDI.cs
Normal file
64
RvAddinTest/TestGDI.cs
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
using System.Drawing;
|
||||||
|
using System.Timers;
|
||||||
|
|
||||||
|
using Autodesk.Revit.Attributes;
|
||||||
|
using Autodesk.Revit.DB;
|
||||||
|
using Autodesk.Revit.UI;
|
||||||
|
|
||||||
|
using Nice3point.Revit.Toolkit.External;
|
||||||
|
|
||||||
|
using Sai.Toolkit.Core.Helpers;
|
||||||
|
|
||||||
|
namespace RvAddinTest;
|
||||||
|
|
||||||
|
[Transaction(TransactionMode.Manual)]
|
||||||
|
[Regeneration(RegenerationOption.Manual)]
|
||||||
|
public class TestGDI : ExternalCommand
|
||||||
|
{
|
||||||
|
private UIView ui;
|
||||||
|
/// <summary>
|
||||||
|
/// 设置项目基点
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
private void SetProjectPosition(XYZ position)
|
||||||
|
{
|
||||||
|
using Transaction trans = new(Document);
|
||||||
|
trans.Start("设置项目基点");
|
||||||
|
XYZ p = new();
|
||||||
|
|
||||||
|
ProjectPosition pp = new(position.X, position.Y, position.Z, 0);
|
||||||
|
//设置项目基点
|
||||||
|
|
||||||
|
Document.ActiveProjectLocation.SetProjectPosition(p, pp);
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
public override void Execute()
|
||||||
|
{
|
||||||
|
|
||||||
|
ui = UiDocument.GetOpenUIViews().FirstOrDefault(uiView => uiView.ViewId == UiDocument.ActiveView.Id);
|
||||||
|
|
||||||
|
var corners = ui.GetZoomCorners();
|
||||||
|
//var inptr = HookInptr.FindWindow(null, view.Name);
|
||||||
|
//Graphics graphics = Graphics.FromHwnd(inptr);
|
||||||
|
|
||||||
|
//graphics.RenderingOrigin=
|
||||||
|
//Graphics graphics = Graphics.FromHwnd(System.Diagnostics.Process.GetCurrentProcess().Handle);
|
||||||
|
System.Timers.Timer timer =
|
||||||
|
new(2000)
|
||||||
|
{
|
||||||
|
Interval = 500,
|
||||||
|
Enabled = true
|
||||||
|
//AutoReset = true
|
||||||
|
};
|
||||||
|
timer.Elapsed += Timer_Elapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
var rectangle = ui.GetWindowRectangle(); //屏幕坐标;原点在右上角
|
||||||
|
var graphics = Graphics.FromHwnd(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle);
|
||||||
|
var p = new System.Drawing.Point(rectangle.Left + 1920, rectangle.Top);
|
||||||
|
var p1 = new System.Drawing.Point(rectangle.Right + 1920, rectangle.Bottom);
|
||||||
|
GdiHelper.DrawLine(graphics, p, p1);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# 17
|
||||||
VisualStudioVersion = 17.1.32421.90
|
VisualStudioVersion = 17.1.32421.90
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sai.RvKits", "Sai.RvKits\Sai.RvKits.csproj", "{AA64ED67-E47E-46B1-A6F6-999A26193E57}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sai.RvKits", "Sai.RvKits\Sai.RvKits.csproj", "{AA64ED67-E47E-46B1-A6F6-999A26193E57}"
|
||||||
@@ -107,26 +107,26 @@ Global
|
|||||||
{1E6F7706-97B3-4929-8FF9-79DF5485801B}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1E6F7706-97B3-4929-8FF9-79DF5485801B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{1E6F7706-97B3-4929-8FF9-79DF5485801B}.Release|x64.ActiveCfg = Release|x64
|
{1E6F7706-97B3-4929-8FF9-79DF5485801B}.Release|x64.ActiveCfg = Release|x64
|
||||||
{1E6F7706-97B3-4929-8FF9-79DF5485801B}.Release|x64.Build.0 = Release|x64
|
{1E6F7706-97B3-4929-8FF9-79DF5485801B}.Release|x64.Build.0 = Release|x64
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.All|Any CPU.ActiveCfg = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.All|Any CPU.ActiveCfg = All|Any CPU
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.All|Any CPU.Build.0 = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.All|Any CPU.Build.0 = All|Any CPU
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.All|x64.ActiveCfg = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.All|x64.ActiveCfg = All|x64
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.All|x64.Build.0 = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.All|x64.Build.0 = All|x64
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug One|Any CPU.ActiveCfg = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug One|Any CPU.ActiveCfg = Debug One|Any CPU
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug One|Any CPU.Build.0 = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug One|Any CPU.Build.0 = Debug One|Any CPU
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug One|x64.ActiveCfg = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug One|x64.ActiveCfg = Debug One|x64
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug One|x64.Build.0 = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug One|x64.Build.0 = Debug One|x64
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug|Any CPU.ActiveCfg = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug|Any CPU.Build.0 = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug|x64.ActiveCfg = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug|x64.Build.0 = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Debug|x64.Build.0 = Debug|x64
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.DefaultBuild|Any CPU.ActiveCfg = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.DefaultBuild|Any CPU.ActiveCfg = DefaultBuild|Any CPU
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.DefaultBuild|Any CPU.Build.0 = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.DefaultBuild|Any CPU.Build.0 = DefaultBuild|Any CPU
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.DefaultBuild|x64.ActiveCfg = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.DefaultBuild|x64.ActiveCfg = DefaultBuild|x64
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.DefaultBuild|x64.Build.0 = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.DefaultBuild|x64.Build.0 = DefaultBuild|x64
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Release|Any CPU.ActiveCfg = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Release|Any CPU.Build.0 = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Release|x64.ActiveCfg = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Release|x64.ActiveCfg = Release|x64
|
||||||
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Release|x64.Build.0 = DefaultBuild
|
{C076D0DF-C55C-461A-B6C9-8D0AC16175FD}.Release|x64.Build.0 = Release|x64
|
||||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.All|Any CPU.ActiveCfg = Debug|Any CPU
|
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.All|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.All|Any CPU.Build.0 = Debug|Any CPU
|
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.All|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.All|x64.ActiveCfg = Debug|x64
|
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.All|x64.ActiveCfg = Debug|x64
|
||||||
|
|||||||
84
Sai.RvKits/Properties/Resources.Designer.cs
generated
84
Sai.RvKits/Properties/Resources.Designer.cs
generated
@@ -89,50 +89,6 @@ namespace Sai.RvKits.Properties {
|
|||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap rotate_instance_16px
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
object obj = ResourceManager.GetObject("rotate_instance_16px", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap rotate_instance_32px
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
object obj = ResourceManager.GetObject("rotate_instance_32px", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap flip_workplane_16px
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
object obj = ResourceManager.GetObject("flip_workplane_16px", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap flip_workplane_32px
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
object obj = ResourceManager.GetObject("flip_workplane_32px", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
@@ -554,6 +510,26 @@ namespace Sai.RvKits.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap flip_workplane_16px {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("flip_workplane_16px", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap flip_workplane_32px {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("flip_workplane_32px", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -904,6 +880,26 @@ namespace Sai.RvKits.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap rotate_instance_16px {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("rotate_instance_16px", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap rotate_instance_32px {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("rotate_instance_32px", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
BIN
Sai.RvKits/Resources/OIP-C.jpg
Normal file
BIN
Sai.RvKits/Resources/OIP-C.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@@ -203,7 +203,7 @@ namespace Sai.RvKits.RvCivil
|
|||||||
catch (Autodesk.Revit.Exceptions.OperationCanceledException) { }
|
catch (Autodesk.Revit.Exceptions.OperationCanceledException) { }
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LogHelper.ToLog(e.Message, Variables.LogFolder);
|
e.Message.ToLog();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,7 +243,12 @@ namespace Sai.RvKits.RvCivil
|
|||||||
return normalFace;
|
return normalFace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找所有管线定位线与元素面的碰撞点
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="elementToOpen"></param>
|
||||||
|
/// <param name="curve"></param>
|
||||||
|
/// <returns></returns>
|
||||||
private static List<XYZ> FindIntersects(Element elementToOpen, Curve curve)
|
private static List<XYZ> FindIntersects(Element elementToOpen, Curve curve)
|
||||||
{
|
{
|
||||||
var faces = elementToOpen.GetAllGeometryObjects<Face>();
|
var faces = elementToOpen.GetAllGeometryObjects<Face>();
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public partial class InstanceCreatorViewModel : ObservableObject
|
|||||||
Reference reference;
|
Reference reference;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
reference = uiDocument.Selection.PickObject(ObjectType.PointOnElement, new DwgBlockSelection(), "请选择dwg块");
|
reference = uiDocument.Selection.PickObject(ObjectType.PointOnElement, new DwgBlockSelection(), "请选择dwg链接的块参照");
|
||||||
}
|
}
|
||||||
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
|
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
|
||||||
{
|
{
|
||||||
|
|||||||
10
Sai.RvKits/RvMEP/ArrangeMEPCurveCmd.cs
Normal file
10
Sai.RvKits/RvMEP/ArrangeMEPCurveCmd.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Sai.RvKits.RvMEP;
|
||||||
|
internal class ArrangeMEPCurveCmd
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -28,11 +28,13 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
|
|||||||
elemIds.Add(Document.GetElement(reference).Id);
|
elemIds.Add(Document.GetElement(reference).Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
var pipeTypeId = ElementId.InvalidElementId;
|
foreach (var elemId in elemIds)
|
||||||
var cableTrayTypeId = ElementId.InvalidElementId;
|
{
|
||||||
var conduitTypeId = ElementId.InvalidElementId;
|
var pipeTypeId = Document.OfClass<PipeType>().FirstElementId();
|
||||||
|
var cableTrayTypeId = Document.OfClass<CableTrayType>().FirstElementId();
|
||||||
|
var conduitTypeId = Document.OfClass<ConduitType>().FirstElementId();
|
||||||
|
|
||||||
var filteredElementCollector = new FilteredElementCollector(Document).OfClass(typeof(DuctType));
|
var filteredElementCollector = Document.OfClass<DuctType>();
|
||||||
var roundTypeId = ElementId.InvalidElementId;
|
var roundTypeId = ElementId.InvalidElementId;
|
||||||
var rectangleTypeId = ElementId.InvalidElementId;
|
var rectangleTypeId = ElementId.InvalidElementId;
|
||||||
var ovalTypeId = ElementId.InvalidElementId;
|
var ovalTypeId = ElementId.InvalidElementId;
|
||||||
@@ -55,10 +57,9 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var fabricationConfiguration = FabricationConfiguration.GetFabricationConfiguration(Document);
|
var fabricationConfiguration = FabricationConfiguration.GetFabricationConfiguration(Document);
|
||||||
foreach (var elemId in elemIds)
|
|
||||||
{
|
|
||||||
var elem = Document.GetElement(elemId);
|
var elem = Document.GetElement(elemId);
|
||||||
if (elem.GetConnectors(true).IsEmpty)
|
if (elem.GetConnectors(true).IsEmpty && elem is not FamilyInstance)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -72,7 +73,7 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (conn.Domain == Domain.DomainPiping)
|
if (conn.Domain == Domain.DomainPiping && connector.Owner is Pipe)
|
||||||
{
|
{
|
||||||
pipeTypeId = connector.Owner.GetTypeId();
|
pipeTypeId = connector.Owner.GetTypeId();
|
||||||
}
|
}
|
||||||
@@ -112,7 +113,8 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
|
|||||||
Document.Invoke(
|
Document.Invoke(
|
||||||
_ =>
|
_ =>
|
||||||
{
|
{
|
||||||
foreach (Connector connector in elem.GetConnectors(true))
|
var conns = elem.GetConnectors(true);
|
||||||
|
foreach (Connector connector in conns)
|
||||||
{
|
{
|
||||||
Element element = null;
|
Element element = null;
|
||||||
if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_FabricationPipework)
|
if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_FabricationPipework)
|
||||||
@@ -155,16 +157,21 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
|
|||||||
connector2.Height = connector.Height;
|
connector2.Height = connector.Height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
var extensionLength = connector.GetExtensionLength();
|
var extensionLength = connector.GetExtensionLength();
|
||||||
var origin = connector.Origin;
|
var origin = connector.Origin;
|
||||||
var xyz2 = origin + (extensionLength * connector.CoordinateSystem.BasisZ);
|
var xyz2 = origin + (extensionLength * connector.CoordinateSystem.BasisZ);
|
||||||
var levelId = elem.LevelId;
|
var levelId = elem.LevelId;
|
||||||
if (levelId == ElementId.InvalidElementId)
|
if (levelId == ElementId.InvalidElementId)
|
||||||
{
|
{
|
||||||
levelId = elem.get_Parameter(BuiltInParameter.RBS_START_LEVEL_PARAM).AsElementId();
|
var pa = elem.get_Parameter(BuiltInParameter.RBS_START_LEVEL_PARAM);
|
||||||
|
if (pa != null)
|
||||||
|
{
|
||||||
|
levelId = pa.AsElementId();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (levelId == ElementId.InvalidElementId)
|
if (levelId == ElementId.InvalidElementId)
|
||||||
@@ -177,6 +184,7 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
|
|||||||
|
|
||||||
switch (connector.Domain)
|
switch (connector.Domain)
|
||||||
{
|
{
|
||||||
|
//未定义
|
||||||
case Domain.DomainUndefined:
|
case Domain.DomainUndefined:
|
||||||
break;
|
break;
|
||||||
//风管
|
//风管
|
||||||
@@ -283,16 +291,10 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
|
|||||||
var pipingSystemTypes = new FilteredElementCollector(Document)
|
var pipingSystemTypes = new FilteredElementCollector(Document)
|
||||||
.OfClass(typeof(PipingSystemType))
|
.OfClass(typeof(PipingSystemType))
|
||||||
.Cast<PipingSystemType>();
|
.Cast<PipingSystemType>();
|
||||||
if (pipeTypeId == ElementId.InvalidElementId
|
if (pipeTypeId == ElementId.InvalidElementId)
|
||||||
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
pipeTypeId = new FilteredElementCollector(Document).OfClass(
|
pipeTypeId = Document.OfClass<PipeType>().WhereElementIsElementType().FirstElementId();
|
||||||
typeof(PipeType))
|
|
||||||
.FirstElementId();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var system = connector.MEPSystem;
|
var system = connector.MEPSystem;
|
||||||
var pipingSystemType =
|
var pipingSystemType =
|
||||||
system != null
|
system != null
|
||||||
@@ -383,9 +385,9 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
|
|||||||
== Autodesk.Revit.DB.MEPSystemClassification.OtherPipe
|
== Autodesk.Revit.DB.MEPSystemClassification.OtherPipe
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
element = Pipe.Create(Document, pipingSystemType.Id, pipeTypeId, levelId, origin, xyz2);
|
element = Pipe.Create(Document, pipingSystemType.Id, pipeTypeId, levelId, origin, xyz2);
|
||||||
element.get_Parameter(BuiltInParameter.RBS_PIPE_DIAMETER_PARAM).Set(connector.Radius * 2);
|
element.get_Parameter(BuiltInParameter.RBS_PIPE_DIAMETER_PARAM).Set(connector.Radius * 2);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
//电力
|
//电力
|
||||||
case Domain.DomainCableTrayConduit:
|
case Domain.DomainCableTrayConduit:
|
||||||
@@ -451,7 +453,6 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"引出短管"
|
"引出短管"
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
MinWidth="250"
|
MinWidth="250"
|
||||||
MinHeight="280"
|
MinHeight="280"
|
||||||
d:DataContext="{d:DesignInstance Type={x:Type local:RotateMEPViewModel}}"
|
d:DataContext="{d:DesignInstance Type={x:Type local:RotateMEPViewModel}}"
|
||||||
SizeToContent="WidthAndHeight"
|
SizeToContent="Height"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<ResourceDictionary Source="pack://application:,,,/Sai.RvKits;component/WPFUI.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/Sai.RvKits;component/WPFUI.xaml" />
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Sai.RvKits.RvMEP
|
|||||||
public partial class RotateMEPViewModel : ObservableObject
|
public partial class RotateMEPViewModel : ObservableObject
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private double angle;
|
private double angle = 90;
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isSingleSelect = true;
|
private bool isSingleSelect = true;
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
@@ -40,7 +40,7 @@ namespace Sai.RvKits.RvMEP
|
|||||||
var r = uidoc.Selection.PickObject(ObjectType.Element, new FuncFilter(e =>
|
var r = uidoc.Selection.PickObject(ObjectType.Element, new FuncFilter(e =>
|
||||||
{
|
{
|
||||||
return e is FamilyInstance && e.GetConnectors().OfType<Connector>().Any(c => c.IsConnected);
|
return e is FamilyInstance && e.GetConnectors().OfType<Connector>().Any(c => c.IsConnected);
|
||||||
}), "请选择可以连管的构件");
|
}), "请选择已经连管的构件");
|
||||||
|
|
||||||
elemIds.Add(r.ElementId);
|
elemIds.Add(r.ElementId);
|
||||||
}
|
}
|
||||||
@@ -49,15 +49,40 @@ namespace Sai.RvKits.RvMEP
|
|||||||
elemIds = uidoc.Selection.PickObjects(ObjectType.Element, new FuncFilter(e =>
|
elemIds = uidoc.Selection.PickObjects(ObjectType.Element, new FuncFilter(e =>
|
||||||
{
|
{
|
||||||
return e is FamilyInstance && e.GetConnectors().OfType<Connector>().Any(c => c.IsConnected);
|
return e is FamilyInstance && e.GetConnectors().OfType<Connector>().Any(c => c.IsConnected);
|
||||||
}), "请选择可以连管的构件,并完成").Select(r => doc.GetElement(r).Id).ToList();
|
}), "请选择已经连管的构件,并完成").Select(r => doc.GetElement(r).Id).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var id in uidoc.Selection.GetElementIds())
|
foreach (var id in elemIds)
|
||||||
{
|
{
|
||||||
var elem = uidoc.Document.GetElement(id);
|
var elem = uidoc.Document.GetElement(id);
|
||||||
|
|
||||||
var referConn = elem.GetConnectors().OfType<Connector>().FirstOrDefault(c => c.IsConnected);
|
var referConn = elem.GetConnectors().OfType<Connector>().FirstOrDefault(c =>
|
||||||
|
{
|
||||||
|
if (c.IsConnected)
|
||||||
|
{
|
||||||
|
if (c.CoordinateSystem.BasisZ.X > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (c.CoordinateSystem.BasisZ.Y > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (c.CoordinateSystem.BasisZ.Z > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
if (referConn != null)
|
if (referConn != null)
|
||||||
{
|
{
|
||||||
@@ -71,7 +96,7 @@ namespace Sai.RvKits.RvMEP
|
|||||||
referConn.CoordinateSystem.Origin,
|
referConn.CoordinateSystem.Origin,
|
||||||
referConn.CoordinateSystem.BasisZ),
|
referConn.CoordinateSystem.BasisZ),
|
||||||
Angle.ToRadian());
|
Angle.ToRadian());
|
||||||
}, "旋转");
|
}, "旋转实例");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -21,6 +21,6 @@ public class QuickViewSectionCmd : ExternalCommand
|
|||||||
{
|
{
|
||||||
public override void Execute()
|
public override void Execute()
|
||||||
{
|
{
|
||||||
WinDialogHelper.ShowModeless<QuickViewSectionView>(new QuickViewSectionViewModel(UiDocument));
|
WinDialogHelper.ShowModeless<QuickViewSectionView>(new QuickViewSectionViewModel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
Title="快速剖面"
|
Title="快速剖面"
|
||||||
Width="250"
|
Width="250"
|
||||||
Height="180"
|
Height="180"
|
||||||
MinHeight="180"
|
|
||||||
d:DataContext="{d:DesignInstance Type=local:QuickViewSectionViewModel}"
|
d:DataContext="{d:DesignInstance Type=local:QuickViewSectionViewModel}"
|
||||||
SizeToContent="Height"
|
SizeToContent="Height"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
@@ -17,7 +16,7 @@
|
|||||||
<ResourceDictionary Source="pack://application:,,,/Sai.RvKits;component/WPFUI.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/Sai.RvKits;component/WPFUI.xaml" />
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
<ex:StackPanelEx Margin="5" Spacing="5">
|
<ex:StackPanelEx Margin="5" Spacing="5">
|
||||||
<GroupBox Grid.Row="0" Header="剖面线">
|
<GroupBox Header="剖面线">
|
||||||
<UniformGrid Rows="1">
|
<UniformGrid Rows="1">
|
||||||
<RadioButton
|
<RadioButton
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
@@ -30,10 +29,18 @@
|
|||||||
IsChecked="{Binding IsParallel, Converter={StaticResource InvertBooleanConverter}}" />
|
IsChecked="{Binding IsParallel, Converter={StaticResource InvertBooleanConverter}}" />
|
||||||
</UniformGrid>
|
</UniformGrid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
<UniformGrid Rows="1">
|
||||||
<Button
|
<Button
|
||||||
Grid.Row="1"
|
Margin="5"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Command="{Binding CreateViewSectionCommand}"
|
Command="{Binding CreateViewSectionCommand}"
|
||||||
Content="创建" />
|
Content="创建" />
|
||||||
|
<Button
|
||||||
|
Margin="5"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Command="{Binding DeleteViewSectionCommand}"
|
||||||
|
Content="删除"
|
||||||
|
ToolTip="删除全部在当前窗口打开时(本次)创建的快速剖面" />
|
||||||
|
</UniformGrid>
|
||||||
</ex:StackPanelEx>
|
</ex:StackPanelEx>
|
||||||
</ex:FluentWindowEx>
|
</ex:FluentWindowEx>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using System.Diagnostics;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
using Autodesk.Revit.DB;
|
using Autodesk.Revit.DB;
|
||||||
using Autodesk.Revit.UI;
|
using Autodesk.Revit.UI;
|
||||||
@@ -10,19 +12,49 @@ using Nice3point.Revit.Toolkit.External.Handlers;
|
|||||||
|
|
||||||
namespace Sai.RvKits.RvView
|
namespace Sai.RvKits.RvView
|
||||||
{
|
{
|
||||||
public partial class QuickViewSectionViewModel(UIDocument uidoc) : ObservableObject
|
public partial class QuickViewSectionViewModel : ObservableObject
|
||||||
{
|
{
|
||||||
private readonly ActionEventHandler handler = new();
|
private readonly ActionEventHandler handler = new();
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isParallel = true;
|
private bool isParallel = true;
|
||||||
|
private readonly List<ViewSection> viewSections = [];
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private void DeleteViewSection()
|
||||||
|
{
|
||||||
|
handler.Raise(
|
||||||
|
uiapp =>
|
||||||
|
{
|
||||||
|
var uidoc = uiapp.ActiveUIDocument;
|
||||||
|
var doc = uidoc.Document;
|
||||||
|
doc.Invoke(
|
||||||
|
ts =>
|
||||||
|
{
|
||||||
|
for (var i = viewSections.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
var view = viewSections[i];
|
||||||
|
if (view.IsValidObject)
|
||||||
|
{
|
||||||
|
var uiView = uidoc.GetOpenUIViews().FirstOrDefault(ui => ui.ViewId == view.Id);
|
||||||
|
|
||||||
|
uiView?.Close();
|
||||||
|
viewSections.Remove(view);
|
||||||
|
doc.Delete(view.Id);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, "删除快速剖面");
|
||||||
|
});
|
||||||
|
}
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private void CreateViewSection()
|
private void CreateViewSection()
|
||||||
{
|
{
|
||||||
var element = uidoc.SelectObject(new FuncFilter(elem => elem.GetLocCurve() is Line));
|
handler.Raise(
|
||||||
if (element != null)
|
uiapp =>
|
||||||
{
|
{
|
||||||
|
var uidoc = uiapp.ActiveUIDocument;
|
||||||
|
var element = uidoc.SelectObject(new FuncFilter(elem => elem.GetLocCurve() is Line));
|
||||||
var lc = element.Location as LocationCurve;
|
var lc = element.Location as LocationCurve;
|
||||||
var line = lc.Curve as Line;
|
var line = lc.Curve as Line;
|
||||||
var doc = uidoc.Document;
|
var doc = uidoc.Document;
|
||||||
@@ -91,9 +123,6 @@ namespace Sai.RvKits.RvView
|
|||||||
Max = max
|
Max = max
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
handler.Raise(
|
|
||||||
_ =>
|
|
||||||
{
|
|
||||||
doc.Invoke(
|
doc.Invoke(
|
||||||
ts =>
|
ts =>
|
||||||
{
|
{
|
||||||
@@ -124,6 +153,10 @@ namespace Sai.RvKits.RvView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ts.Commit();
|
ts.Commit();
|
||||||
|
if (viewSection != null)
|
||||||
|
{
|
||||||
|
viewSections.Add(viewSection);
|
||||||
|
}
|
||||||
Debug.WriteLine("生成后:");
|
Debug.WriteLine("生成后:");
|
||||||
|
|
||||||
Debug.WriteLine($"CropBox.Origin:{viewSection.CropBox.Transform.Origin}");
|
Debug.WriteLine($"CropBox.Origin:{viewSection.CropBox.Transform.Origin}");
|
||||||
@@ -141,9 +174,8 @@ namespace Sai.RvKits.RvView
|
|||||||
uidoc.ActiveView = viewSection;
|
uidoc.ActiveView = viewSection;
|
||||||
uidoc.Selection.SetElementIds([element.Id]);
|
uidoc.Selection.SetElementIds([element.Id]);
|
||||||
}
|
}
|
||||||
|
}, "创建快速剖面");
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Controls.Primitives;
|
||||||
|
|
||||||
using Autodesk.Revit.DB;
|
using Autodesk.Revit.DB;
|
||||||
using Autodesk.Revit.UI;
|
using Autodesk.Revit.UI;
|
||||||
@@ -52,7 +53,12 @@ public partial class VisibilityViewModel : ObservableObject
|
|||||||
doc.Invoke(
|
doc.Invoke(
|
||||||
_ =>
|
_ =>
|
||||||
{
|
{
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_StructuralFraming), value == false);
|
foreach (var builtInCategory in beamCategory)
|
||||||
|
{
|
||||||
|
var categoryId = Category.GetCategory(doc, builtInCategory).Id;
|
||||||
|
|
||||||
|
uidoc.ActiveView.SetCategoryHidden(categoryId, value == false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"梁显隐"
|
"梁显隐"
|
||||||
);
|
);
|
||||||
@@ -73,8 +79,12 @@ public partial class VisibilityViewModel : ObservableObject
|
|||||||
doc.Invoke(
|
doc.Invoke(
|
||||||
_ =>
|
_ =>
|
||||||
{
|
{
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_CableTray), value == false);
|
foreach (var builtInCategory in cabletrayCategory)
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_CableTrayFitting), value == false);
|
{
|
||||||
|
var categoryId = Category.GetCategory(doc, builtInCategory).Id;
|
||||||
|
|
||||||
|
uidoc.ActiveView.SetCategoryHidden(categoryId, value == false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"桥架显隐"
|
"桥架显隐"
|
||||||
);
|
);
|
||||||
@@ -95,8 +105,12 @@ public partial class VisibilityViewModel : ObservableObject
|
|||||||
doc.Invoke(
|
doc.Invoke(
|
||||||
_ =>
|
_ =>
|
||||||
{
|
{
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_StructuralColumns), value == false);
|
foreach (var builtInCategory in columnsCategory)
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_Columns), value == false);
|
{
|
||||||
|
var categoryId = Category.GetCategory(doc, builtInCategory).Id;
|
||||||
|
|
||||||
|
uidoc.ActiveView.SetCategoryHidden(categoryId, value == false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"柱显隐"
|
"柱显隐"
|
||||||
);
|
);
|
||||||
@@ -117,7 +131,12 @@ public partial class VisibilityViewModel : ObservableObject
|
|||||||
doc.Invoke(
|
doc.Invoke(
|
||||||
_ =>
|
_ =>
|
||||||
{
|
{
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_Walls), value == false);
|
foreach (var builtInCategory in wallCategory)
|
||||||
|
{
|
||||||
|
var categoryId = Category.GetCategory(doc, builtInCategory).Id;
|
||||||
|
|
||||||
|
uidoc.ActiveView.SetCategoryHidden(categoryId, value == false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"墙显隐"
|
"墙显隐"
|
||||||
);
|
);
|
||||||
@@ -138,7 +157,12 @@ public partial class VisibilityViewModel : ObservableObject
|
|||||||
doc.Invoke(
|
doc.Invoke(
|
||||||
_ =>
|
_ =>
|
||||||
{
|
{
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_Floors), value == false);
|
foreach (var builtInCategory in floorCategory)
|
||||||
|
{
|
||||||
|
var categoryId = Category.GetCategory(doc, builtInCategory).Id;
|
||||||
|
|
||||||
|
uidoc.ActiveView.SetCategoryHidden(categoryId, value == false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"楼板显隐"
|
"楼板显隐"
|
||||||
);
|
);
|
||||||
@@ -159,8 +183,12 @@ public partial class VisibilityViewModel : ObservableObject
|
|||||||
doc.Invoke(
|
doc.Invoke(
|
||||||
_ =>
|
_ =>
|
||||||
{
|
{
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_Conduit), value == false);
|
foreach (var builtInCategory in conduitCategory)
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_ConduitFitting), value == false);
|
{
|
||||||
|
var categoryId = Category.GetCategory(doc, builtInCategory).Id;
|
||||||
|
|
||||||
|
uidoc.ActiveView.SetCategoryHidden(categoryId, value == false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"线管显隐"
|
"线管显隐"
|
||||||
);
|
);
|
||||||
@@ -181,9 +209,12 @@ public partial class VisibilityViewModel : ObservableObject
|
|||||||
doc.Invoke(
|
doc.Invoke(
|
||||||
_ =>
|
_ =>
|
||||||
{
|
{
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_DuctCurves), value == false);
|
foreach (var builtInCategory in mechanicalCategory)
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_DuctAccessory), value == false);
|
{
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_DuctFitting), value == false);
|
var categoryId = Category.GetCategory(doc, builtInCategory).Id;
|
||||||
|
|
||||||
|
uidoc.ActiveView.SetCategoryHidden(categoryId, value == false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"暖通显隐"
|
"暖通显隐"
|
||||||
);
|
);
|
||||||
@@ -204,10 +235,12 @@ public partial class VisibilityViewModel : ObservableObject
|
|||||||
doc.Invoke(
|
doc.Invoke(
|
||||||
_ =>
|
_ =>
|
||||||
{
|
{
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_PipeCurves), value == false);
|
foreach (var builtInCategory in pipingCategory)
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_PipeFitting), value == false);
|
{
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_PipeAccessory), value == false);
|
var categoryId = Category.GetCategory(doc, builtInCategory).Id;
|
||||||
uidoc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_Sprinklers), value == false);
|
|
||||||
|
uidoc.ActiveView.SetCategoryHidden(categoryId, value == false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"给排水显隐"
|
"给排水显隐"
|
||||||
);
|
);
|
||||||
@@ -244,6 +277,35 @@ public partial class VisibilityViewModel : ObservableObject
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
readonly BuiltInCategory[] wallCategory = [BuiltInCategory.OST_Walls];
|
||||||
|
readonly BuiltInCategory[] beamCategory = [BuiltInCategory.OST_StructuralFraming];
|
||||||
|
readonly BuiltInCategory[] floorCategory = [BuiltInCategory.OST_Floors];
|
||||||
|
readonly BuiltInCategory[] columnsCategory = [
|
||||||
|
BuiltInCategory.OST_StructuralColumns,
|
||||||
|
BuiltInCategory.OST_Columns];
|
||||||
|
readonly BuiltInCategory[] mechanicalCategory = [
|
||||||
|
BuiltInCategory.OST_DuctCurves,
|
||||||
|
BuiltInCategory.OST_DuctAccessory,
|
||||||
|
BuiltInCategory.OST_DuctFitting,
|
||||||
|
BuiltInCategory.OST_DuctInsulations,
|
||||||
|
BuiltInCategory.OST_DuctTerminal,
|
||||||
|
BuiltInCategory.OST_FlexDuctCurves,
|
||||||
|
BuiltInCategory.OST_PlaceHolderDucts,BuiltInCategory.OST_MechanicalEquipment];
|
||||||
|
readonly BuiltInCategory[] pipingCategory = [
|
||||||
|
BuiltInCategory.OST_PipeCurves,
|
||||||
|
BuiltInCategory.OST_PipeFitting,
|
||||||
|
BuiltInCategory.OST_PipeAccessory,
|
||||||
|
BuiltInCategory.OST_PipeInsulations,
|
||||||
|
BuiltInCategory.OST_Sprinklers,
|
||||||
|
BuiltInCategory.OST_FlexPipeCurves,
|
||||||
|
BuiltInCategory.OST_PlaceHolderPipes,
|
||||||
|
BuiltInCategory.OST_PlumbingFixtures];
|
||||||
|
readonly BuiltInCategory[] cabletrayCategory = [
|
||||||
|
BuiltInCategory.OST_CableTray,
|
||||||
|
BuiltInCategory.OST_CableTrayFitting,];
|
||||||
|
readonly BuiltInCategory[] conduitCategory = [
|
||||||
|
BuiltInCategory.OST_Conduit,
|
||||||
|
BuiltInCategory.OST_ConduitFitting,];
|
||||||
|
|
||||||
private void UpdateCheckedState(Document doc)
|
private void UpdateCheckedState(Document doc)
|
||||||
{
|
{
|
||||||
@@ -251,14 +313,14 @@ public partial class VisibilityViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WallChecked = GetCheckedStatue(doc, BuiltInCategory.OST_Walls);
|
WallChecked = GetCheckedStatue(doc, wallCategory);
|
||||||
BeamChecked = GetCheckedStatue(doc, BuiltInCategory.OST_StructuralFraming);
|
BeamChecked = GetCheckedStatue(doc, beamCategory);
|
||||||
FloorChecked = GetCheckedStatue(doc, BuiltInCategory.OST_Floors);
|
FloorChecked = GetCheckedStatue(doc, floorCategory);
|
||||||
ColumnChecked = GetCheckedStatue(doc, BuiltInCategory.OST_StructuralColumns, BuiltInCategory.OST_Columns);
|
ColumnChecked = GetCheckedStatue(doc, columnsCategory);
|
||||||
MechanicalChecked = GetCheckedStatue(doc, BuiltInCategory.OST_DuctCurves, BuiltInCategory.OST_DuctAccessory, BuiltInCategory.OST_DuctFitting);
|
MechanicalChecked = GetCheckedStatue(doc, mechanicalCategory);
|
||||||
PlumbingChecked = GetCheckedStatue(doc, BuiltInCategory.OST_PipeCurves, BuiltInCategory.OST_PipeFitting, BuiltInCategory.OST_PipeAccessory, BuiltInCategory.OST_Sprinklers);
|
PlumbingChecked = GetCheckedStatue(doc, pipingCategory);
|
||||||
CableTrayChecked = GetCheckedStatue(doc, BuiltInCategory.OST_CableTray, BuiltInCategory.OST_CableTrayFitting);
|
CableTrayChecked = GetCheckedStatue(doc, cabletrayCategory);
|
||||||
ConduitChecked = GetCheckedStatue(doc, BuiltInCategory.OST_Conduit, BuiltInCategory.OST_ConduitFitting);
|
ConduitChecked = GetCheckedStatue(doc, conduitCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
|
|||||||
@@ -82,12 +82,13 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommunityToolkit.Common" Version="8.3.2" />
|
<PackageReference Include="CommunityToolkit.Common" Version="8.3.2" />
|
||||||
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.3.2" />
|
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.3.2" />
|
||||||
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
|
||||||
<PackageReference Include="EPPlus.Core.Extensions" Version="2.4.0" />
|
<PackageReference Include="EPPlus.Core.Extensions" Version="2.4.0" />
|
||||||
<PackageReference Include="ACadSharp" Version="1.0.0" />
|
<PackageReference Include="ACadSharp" Version="1.0.0" />
|
||||||
<PackageReference Include="FuzzySharp" Version="2.0.2" />
|
<PackageReference Include="FuzzySharp" Version="2.0.2" />
|
||||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.65" />
|
<PackageReference Include="HtmlAgilityPack" Version="1.11.65" />
|
||||||
<!--TreatAsUsed="true"标记为已使用-->
|
<!--TreatAsUsed="true"标记为已使用-->
|
||||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.122" TreatAsUsed="true" />
|
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.135" TreatAsUsed="true" />
|
||||||
<PackageReference Include="randomColorSharped.NetStandard" Version="1.0.2" />
|
<PackageReference Include="randomColorSharped.NetStandard" Version="1.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- <ItemGroup Condition="$(DefineConstants.Contains('WINFORMS'))"> -->
|
<!-- <ItemGroup Condition="$(DefineConstants.Contains('WINFORMS'))"> -->
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
using System.Drawing;
|
|
||||||
using System.Timers;
|
|
||||||
using Autodesk.Revit.Attributes;
|
|
||||||
using Autodesk.Revit.DB;
|
|
||||||
using Autodesk.Revit.UI;
|
|
||||||
using Nice3point.Revit.Toolkit.External;
|
|
||||||
using Sai.Toolkit.Core.Helpers;
|
|
||||||
|
|
||||||
namespace Sai.RvKits;
|
|
||||||
|
|
||||||
[Transaction(TransactionMode.Manual)]
|
|
||||||
[Regeneration(RegenerationOption.Manual)]
|
|
||||||
public class TestGDI : ExternalCommand
|
|
||||||
{
|
|
||||||
private UIView ui;
|
|
||||||
/// <summary>
|
|
||||||
/// 设置项目基点
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="position"></param>
|
|
||||||
private void SetProjectPosition(XYZ position)
|
|
||||||
{
|
|
||||||
using Transaction trans = new(Document);
|
|
||||||
trans.Start("设置项目基点");
|
|
||||||
XYZ p = new();
|
|
||||||
|
|
||||||
ProjectPosition pp = new(position.X, position.Y, position.Z, 0);
|
|
||||||
//设置项目基点
|
|
||||||
|
|
||||||
Document.ActiveProjectLocation.SetProjectPosition(p, pp);
|
|
||||||
trans.Commit();
|
|
||||||
}
|
|
||||||
public override void Execute()
|
|
||||||
{
|
|
||||||
|
|
||||||
ui = UiDocument.GetOpenUIViews().FirstOrDefault(uiView => uiView.ViewId == UiDocument.ActiveView.Id);
|
|
||||||
|
|
||||||
var corners = ui.GetZoomCorners();
|
|
||||||
//var inptr = HookInptr.FindWindow(null, view.Name);
|
|
||||||
//Graphics graphics = Graphics.FromHwnd(inptr);
|
|
||||||
|
|
||||||
//graphics.RenderingOrigin=
|
|
||||||
//Graphics graphics = Graphics.FromHwnd(System.Diagnostics.Process.GetCurrentProcess().Handle);
|
|
||||||
System.Timers.Timer timer =
|
|
||||||
new(2000)
|
|
||||||
{
|
|
||||||
Interval = 500,
|
|
||||||
Enabled = true
|
|
||||||
//AutoReset = true
|
|
||||||
};
|
|
||||||
timer.Elapsed += Timer_Elapsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
|
|
||||||
{
|
|
||||||
var rectangle = ui.GetWindowRectangle(); //屏幕坐标;原点在右上角
|
|
||||||
var graphics = Graphics.FromHwnd(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle);
|
|
||||||
var p = new System.Drawing.Point(rectangle.Left + 1920, rectangle.Top);
|
|
||||||
var p1 = new System.Drawing.Point(rectangle.Right + 1920, rectangle.Bottom);
|
|
||||||
GdiHelper.DrawLine(graphics, p, p1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -29,69 +29,69 @@ public class DrawingViewApp
|
|||||||
{
|
{
|
||||||
var ribbonPanel = application.CreateRibbonPanel(TabName, "视图与出图");
|
var ribbonPanel = application.CreateRibbonPanel(TabName, "视图与出图");
|
||||||
|
|
||||||
var autoAlignTags = UIAssist.NewButtonData<AlignTagsCmd>(
|
var autoAlignTags = UIAssist.NewPushButtonData<AlignTagsCmd>(
|
||||||
"对齐标记",
|
"对齐标记",
|
||||||
Resources.align_tags_32px,
|
Resources.align_tags_32px,
|
||||||
Resources.align_tags_16px
|
Resources.align_tags_16px
|
||||||
).SetAvailability<EnableInViewPlan>();
|
).SetAvailability<EnableInViewPlan>();
|
||||||
var arrangeTags = UIAssist.NewButtonData<ArrangeTagsCmd>(
|
var arrangeTags = UIAssist.NewPushButtonData<ArrangeTagsCmd>(
|
||||||
"整理标记",
|
"整理标记",
|
||||||
Resources.arrange_tags_32px,
|
Resources.arrange_tags_32px,
|
||||||
Resources.arrange_tags_16px
|
Resources.arrange_tags_16px
|
||||||
).SetAvailability<EnableInViewPlan>();
|
).SetAvailability<EnableInViewPlan>();
|
||||||
|
|
||||||
var dim2Line = UIAssist.NewButtonData<DimensionBy2LineCmd>(
|
var dim2Line = UIAssist.NewPushButtonData<DimensionBy2LineCmd>(
|
||||||
"双线标注",
|
"双线标注",
|
||||||
Resources.two_lines_32px,
|
Resources.two_lines_32px,
|
||||||
Resources.two_lines_16px,
|
Resources.two_lines_16px,
|
||||||
"选择要标注的两条平行的几何模型边缘线进行标注。"
|
"选择要标注的两条平行的几何模型边缘线进行标注。"
|
||||||
);
|
);
|
||||||
|
|
||||||
var visibilityControl = UIAssist.NewButtonData<VisibilityControlCmd>(
|
var visibilityControl = UIAssist.NewPushButtonData<VisibilityControlCmd>(
|
||||||
"可见性",
|
"可见性",
|
||||||
Resources.visibility_control_32px,
|
Resources.visibility_control_32px,
|
||||||
Resources.visibility_control_16px,
|
Resources.visibility_control_16px,
|
||||||
"可见性控制"
|
"可见性控制"
|
||||||
).SetAvailability<OnProjectDocument>();
|
).SetAvailability<OnProjectDocument>();
|
||||||
var sectionBox = UIAssist.NewButtonData<SectionBoxControllerCmd>(
|
var sectionBox = UIAssist.NewPushButtonData<SectionBoxControllerCmd>(
|
||||||
"剖面框",
|
"剖面框",
|
||||||
Resources.sectionBox_32px,
|
Resources.sectionBox_32px,
|
||||||
Resources.sectionBox_16px
|
Resources.sectionBox_16px
|
||||||
);
|
);
|
||||||
var filter = UIAssist.NewButtonData<CivilViewFilterCmd>(
|
var filter = UIAssist.NewPushButtonData<CivilViewFilterCmd>(
|
||||||
"过滤器",
|
"过滤器",
|
||||||
Resources.filter_32px,
|
Resources.filter_32px,
|
||||||
Resources.filter_16px,
|
Resources.filter_16px,
|
||||||
"创建当前视图的结构模型区分的过滤"
|
"创建当前视图的结构模型区分的过滤"
|
||||||
);
|
);
|
||||||
|
|
||||||
var panelSchedule = UIAssist.NewButtonData<PanelScheduleCmd>(
|
var panelSchedule = UIAssist.NewPushButtonData<PanelScheduleCmd>(
|
||||||
"铺砖明细表",
|
"铺砖明细表",
|
||||||
Resources.schedule_32px,
|
Resources.schedule_32px,
|
||||||
Resources.schedule_16px
|
Resources.schedule_16px
|
||||||
);
|
);
|
||||||
var exportSchedulesPbd = UIAssist.NewButtonData<ExportSchedulesCmd>(
|
var exportSchedulesPbd = UIAssist.NewPushButtonData<ExportSchedulesCmd>(
|
||||||
"导出明细表",
|
"导出明细表",
|
||||||
Resources.export_excel_32px,
|
Resources.export_excel_32px,
|
||||||
Resources.export_excel_16px,
|
Resources.export_excel_16px,
|
||||||
"导出明细表为Excel文件"
|
"导出明细表为Excel文件"
|
||||||
);
|
);
|
||||||
var systemDisplay = UIAssist.NewButtonData<SystemDisplayCmd>(
|
var systemDisplay = UIAssist.NewPushButtonData<SystemDisplayCmd>(
|
||||||
"系统显示",
|
"系统显示",
|
||||||
Resources.system_display_32px,
|
Resources.system_display_32px,
|
||||||
Resources.system_display_16px
|
Resources.system_display_16px
|
||||||
);
|
);
|
||||||
var viewManager = UIAssist.NewButtonData<ViewManagerCmd>(
|
var viewManager = UIAssist.NewPushButtonData<ViewManagerCmd>(
|
||||||
"视图管理",
|
"视图管理",
|
||||||
Resources.view_manager_32px,
|
Resources.view_manager_32px,
|
||||||
Resources.view_manager_16px
|
Resources.view_manager_16px
|
||||||
);
|
);
|
||||||
var quickViewSection = UIAssist.NewButtonData<QuickViewSectionCmd>(
|
var quickViewSection = UIAssist.NewPushButtonData<QuickViewSectionCmd>(
|
||||||
"快速剖面",
|
"快速剖面",
|
||||||
Resources.view_section_32px,
|
Resources.view_section_32px,
|
||||||
Resources.view_section_16px
|
Resources.view_section_16px
|
||||||
);
|
);
|
||||||
var elementsControlCmd = UIAssist.NewButtonData<ElementsControlCmd>(
|
var elementsControlCmd = UIAssist.NewPushButtonData<ElementsControlCmd>(
|
||||||
"元素控制",
|
"元素控制",
|
||||||
Resources.open_pane_32px,
|
Resources.open_pane_32px,
|
||||||
Resources.open_pane_32px,
|
Resources.open_pane_32px,
|
||||||
@@ -103,8 +103,9 @@ public class DrawingViewApp
|
|||||||
//ribbonPanel.AddSplitButton(splitBtn1, dim2Line, autoAlignTags, arrangeTags);
|
//ribbonPanel.AddSplitButton(splitBtn1, dim2Line, autoAlignTags, arrangeTags);
|
||||||
|
|
||||||
ribbonPanel.AddItem(elementsControlCmd);
|
ribbonPanel.AddItem(elementsControlCmd);
|
||||||
var tab = ComponentManager.Ribbon.Tabs.First(t => t.Name == TabName);
|
|
||||||
ribbonPanel.AddStackedItems(systemDisplay, viewManager, quickViewSection);
|
ribbonPanel.AddStackedItems(systemDisplay, viewManager, quickViewSection);
|
||||||
|
|
||||||
|
var tab = ComponentManager.Ribbon.Tabs.First(t => t.Name == TabName);
|
||||||
CreateToggleButton(tab, "视图与出图");
|
CreateToggleButton(tab, "视图与出图");
|
||||||
//面板下拉展开
|
//面板下拉展开
|
||||||
ribbonPanel.AddSlideOut();
|
ribbonPanel.AddSlideOut();
|
||||||
@@ -120,17 +121,21 @@ public class DrawingViewApp
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var panel = rt.Panels.FirstOrDefault(p => p.Source.Name == panelName);
|
var panel = rt.Panels.FirstOrDefault(p => p.Source.Name == panelName);
|
||||||
var tog = new Autodesk.Windows.RibbonToggleButton()
|
var tog = UIAssist.NewAwToggleButton(
|
||||||
{
|
"最大化",
|
||||||
LargeImage = Resources.zoom_32px.ToBitmapSource(),
|
Resources.zoom_32px,
|
||||||
Size = RibbonItemSize.Large,
|
"根据视图的图元是否可见,在切换视图时,对当前选中的图元进行快速缩放定位");
|
||||||
Name = "ZoomElement",
|
//var tog = new Autodesk.Windows.RibbonToggleButton()
|
||||||
Text = "最大化",
|
//{
|
||||||
ShowText = true,
|
// LargeImage = Resources.zoom_32px.ToBitmapSource(),
|
||||||
ToolTip = "根据视图的图元是否可见,在切换视图时,对当前选中的图元进行快速缩放定位",
|
// Size = RibbonItemSize.Large,
|
||||||
IsCheckable = true,
|
// Name = "ZoomElement",
|
||||||
Orientation = System.Windows.Controls.Orientation.Vertical,
|
// Text = "最大化",
|
||||||
};
|
// ShowText = true,
|
||||||
|
// ToolTip = "根据视图的图元是否可见,在切换视图时,对当前选中的图元进行快速缩放定位",
|
||||||
|
// IsCheckable = true,
|
||||||
|
// Orientation = System.Windows.Controls.Orientation.Vertical,
|
||||||
|
//};
|
||||||
tog.CheckStateChanged += (s, e) =>
|
tog.CheckStateChanged += (s, e) =>
|
||||||
{
|
{
|
||||||
zoomElementHandler.Raise(
|
zoomElementHandler.Raise(
|
||||||
@@ -153,7 +158,7 @@ public class DrawingViewApp
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
MessageBox.Show(exception.Message, "错误");
|
MessageBox.Show(exception.Message, "添加TogButton错误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static void RegisterDockPaneAndEvent(UIControlledApplication application)
|
private static void RegisterDockPaneAndEvent(UIControlledApplication application)
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ public class FamilyApp
|
|||||||
|
|
||||||
//application.CreateRibbonTab(TabName);
|
//application.CreateRibbonTab(TabName);
|
||||||
|
|
||||||
//UserPanel.AddItem(_loginPBData);
|
//UserPanel.AddAwItem(_loginPBData);
|
||||||
//".\\*.*"中的“.”表示通用类库文件所在的目录(Debug),“..”表示的是上级的目录(bin),“..”\\..,引号表示再上一级目录
|
//".\\*.*"中的“.”表示通用类库文件所在的目录(Debug),“..”表示的是上级的目录(bin),“..”\\..,引号表示再上一级目录
|
||||||
//ContextualHelp contextualHelp = new ContextualHelp(ContextualHelpType.Url, "https://www.szmedi.com.cn");
|
//ContextualHelp contextualHelp = new ContextualHelp(ContextualHelpType.Url, "https://www.szmedi.com.cn");
|
||||||
//_loginPBData.CreateContextualHelp(contextualHelp);
|
//_loginPBData.CreateContextualHelp(contextualHelp);
|
||||||
@@ -180,37 +180,37 @@ public class FamilyApp
|
|||||||
var familyManagePanel = application.CreateRibbonPanel(TabName, VbPanelName);
|
var familyManagePanel = application.CreateRibbonPanel(TabName, VbPanelName);
|
||||||
|
|
||||||
//在面板上添加添加浏览族库按钮
|
//在面板上添加添加浏览族库按钮
|
||||||
var localFamilyPbd = UIAssist.NewButtonData<FamilyLibraryCmd>(
|
var localFamilyPbd = UIAssist.NewPushButtonData<FamilyLibraryCmd>(
|
||||||
"本地族库",
|
"本地族库",
|
||||||
Resources.library_32px,
|
Resources.library_32px,
|
||||||
Resources.library_16px
|
Resources.library_16px
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
var familyMassSave = UIAssist.NewButtonData<FamilyProcessorCmd>(
|
var familyMassSave = UIAssist.NewPushButtonData<FamilyProcessorCmd>(
|
||||||
"族复用",
|
"族复用",
|
||||||
Resources.family_processor_32px,
|
Resources.family_processor_32px,
|
||||||
Resources.family_processor_16px
|
Resources.family_processor_16px
|
||||||
);
|
);
|
||||||
var replaceInstance = UIAssist.NewButtonData<ReplaceInstanceCmd>(
|
var replaceInstance = UIAssist.NewPushButtonData<ReplaceInstanceCmd>(
|
||||||
"替换族",
|
"替换族",
|
||||||
Resources.replace_32px,
|
Resources.replace_32px,
|
||||||
Resources.replace_16px
|
Resources.replace_16px
|
||||||
);
|
);
|
||||||
|
|
||||||
var updateFamilyFile = UIAssist.NewButtonData<UpgradeFamilyCmd>(
|
var updateFamilyFile = UIAssist.NewPushButtonData<UpgradeFamilyCmd>(
|
||||||
"更新族",
|
"更新族",
|
||||||
Resources.available_updates_32px,
|
Resources.available_updates_32px,
|
||||||
Resources.available_updates_16px,
|
Resources.available_updates_16px,
|
||||||
"更新族文件缩略图及升级至当前版本"
|
"更新族文件缩略图及升级至当前版本"
|
||||||
);
|
);
|
||||||
|
|
||||||
var renameFamily = UIAssist.NewButtonData<RenameFamilyNameCmd>(
|
var renameFamily = UIAssist.NewPushButtonData<RenameFamilyNameCmd>(
|
||||||
"重命名族",
|
"重命名族",
|
||||||
Resources.rename_family_32px,
|
Resources.rename_family_32px,
|
||||||
Resources.rename_family_16px
|
Resources.rename_family_16px
|
||||||
);
|
);
|
||||||
var renameType = UIAssist.NewButtonData<RenameTypeNameCmd>(
|
var renameType = UIAssist.NewPushButtonData<RenameTypeNameCmd>(
|
||||||
"重命名类型",
|
"重命名类型",
|
||||||
Resources.rename_type_32px,
|
Resources.rename_type_32px,
|
||||||
Resources.rename_type_16px
|
Resources.rename_type_16px
|
||||||
|
|||||||
@@ -536,7 +536,7 @@ public class ModifyTabApp
|
|||||||
};
|
};
|
||||||
//面板行布局
|
//面板行布局
|
||||||
RibbonRowPanel ribbonRowPanel = new();
|
RibbonRowPanel ribbonRowPanel = new();
|
||||||
ribbonRowPanel.AddStackItems(iavBtn, iipBtn, rSelBtn);
|
ribbonRowPanel.AddAwStackItems(iavBtn, iipBtn, rSelBtn);
|
||||||
|
|
||||||
//ribbonRowPanel.Items.Add(iavBtn);
|
//ribbonRowPanel.Items.Add(iavBtn);
|
||||||
////行打断=新建行
|
////行打断=新建行
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ namespace Sai.RvKits.UIRibbon;
|
|||||||
public class RvApp : ExternalApplication
|
public class RvApp : ExternalApplication
|
||||||
{
|
{
|
||||||
private static readonly string TabName = Settings.Default.TabName;
|
private static readonly string TabName = Settings.Default.TabName;
|
||||||
public static AsyncEventHandler SaveHandler { get; } = new();
|
private AsyncEventHandler saveHandler;
|
||||||
|
|
||||||
private static void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
|
private void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
SaveHandler.RaiseAsync(app =>
|
saveHandler.RaiseAsync(app =>
|
||||||
{
|
{
|
||||||
#if REVIT2018
|
#if REVIT2018
|
||||||
if (app.ActiveUIDocument.Document.IsModified)
|
if (app.ActiveUIDocument.Document.IsModified)
|
||||||
@@ -41,19 +41,9 @@ public class RvApp : ExternalApplication
|
|||||||
}
|
}
|
||||||
public override void OnStartup()
|
public override void OnStartup()
|
||||||
{
|
{
|
||||||
|
saveHandler = new();
|
||||||
UiApplication.CreateRibbonTab(Settings.Default.TabName);
|
UiApplication.CreateRibbonTab(Settings.Default.TabName);
|
||||||
|
|
||||||
var ribbon = Autodesk.Windows.ComponentManager.Ribbon;
|
|
||||||
Autodesk.Windows.RibbonTab rt = null;
|
|
||||||
foreach (var tab in ribbon.Tabs)
|
|
||||||
{
|
|
||||||
if (tab.Name == Settings.Default.TabName)
|
|
||||||
{
|
|
||||||
rt = tab;
|
|
||||||
ribbon.Tabs.Remove(tab);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var versionNumber = UiApplication.Application.VersionNumber;
|
var versionNumber = UiApplication.Application.VersionNumber;
|
||||||
var subVersionNumber = UiApplication.Application.SubVersionNumber;
|
var subVersionNumber = UiApplication.Application.SubVersionNumber;
|
||||||
var subVersion = new Version(subVersionNumber);
|
var subVersion = new Version(subVersionNumber);
|
||||||
@@ -62,6 +52,20 @@ public class RvApp : ExternalApplication
|
|||||||
{
|
{
|
||||||
MessageBox.Show("版本小于2018.1,部分功能可能无法使用,请使用升级补丁升级Revit软件", "提示");
|
MessageBox.Show("版本小于2018.1,部分功能可能无法使用,请使用升级补丁升级Revit软件", "提示");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ribbon = Autodesk.Windows.ComponentManager.Ribbon;
|
||||||
|
|
||||||
|
var rt = ribbon.Tabs.FirstOrDefault(tab => tab.Name == Settings.Default.TabName);
|
||||||
|
ribbon.Tabs.Remove(rt);
|
||||||
|
//foreach (var tab in ribbon.Tabs)
|
||||||
|
//{
|
||||||
|
// if (tab.Name == Settings.Default.TabName)
|
||||||
|
// {
|
||||||
|
// rt = tab;
|
||||||
|
// ribbon.Tabs.Remove(tab);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
ribbon.Tabs.Insert(0, rt);
|
ribbon.Tabs.Insert(0, rt);
|
||||||
|
|
||||||
CivilApp(Application);
|
CivilApp(Application);
|
||||||
@@ -86,49 +90,49 @@ public class RvApp : ExternalApplication
|
|||||||
{
|
{
|
||||||
var ribbonPanel = application.CreateRibbonPanel(TabName, "土建装饰");
|
var ribbonPanel = application.CreateRibbonPanel(TabName, "土建装饰");
|
||||||
|
|
||||||
var floorFinishesPbd = UIAssist.NewButtonData<FloorFinishesCmd>(
|
var floorFinishesPbd = UIAssist.NewPushButtonData<FloorFinishesCmd>(
|
||||||
"房间饰面",
|
"房间饰面",
|
||||||
Resources.tites_32px,
|
Resources.tites_32px,
|
||||||
Resources.tites_16px,
|
Resources.tites_16px,
|
||||||
"创建房间饰面"
|
"创建房间饰面"
|
||||||
);
|
);
|
||||||
var curtainFinishesPbd = UIAssist.NewButtonData<BricksFinishesCmd>(
|
var curtainFinishesPbd = UIAssist.NewPushButtonData<BricksFinishesCmd>(
|
||||||
"铺贴饰面",
|
"铺贴饰面",
|
||||||
Resources.finishes_32px,
|
Resources.finishes_32px,
|
||||||
Resources.finishes_16px
|
Resources.finishes_16px
|
||||||
);
|
);
|
||||||
var wallFinishesPbd = UIAssist.NewButtonData<WallFinishesCmd>(
|
var wallFinishesPbd = UIAssist.NewPushButtonData<WallFinishesCmd>(
|
||||||
"墙饰面",
|
"墙饰面",
|
||||||
Resources.bricks_32px,
|
Resources.bricks_32px,
|
||||||
Resources.bricks_16px
|
Resources.bricks_16px
|
||||||
);
|
);
|
||||||
|
|
||||||
var slopeFloorPbd = UIAssist.NewButtonData<SlopedFloorCmd>(
|
var slopeFloorPbd = UIAssist.NewPushButtonData<SlopedFloorCmd>(
|
||||||
"坡度楼板",
|
"坡度楼板",
|
||||||
Resources.slope_floor_32px,
|
Resources.slope_floor_32px,
|
||||||
Resources.slope_floor_16px,
|
Resources.slope_floor_16px,
|
||||||
"分别选择两个楼板的两条平行线创建坡度楼板"
|
"分别选择两个楼板的两条平行线创建坡度楼板"
|
||||||
);
|
);
|
||||||
|
|
||||||
var createOpeningsPbd = UIAssist.NewButtonData<CreateOpeningsCmd>(
|
var createOpeningsPbd = UIAssist.NewPushButtonData<CreateOpeningsCmd>(
|
||||||
"创建洞口",
|
"创建洞口",
|
||||||
Resources.openings_32px,
|
Resources.openings_32px,
|
||||||
Resources.openings_16px,
|
Resources.openings_16px,
|
||||||
"根据管线创建洞口"
|
"根据管线创建洞口"
|
||||||
).SetAvailability<EnableInView3D>();
|
).SetAvailability<EnableInView3D>();
|
||||||
var modelSplitPbd = UIAssist.NewButtonData<ModelSplitterCmd>(
|
var modelSplitPbd = UIAssist.NewPushButtonData<ModelSplitterCmd>(
|
||||||
"模型拆分",
|
"模型拆分",
|
||||||
Resources.separation_32px,
|
Resources.separation_32px,
|
||||||
Resources.separation_16px,
|
Resources.separation_16px,
|
||||||
"按标高拆分为单独的文件"
|
"按标高拆分为单独的文件"
|
||||||
);
|
);
|
||||||
var splitComPbd = UIAssist.NewButtonData<SplitComsByLevelCmd>(
|
var splitComPbd = UIAssist.NewPushButtonData<SplitComsByLevelCmd>(
|
||||||
"分割墙柱",
|
"分割墙柱",
|
||||||
Resources.model_split_32px,
|
Resources.model_split_32px,
|
||||||
Resources.model_split_16px,
|
Resources.model_split_16px,
|
||||||
"按标高拆分墙、柱"
|
"按标高拆分墙、柱"
|
||||||
);
|
);
|
||||||
var connectPbd = UIAssist.NewButtonData<CivilConnectionCmd>(
|
var connectPbd = UIAssist.NewPushButtonData<CivilConnectionCmd>(
|
||||||
"土建连接",
|
"土建连接",
|
||||||
Resources.connect_32px,
|
Resources.connect_32px,
|
||||||
Resources.connect_16px,
|
Resources.connect_16px,
|
||||||
@@ -147,68 +151,68 @@ public class RvApp : ExternalApplication
|
|||||||
null,
|
null,
|
||||||
Resources.stand_mepcurve_16px
|
Resources.stand_mepcurve_16px
|
||||||
).SetAvailability<EnableInViewPlan>();
|
).SetAvailability<EnableInViewPlan>();
|
||||||
var bloomConnector = UIAssist.NewButtonData<BloomConnectorCmd>("引出管线", null, Resources.bloom_16px, "从连接件生成管线");
|
var bloomConnector = UIAssist.NewPushButtonData<BloomConnectorCmd>("引出管线", null, Resources.bloom_16px, "从连接件生成管线");
|
||||||
var anyConnect = UIAssist.NewButtonData<AnyConnectCmd>("任意连接", null, Resources.any_connect_16px, "选择任意管线进行连接");
|
var anyConnect = UIAssist.NewPushButtonData<AnyConnectCmd>("任意连接", null, Resources.any_connect_16px, "选择任意管线进行连接");
|
||||||
var moveConnect = UIAssist.NewButtonData<MoveConnectCmd>(
|
var moveConnect = UIAssist.NewPushButtonData<MoveConnectCmd>(
|
||||||
"移动连接",
|
"移动连接",
|
||||||
null,
|
null,
|
||||||
Resources.move_connect_16px,
|
Resources.move_connect_16px,
|
||||||
"根据最近距离的未连接的连接件,将其连接或角度过大则对齐连接"
|
"根据最近距离的未连接的连接件,将其连接或角度过大则对齐连接"
|
||||||
);
|
);
|
||||||
var breakMepCurveBtn = UIAssist.NewButtonData<BreakMEPCurveCmd>(
|
var breakMepCurveBtn = UIAssist.NewPushButtonData<BreakMEPCurveCmd>(
|
||||||
"打断管线",
|
"打断管线",
|
||||||
null,
|
null,
|
||||||
Resources.break_mepcurve_16px,
|
Resources.break_mepcurve_16px,
|
||||||
"将管线打断成两根管线并保留打断后的连接关系"
|
"将管线打断成两根管线并保留打断后的连接关系"
|
||||||
);
|
);
|
||||||
var disConnect = UIAssist.NewButtonData<DisconnectCmd>(
|
var disConnect = UIAssist.NewPushButtonData<DisconnectCmd>(
|
||||||
"取消连接",
|
"取消连接",
|
||||||
null,
|
null,
|
||||||
Resources.disconnect_16px,
|
Resources.disconnect_16px,
|
||||||
"取消设备、管线之间的连接"
|
"取消设备、管线之间的连接"
|
||||||
);
|
);
|
||||||
var correctSlope = UIAssist.NewButtonData<CorrectMEPCurveSlopeCmd>(
|
var correctSlope = UIAssist.NewPushButtonData<CorrectMEPCurveSlopeCmd>(
|
||||||
"坡度修正",
|
"坡度修正",
|
||||||
null,
|
null,
|
||||||
Resources.correct_mep_16px,
|
Resources.correct_mep_16px,
|
||||||
"修正管线的坡度"
|
"修正管线的坡度"
|
||||||
);
|
);
|
||||||
|
|
||||||
var moveMEP = UIAssist.NewButtonData<MoveMEPCmd>(
|
var moveMEP = UIAssist.NewPushButtonData<MoveMEPCmd>(
|
||||||
"移动管线",
|
"移动管线",
|
||||||
Resources.move_MEP_32px,
|
Resources.move_MEP_32px,
|
||||||
Resources.move_MEP_16px,
|
Resources.move_MEP_16px,
|
||||||
"基于管线底部参照或距离,上下移动管线"
|
"基于管线底部参照或距离,上下移动管线"
|
||||||
);
|
);
|
||||||
var clashReport = UIAssist.NewButtonData<ClashReportCmd>(
|
var clashReport = UIAssist.NewPushButtonData<ClashReportCmd>(
|
||||||
"碰撞报告",
|
"碰撞报告",
|
||||||
Resources.clash_report_32px,
|
Resources.clash_report_32px,
|
||||||
Resources.clash_report_16px,
|
Resources.clash_report_16px,
|
||||||
"根据Revit生成的报告,快速定位碰撞构件"
|
"根据Revit生成的报告,快速定位碰撞构件"
|
||||||
);
|
);
|
||||||
var terminalConnect = UIAssist.NewButtonData<TerminalConnectToDuctCmd>(
|
var terminalConnect = UIAssist.NewPushButtonData<TerminalConnectToDuctCmd>(
|
||||||
"连接风口",
|
"连接风口",
|
||||||
Resources.air_terminal_32px,
|
Resources.air_terminal_32px,
|
||||||
Resources.air_terminal_16px
|
Resources.air_terminal_16px
|
||||||
);
|
);
|
||||||
var clashResolve = UIAssist.NewButtonData<ClashResolveCmd>(
|
var clashResolve = UIAssist.NewPushButtonData<ClashResolveCmd>(
|
||||||
"碰撞处理",
|
"碰撞处理",
|
||||||
Resources.clash_resolve_32px,
|
Resources.clash_resolve_32px,
|
||||||
Resources.clash_resolve_16px
|
Resources.clash_resolve_16px
|
||||||
);
|
);
|
||||||
|
|
||||||
var headroomCheck = UIAssist.NewButtonData<HeadroomCheckCmd>(
|
var headroomCheck = UIAssist.NewPushButtonData<HeadroomCheckCmd>(
|
||||||
"净高检查",
|
"净高检查",
|
||||||
Resources.head_room_32px,
|
Resources.head_room_32px,
|
||||||
Resources.head_room_16px
|
Resources.head_room_16px
|
||||||
);
|
);
|
||||||
var flipWorkplane = UIAssist.NewButtonData<FlipWorkplaneCmd>(
|
var flipWorkplane = UIAssist.NewPushButtonData<FlipWorkplaneCmd>(
|
||||||
"翻转工作平面",
|
"翻转工作平面",
|
||||||
Resources.flip_workplane_32px,
|
Resources.flip_workplane_32px,
|
||||||
Resources.flip_workplane_16px,
|
Resources.flip_workplane_16px,
|
||||||
"将可以翻转工作平面的族实例,翻转其工作平面"
|
"将可以翻转工作平面的族实例,翻转其工作平面"
|
||||||
);
|
);
|
||||||
var rotateInstance = UIAssist.NewButtonData<RotateInstanceCmd>(
|
var rotateInstance = UIAssist.NewPushButtonData<RotateInstanceCmd>(
|
||||||
"旋转实例",
|
"旋转实例",
|
||||||
Resources.rotate_instance_32px,
|
Resources.rotate_instance_32px,
|
||||||
Resources.rotate_instance_16px,
|
Resources.rotate_instance_16px,
|
||||||
@@ -240,45 +244,45 @@ public class RvApp : ExternalApplication
|
|||||||
// ImageUtil.ConvertToBitmapSource(Resources.entity_32px),
|
// ImageUtil.ConvertToBitmapSource(Resources.entity_32px),
|
||||||
// "存储内容到扩展数据"
|
// "存储内容到扩展数据"
|
||||||
// };
|
// };
|
||||||
var modelCheckPbd = UIAssist.NewButtonData<ModelCheckCmd>(
|
var modelCheckPbd = UIAssist.NewPushButtonData<ModelCheckCmd>(
|
||||||
"模型检查",
|
"模型检查",
|
||||||
Resources.model_check_16px,
|
Resources.model_check_16px,
|
||||||
Resources.model_check_32px,
|
Resources.model_check_32px,
|
||||||
"对模型进行多项要求的检查"
|
"对模型进行多项要求的检查"
|
||||||
);
|
);
|
||||||
var templateManager = UIAssist.NewButtonData<TemplateManagerCmd>(
|
var templateManager = UIAssist.NewPushButtonData<TemplateManagerCmd>(
|
||||||
"样板定制",
|
"样板定制",
|
||||||
Resources.template_32px,
|
Resources.template_32px,
|
||||||
Resources.template_16px,
|
Resources.template_16px,
|
||||||
"对项目样板进行批量处理"
|
"对项目样板进行批量处理"
|
||||||
);
|
);
|
||||||
|
|
||||||
var autoSavePbd = UIAssist.NewButtonData<AutoSaveCmd>("定时保存", Resources.save_32px, Resources.save_16px);
|
var autoSavePbd = UIAssist.NewPushButtonData<AutoSaveCmd>("定时保存", Resources.save_32px, Resources.save_16px);
|
||||||
var purgeBtn = UIAssist.NewButtonData<PureModelCmd>(
|
var purgeBtn = UIAssist.NewPushButtonData<PureModelCmd>(
|
||||||
"清理模型",
|
"清理模型",
|
||||||
Resources.purge_32px,
|
Resources.purge_32px,
|
||||||
Resources.purge_16px,
|
Resources.purge_16px,
|
||||||
"清理并压缩模型文件大小"
|
"清理并压缩模型文件大小"
|
||||||
);
|
);
|
||||||
var pipesCreatorPbd = UIAssist.NewButtonData<PipesCreatorCmd>(
|
var pipesCreatorPbd = UIAssist.NewPushButtonData<PipesCreatorCmd>(
|
||||||
"管线生成",
|
"管线生成",
|
||||||
Resources.pipe_creator_32px,
|
Resources.pipe_creator_32px,
|
||||||
Resources.pipe_creator_16px,
|
Resources.pipe_creator_16px,
|
||||||
"根据dwg图纸生成管线"
|
"根据dwg图纸生成管线"
|
||||||
);
|
);
|
||||||
var instanceCreatorPbd = UIAssist.NewButtonData<InstanceCreatorCmd>(
|
var instanceCreatorPbd = UIAssist.NewPushButtonData<InstanceCreatorCmd>(
|
||||||
"实例布置",
|
"实例布置",
|
||||||
Resources.instance_creator_32px,
|
Resources.instance_creator_32px,
|
||||||
Resources.instance_creator_16px,
|
Resources.instance_creator_16px,
|
||||||
"根据dwg块进行族实例布置"
|
"根据dwg块进行族实例布置"
|
||||||
);
|
);
|
||||||
var modelByCurveCreatorPbd = UIAssist.NewButtonData<ModelByCurveCreatorCmd>(
|
var modelByCurveCreatorPbd = UIAssist.NewPushButtonData<ModelByCurveCreatorCmd>(
|
||||||
"曲线布置",
|
"曲线布置",
|
||||||
Resources.model_by_curve_32px,
|
Resources.model_by_curve_32px,
|
||||||
Resources.model_by_curve_16px,
|
Resources.model_by_curve_16px,
|
||||||
"根据dwg曲线或模型线对轮廓族放样或者布置族实例"
|
"根据dwg曲线或模型线对轮廓族放样或者布置族实例"
|
||||||
);
|
);
|
||||||
var toggleBackgroundPbd = UIAssist.NewButtonData<SwitchBackgroundCmd>(
|
var toggleBackgroundPbd = UIAssist.NewPushButtonData<SwitchBackgroundCmd>(
|
||||||
"切换背景",
|
"切换背景",
|
||||||
Resources.background_32px,
|
Resources.background_32px,
|
||||||
Resources.background_16px,
|
Resources.background_16px,
|
||||||
@@ -290,13 +294,13 @@ public class RvApp : ExternalApplication
|
|||||||
ribbonPanel.AddStackedItems(instanceCreatorPbd, modelByCurveCreatorPbd, pipesCreatorPbd);
|
ribbonPanel.AddStackedItems(instanceCreatorPbd, modelByCurveCreatorPbd, pipesCreatorPbd);
|
||||||
ribbonPanel.AddStackedItems(toggleBackgroundPbd, purgeBtn, autoSavePbd);
|
ribbonPanel.AddStackedItems(toggleBackgroundPbd, purgeBtn, autoSavePbd);
|
||||||
|
|
||||||
//ribbonPanel.AddItem(toggleBackgroundPbd);
|
//ribbonPanel.AddAwItem(toggleBackgroundPbd);
|
||||||
//ribbonPanel.AddItem(autoSavePbd);
|
//ribbonPanel.AddAwItem(autoSavePbd);
|
||||||
|
|
||||||
//RadioButtonGroupData groupData = new RadioButtonGroupData("定位");
|
//RadioButtonGroupData groupData = new RadioButtonGroupData("定位");
|
||||||
//RadioButtonGroup radioBtnGroup = ribbonPanel.AddItem(groupData) as RadioButtonGroup;
|
//RadioButtonGroup radioBtnGroup = ribbonPanel.AddAwItem(groupData) as RadioButtonGroup;
|
||||||
//radioBtnGroup.AddItem(updateViewBySelectElemPbd);
|
//radioBtnGroup.AddAwItem(updateViewBySelectElemPbd);
|
||||||
//var tg2 = radioBtnGroup.AddItem(updateViewBySelectElemPbd);
|
//var tg2 = radioBtnGroup.AddAwItem(updateViewBySelectElemPbd);
|
||||||
//tg2.Visible = false;
|
//tg2.Visible = false;
|
||||||
//var group = ribbonPanel.AddRadioButtonGroup(groupData, updateViewBySelectElemPbd, updateViewBySelectElemPbd1);
|
//var group = ribbonPanel.AddRadioButtonGroup(groupData, updateViewBySelectElemPbd, updateViewBySelectElemPbd1);
|
||||||
}
|
}
|
||||||
@@ -304,27 +308,27 @@ public class RvApp : ExternalApplication
|
|||||||
private static void CreateIndependentTools(UIControlledApplication application)
|
private static void CreateIndependentTools(UIControlledApplication application)
|
||||||
{
|
{
|
||||||
var ribbonPanel = application.CreateRibbonPanel(TabName, "独立工具");
|
var ribbonPanel = application.CreateRibbonPanel(TabName, "独立工具");
|
||||||
var networkCreator = UIAssist.NewButtonData<NetworkCreatorCmd>(
|
var networkCreator = UIAssist.NewPushButtonData<NetworkCreatorCmd>(
|
||||||
"物探管网",
|
"物探管网",
|
||||||
Resources.pipe_net_32px,
|
Resources.pipe_net_32px,
|
||||||
Resources.pipe_net_16px
|
Resources.pipe_net_16px
|
||||||
);
|
);
|
||||||
var metroGauges = UIAssist.NewButtonData<MetroGaugesCmd>(
|
var metroGauges = UIAssist.NewPushButtonData<MetroGaugesCmd>(
|
||||||
"限界轮廓",
|
"限界轮廓",
|
||||||
Resources.gauges_32px,
|
Resources.gauges_32px,
|
||||||
Resources.gauges_16px,
|
Resources.gauges_16px,
|
||||||
"创建限界轮廓"
|
"创建限界轮廓"
|
||||||
);
|
);
|
||||||
var metroTunnel = UIAssist.NewButtonData<MetroTunnelCmd>(
|
var metroTunnel = UIAssist.NewPushButtonData<MetroTunnelCmd>(
|
||||||
"盾构隧道",
|
"盾构隧道",
|
||||||
Resources.gauges_32px,
|
Resources.gauges_32px,
|
||||||
Resources.gauges_16px,
|
Resources.gauges_16px,
|
||||||
"创建盾构隧道"
|
"创建盾构隧道"
|
||||||
);
|
);
|
||||||
ribbonPanel.AddSplitButton("独立工具", networkCreator, metroTunnel, metroGauges);
|
ribbonPanel.AddSplitButton("独立工具", networkCreator, metroTunnel, metroGauges);
|
||||||
//ribbonPanel.AddItem(networkCreator);
|
//ribbonPanel.AddAwItem(networkCreator);
|
||||||
//ribbonPanel.AddItem(metroGauges);
|
//ribbonPanel.AddAwItem(metroGauges);
|
||||||
//ribbonPanel.AddItem(metroTunnel);
|
//ribbonPanel.AddAwItem(metroTunnel);
|
||||||
//ribbonPanel.AddSplitButton("独立工具", networkCreator, metroGauges, metroTunnel);
|
//ribbonPanel.AddSplitButton("独立工具", networkCreator, metroGauges, metroTunnel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public class TabManagerApp
|
|||||||
// if (obj is Autodesk.Windows.RibbonButton rb)
|
// if (obj is Autodesk.Windows.RibbonButton rb)
|
||||||
// {
|
// {
|
||||||
// string tabName = rb.CommandParameter.ToString();
|
// string tabName = rb.CommandParameter.ToString();
|
||||||
// var ribbonTab = ribbon.FindTab(tabName);
|
// var ribbonTab = ribbon.FindAwTab(tabName);
|
||||||
// ribbonTab.IsVisible = true;
|
// ribbonTab.IsVisible = true;
|
||||||
// }
|
// }
|
||||||
//}),
|
//}),
|
||||||
@@ -115,7 +115,7 @@ public class TabManagerApp
|
|||||||
//如果是族文档,在激活视图时,隐藏面板
|
//如果是族文档,在激活视图时,隐藏面板
|
||||||
private static void SetTabEnabled(string tabName, bool isVisible)
|
private static void SetTabEnabled(string tabName, bool isVisible)
|
||||||
{
|
{
|
||||||
//Autodesk.Windows.RibbonTab revitRibbonTab = UIFramework.RevitRibbonControl.RibbonControl.FindTab(Properties.Settings.Default.TabName);
|
//Autodesk.Windows.RibbonTab revitRibbonTab = UIFramework.RevitRibbonControl.RibbonControl.FindAwTab(Properties.Settings.Default.TabName);
|
||||||
//revitRibbonTab.IsVisible = false;
|
//revitRibbonTab.IsVisible = false;
|
||||||
var ribbon = ComponentManager.Ribbon;
|
var ribbon = ComponentManager.Ribbon;
|
||||||
var ribbonTab = ribbon.FindTab(tabName);
|
var ribbonTab = ribbon.FindTab(tabName);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace Sai.RvKits;
|
|||||||
|
|
||||||
public static class Variables
|
public static class Variables
|
||||||
{
|
{
|
||||||
public static readonly string AddInPath = Assembly.GetExecutingAssembly().Location;
|
public static string AddInPath => Assembly.GetExecutingAssembly().Location;
|
||||||
|
|
||||||
// public static IntPtr RevitWindowPtr
|
// public static IntPtr RevitWindowPtr
|
||||||
//{
|
//{
|
||||||
@@ -18,10 +18,9 @@ public static class Variables
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
//public static readonly string DllPath = typeof(Variables).Assembly.Location;
|
//public static readonly string DllPath = typeof(Variables).Assembly.Location;
|
||||||
public static string DirAssembly = Path.GetDirectoryName(AddInPath);
|
public static string DirAssembly => Path.GetDirectoryName(AddInPath);
|
||||||
public static string FamilyFolder = $@"{DirAssembly}\Libraries\";
|
public static string FamilyFolder => Path.Combine(DirAssembly, "Libraries");
|
||||||
public static string LogFolder = $@"{DirAssembly}\Log\";
|
public static DockablePaneId PaneId => new(new Guid(Properties.Settings.Default.DockPaneGuid));
|
||||||
public static DockablePaneId PaneId { get; } = new(new Guid(Properties.Settings.Default.DockPaneGuid));
|
public static System.Timers.Timer Timer => new();
|
||||||
public static System.Timers.Timer Timer { get; } = new();
|
|
||||||
public static SnackbarPresenter SnackbarPresenter { get; set; }
|
public static SnackbarPresenter SnackbarPresenter { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class IniHelper
|
|||||||
public string IniReadValue(string section, string key)
|
public string IniReadValue(string section, string key)
|
||||||
{
|
{
|
||||||
var temp = new StringBuilder(255);
|
var temp = new StringBuilder(255);
|
||||||
var i = GetPrivateProfileString(section, key, "", temp, 255, path);
|
GetPrivateProfileString(section, key, "", temp, 255, path);
|
||||||
return temp.ToString();
|
return temp.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public static class LogHelper
|
|||||||
{
|
{
|
||||||
var assemblyPath = typeof(LogHelper).Assembly.Location;
|
var assemblyPath = typeof(LogHelper).Assembly.Location;
|
||||||
var directory = Path.GetDirectoryName(assemblyPath);
|
var directory = Path.GetDirectoryName(assemblyPath);
|
||||||
logFolder = $"{directory}\\Logs";
|
logFolder = Path.Combine(directory, "Logs");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Directory.Exists(logFolder))
|
if (!Directory.Exists(logFolder))
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace Sai.Toolkit.Core.Helpers;
|
|||||||
public sealed record SingletonViewHelper<T>
|
public sealed record SingletonViewHelper<T>
|
||||||
where T : Window, new()
|
where T : Window, new()
|
||||||
{
|
{
|
||||||
private static T instance;
|
private static T _instance;
|
||||||
private static readonly object Padlock = new();
|
private static readonly object Padlock = new();
|
||||||
|
|
||||||
private SingletonViewHelper() { }
|
private SingletonViewHelper() { }
|
||||||
@@ -15,21 +15,21 @@ public sealed record SingletonViewHelper<T>
|
|||||||
{
|
{
|
||||||
isNewCreate = false;
|
isNewCreate = false;
|
||||||
//double-check locking
|
//double-check locking
|
||||||
if (instance == null)
|
if (_instance == null)
|
||||||
{
|
{
|
||||||
isNewCreate = true;
|
isNewCreate = true;
|
||||||
lock (Padlock)
|
lock (Padlock)
|
||||||
{
|
{
|
||||||
instance ??= new T();
|
_instance ??= new T();
|
||||||
instance.Closed += OnWindowClosed;
|
_instance.Closed += OnWindowClosed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnWindowClosed(object sender, EventArgs e)
|
private static void OnWindowClosed(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
instance = null;
|
_instance = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ public class StringHelper
|
|||||||
//StringFormat={}{0:m} May 04
|
//StringFormat={}{0:m} May 04
|
||||||
//StringFormat={}{0:Distinct} May 04
|
//StringFormat={}{0:Distinct} May 04
|
||||||
//StringFormat={}{0:t} 5:46 PM
|
//StringFormat={}{0:t} 5:46 PM
|
||||||
//StringFormat={}{0:T} 5:46:56 PM
|
//StringFormat={}{0:Command} 5:46:56 PM
|
||||||
//StringFormat={}{0:yyyy年MM月dd日} 2015年05月04日
|
//StringFormat={}{0:yyyy年MM月dd日} 2015年05月04日
|
||||||
//StringFormat={}{0:yyyy-MM-dd} 2015-05-04
|
//StringFormat={}{0:yyyy-MM-dd} 2015-05-04
|
||||||
//StringFormat={}{0:yyyy-MM-dd HH:mm} 2015-05-04 17:46
|
//StringFormat={}{0:yyyy-MM-dd HH:mm} 2015-05-04 17:46
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public static class WinDialogHelper
|
|||||||
//loaderUtil.HookAssemblyResolve();
|
//loaderUtil.HookAssemblyResolve();
|
||||||
//try
|
//try
|
||||||
//{
|
//{
|
||||||
// var view = SingletonViewHelper<T>.GetInstance(out var isNewCreate);
|
// var view = SingletonViewHelper<Command>.GetInstance(out var isNewCreate);
|
||||||
// if (isNewCreate)
|
// if (isNewCreate)
|
||||||
// {
|
// {
|
||||||
// view.DataContext = viewModel;
|
// view.DataContext = viewModel;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class XmlHelper
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建配置文件,可在子类中重写此方法
|
/// 创建配置文件,可在子类中重写此方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CreateFile(string fileName)
|
public static void CreateFile(string fileName)
|
||||||
{
|
{
|
||||||
var doc = new XmlDocument();
|
var doc = new XmlDocument();
|
||||||
var dec = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
|
var dec = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
|
||||||
|
|||||||
@@ -111,8 +111,8 @@ public static class ExtensibleStorageAssist
|
|||||||
throw new ArgumentNullException(nameof(fieldName));
|
throw new ArgumentNullException(nameof(fieldName));
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (!typeof(T).IsPrimitive)
|
//if (!typeof(Command).IsPrimitive)
|
||||||
// throw new NotSupportedException(nameof(T));
|
// throw new NotSupportedException(nameof(Command));
|
||||||
|
|
||||||
var result = schemaBuilder.AddArrayField(fieldName, typeof(T));
|
var result = schemaBuilder.AddArrayField(fieldName, typeof(T));
|
||||||
if (description == string.Empty)
|
if (description == string.Empty)
|
||||||
@@ -144,8 +144,8 @@ public static class ExtensibleStorageAssist
|
|||||||
throw new ArgumentNullException(nameof(fieldName));
|
throw new ArgumentNullException(nameof(fieldName));
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (!typeof(T).IsPrimitive)
|
//if (!typeof(Command).IsPrimitive)
|
||||||
// throw new NotSupportedException(nameof(T));
|
// throw new NotSupportedException(nameof(Command));
|
||||||
|
|
||||||
var result = schemaBuilder.AddSimpleField(fieldName, typeof(T));
|
var result = schemaBuilder.AddSimpleField(fieldName, typeof(T));
|
||||||
//result.SetUnitType(unitType);
|
//result.SetUnitType(unitType);
|
||||||
@@ -340,7 +340,7 @@ public static class ExtensibleStorageAssist
|
|||||||
// Entity ent = e.GetEntity(schema);
|
// Entity ent = e.GetEntity(schema);
|
||||||
// foreach (var field in fields)
|
// foreach (var field in fields)
|
||||||
// {
|
// {
|
||||||
// var f = ent.Get<T>(field);
|
// var f = ent.Get<Command>(field);
|
||||||
// storages.Add(f);
|
// storages.Add(f);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Autodesk.Revit.DB;
|
using Autodesk.Revit.DB;
|
||||||
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
|
|
||||||
namespace Sai.Toolkit.Revit.Assist;
|
namespace Sai.Toolkit.Revit.Assist;
|
||||||
|
|
||||||
@@ -14,7 +13,7 @@ internal static class HostObjectAssist
|
|||||||
public static List<Sketch> GetSketch(this HostObject element)
|
public static List<Sketch> GetSketch(this HostObject element)
|
||||||
{
|
{
|
||||||
var doc = element.Document;
|
var doc = element.Document;
|
||||||
List<Sketch> sketches = new();
|
List<Sketch> sketches = [];
|
||||||
using (SubTransaction subTransaction = new(doc))
|
using (SubTransaction subTransaction = new(doc))
|
||||||
{
|
{
|
||||||
subTransaction.Start();
|
subTransaction.Start();
|
||||||
|
|||||||
@@ -54,11 +54,9 @@ public static class ImageAssist
|
|||||||
|
|
||||||
public static BitmapSource ToBitmapSource(this Bitmap bitmap)
|
public static BitmapSource ToBitmapSource(this Bitmap bitmap)
|
||||||
{
|
{
|
||||||
if (bitmap == null)
|
return bitmap == null
|
||||||
{
|
? null
|
||||||
return null;
|
: Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
|
||||||
}
|
|
||||||
return Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
10
Sai.Toolkit.Revit/Assist/JIGAssist.cs
Normal file
10
Sai.Toolkit.Revit/Assist/JIGAssist.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Sai.Toolkit.Revit.Assist
|
||||||
|
{
|
||||||
|
internal class JIGAssist
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@ using System.Diagnostics;
|
|||||||
|
|
||||||
using Autodesk.Revit.DB;
|
using Autodesk.Revit.DB;
|
||||||
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
|
|
||||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
|
||||||
|
|
||||||
@@ -149,7 +148,6 @@ public static class SpatialAssist
|
|||||||
/// <summary>创建一个新的实体,它是输入实体的副本</summary>
|
/// <summary>创建一个新的实体,它是输入实体的副本</summary>
|
||||||
/// <param name="solid">要复制的输入实体</param>
|
/// <param name="solid">要复制的输入实体</param>
|
||||||
/// <returns>新的实体</returns>
|
/// <returns>新的实体</returns>
|
||||||
[Pure]
|
|
||||||
public static Solid Clone(this Solid solid)
|
public static Solid Clone(this Solid solid)
|
||||||
{
|
{
|
||||||
return SolidUtils.Clone(solid);
|
return SolidUtils.Clone(solid);
|
||||||
@@ -159,11 +157,10 @@ public static class SpatialAssist
|
|||||||
/// <param name="solid">要转换的输入实体</param>
|
/// <param name="solid">要转换的输入实体</param>
|
||||||
/// <param name="transform">变换(必须是保角变换)</param>
|
/// <param name="transform">变换(必须是保角变换)</param>
|
||||||
/// <returns>新的实体</returns>
|
/// <returns>新的实体</returns>
|
||||||
/// <exception cref="T:Autodesk.Revit.Exceptions.ArgumentOutOfRangeException">
|
/// <exception cref="Command:Autodesk.Revit.Exceptions.ArgumentOutOfRangeException">
|
||||||
/// 变换不保形。
|
/// 变换不保形。
|
||||||
/// 或变换的比例为负或零
|
/// 或变换的比例为负或零
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
|
||||||
public static Solid CreateTransformed(this Solid solid, Transform transform)
|
public static Solid CreateTransformed(this Solid solid, Transform transform)
|
||||||
{
|
{
|
||||||
return SolidUtils.CreateTransformed(solid, transform);
|
return SolidUtils.CreateTransformed(solid, transform);
|
||||||
@@ -431,13 +428,13 @@ public static class SpatialAssist
|
|||||||
public static List<List<Curve>> ToCurveLoops(List<Curve> curves)
|
public static List<List<Curve>> ToCurveLoops(List<Curve> curves)
|
||||||
{
|
{
|
||||||
|
|
||||||
List<List<Curve>> list = new();
|
List<List<Curve>> list = [];
|
||||||
while (curves.Any())
|
while (curves.Any())
|
||||||
{
|
{
|
||||||
_curvesSorted = new()
|
_curvesSorted =
|
||||||
{
|
[
|
||||||
curves[0]
|
curves[0]
|
||||||
};
|
];
|
||||||
if (!curves[0].IsBound)
|
if (!curves[0].IsBound)
|
||||||
{
|
{
|
||||||
curves.Remove(curves[0]);
|
curves.Remove(curves[0]);
|
||||||
@@ -1382,10 +1379,9 @@ public static class SpatialAssist
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="solid">The solid</param>
|
/// <param name="solid">The solid</param>
|
||||||
/// <returns>分割实体几何图形</returns>
|
/// <returns>分割实体几何图形</returns>
|
||||||
/// <exception cref="T:Autodesk.Revit.Exceptions.InvalidOperationException">
|
/// <exception cref="Command:Autodesk.Revit.Exceptions.InvalidOperationException">
|
||||||
/// 分割实体几何体失败
|
/// 分割实体几何体失败
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
|
||||||
public static IList<Solid> SplitVolumes(this Solid solid)
|
public static IList<Solid> SplitVolumes(this Solid solid)
|
||||||
{
|
{
|
||||||
return SolidUtils.SplitVolumes(solid);
|
return SolidUtils.SplitVolumes(solid);
|
||||||
@@ -1409,10 +1405,10 @@ public static class SpatialAssist
|
|||||||
/// 与输入实体的边界成分或输入壳体的成分相对应的三角形结构
|
/// 与输入实体的边界成分或输入壳体的成分相对应的三角形结构
|
||||||
/// 输入实体或输入壳体的分量
|
/// 输入实体或输入壳体的分量
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="T:Autodesk.Revit.Exceptions.ArgumentException">
|
/// <exception cref="Command:Autodesk.Revit.Exceptions.ArgumentException">
|
||||||
/// solidOrShell 对三角剖分无效(例如,它不包含任何面)
|
/// solidOrShell 对三角剖分无效(例如,它不包含任何面)
|
||||||
/// </exception>
|
/// </exception>
|
||||||
/// <exception cref="T:Autodesk.Revit.Exceptions.InvalidOperationException">
|
/// <exception cref="Command:Autodesk.Revit.Exceptions.InvalidOperationException">
|
||||||
/// 无法对实体或外壳进行三角测量
|
/// 无法对实体或外壳进行三角测量
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public static TriangulatedSolidOrShell TessellateSolidOrShell(this Solid solid, SolidOrShellTessellationControls tessellationControls)
|
public static TriangulatedSolidOrShell TessellateSolidOrShell(this Solid solid, SolidOrShellTessellationControls tessellationControls)
|
||||||
|
|||||||
@@ -4,18 +4,22 @@ using System.IO;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Input;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
using Autodesk.Revit.DB;
|
using Autodesk.Revit.DB;
|
||||||
using Autodesk.Revit.UI;
|
using Autodesk.Revit.UI;
|
||||||
|
using adWin = Autodesk.Windows;
|
||||||
|
|
||||||
|
using CommunityToolkit.Diagnostics;
|
||||||
|
|
||||||
using UIFramework;
|
using UIFramework;
|
||||||
|
|
||||||
using UIFrameworkServices;
|
using UIFrameworkServices;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using Sai.Toolkit.Mvvm.Attributes;
|
||||||
|
|
||||||
using adWin = Autodesk.Windows;
|
|
||||||
|
|
||||||
namespace Sai.Toolkit.Revit.Assist;
|
namespace Sai.Toolkit.Revit.Assist;
|
||||||
|
|
||||||
@@ -23,15 +27,55 @@ public static class UIAssist
|
|||||||
{
|
{
|
||||||
private static readonly string AddInPath = typeof(UIAssist).Assembly.Location;
|
private static readonly string AddInPath = typeof(UIAssist).Assembly.Location;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找内容
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hwndParent"></param>
|
||||||
|
/// <param name="hwndChildAfter"></param>
|
||||||
|
/// <param name="lpszClass"></param>
|
||||||
|
/// <param name="lpszWindow"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[DllImport("user32.dll", EntryPoint = "FindWindowEx", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||||
|
private static extern IntPtr FindWindowEx(
|
||||||
|
IntPtr hwndParent,
|
||||||
|
IntPtr hwndChildAfter,
|
||||||
|
string lpszClass,
|
||||||
|
string lpszWindow
|
||||||
|
);
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||||
private static extern bool SetWindowText(IntPtr hWnd, string lpString);
|
private static extern bool SetWindowText(IntPtr hWnd, string lpString);
|
||||||
private static BitmapSource ToBitmapSource(Bitmap bitmap)
|
|
||||||
|
/// <summary>
|
||||||
|
/// 面板上添加项
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="panel"></param>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
public static void AddAwItem(this adWin.RibbonPanel panel, adWin.RibbonItem item)
|
||||||
{
|
{
|
||||||
return bitmap == null
|
panel.Source.Items.Add(item);
|
||||||
? null
|
|
||||||
: Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加堆叠按钮组
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rowPanel"></param>
|
||||||
|
/// <param name="ribbonButtons"></param>
|
||||||
|
public static void AddAwStackItems(this adWin.RibbonRowPanel rowPanel, params adWin.RibbonButton[] ribbonButtons)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < ribbonButtons.Length; i++)
|
||||||
|
{
|
||||||
|
rowPanel.Items.Add(ribbonButtons[i]);
|
||||||
|
//添加一个,打断一次
|
||||||
|
if (i < ribbonButtons.Length - 1)
|
||||||
|
{
|
||||||
|
//行打断=新建行
|
||||||
|
rowPanel.Items.Add(new adWin.RibbonRowBreak());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Combobox是可以分组的
|
/// Combobox是可以分组的
|
||||||
/// 组合框是与事件结合使用的
|
/// 组合框是与事件结合使用的
|
||||||
@@ -57,27 +101,7 @@ public static class UIAssist
|
|||||||
};
|
};
|
||||||
return comboBx;
|
return comboBx;
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// 在Revit现有的标签下(如不存在则创建),创建创建面板
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="application"></param>
|
|
||||||
/// <param name="panelName">创建的面板名称</param>
|
|
||||||
/// <param name="tabName">若Tab不存在,则创建对应名称的Tab</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static RibbonPanel AddPanel(this UIControlledApplication application, string panelName, string tabName)
|
|
||||||
{
|
|
||||||
var ribbonTab = adWin.ComponentManager.Ribbon.Tabs.FirstOrDefault(tab => tab.Id.Equals(tabName));
|
|
||||||
|
|
||||||
if (ribbonTab is null)
|
|
||||||
{
|
|
||||||
application.CreateRibbonTab(tabName);
|
|
||||||
return application.CreateRibbonPanel(tabName, panelName);
|
|
||||||
}
|
|
||||||
|
|
||||||
var ribbonPanel = application.GetRibbonPanels(tabName).Find(panel => panel.Name.Equals(panelName));
|
|
||||||
|
|
||||||
return ribbonPanel ?? application.CreateRibbonPanel(tabName, panelName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建一个下拉式按钮。
|
/// 创建一个下拉式按钮。
|
||||||
@@ -146,37 +170,6 @@ public static class UIAssist
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 单选框
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pnl">面板</param>
|
|
||||||
/// <param name="groupName">分组名称</param>
|
|
||||||
/// <param name="toggleButtonData"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static RadioButtonGroup AddRadioButtonGroup(
|
|
||||||
this RibbonPanel pnl,
|
|
||||||
string groupName,
|
|
||||||
params ToggleButtonData[] toggleButtonData
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (pnl is null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(pnl));
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(groupName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(groupName));
|
|
||||||
}
|
|
||||||
RadioButtonGroupData groupData = new(groupName);
|
|
||||||
var radioButtonGroup = (RadioButtonGroup)pnl.AddItem(groupData);
|
|
||||||
foreach (var data in toggleButtonData)
|
|
||||||
{
|
|
||||||
radioButtonGroup.AddItem(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return radioButtonGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建一个分割记忆按钮。
|
/// 创建一个分割记忆按钮。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -220,18 +213,7 @@ public static class UIAssist
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static void AddStackItems(this adWin.RibbonRowPanel rowPanel, params adWin.RibbonButton[] ribbonButtons)
|
|
||||||
{
|
|
||||||
for (var i = 0; i < ribbonButtons.Length; i++)
|
|
||||||
{
|
|
||||||
rowPanel.Items.Add(ribbonButtons[i]);
|
|
||||||
if (i < ribbonButtons.Length - 1)
|
|
||||||
{
|
|
||||||
//行打断=新建行
|
|
||||||
rowPanel.Items.Add(new adWin.RibbonRowBreak());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void AddTextBox(this RibbonPanel panel, TextBoxData txtBoxData)
|
public static void AddTextBox(this RibbonPanel panel, TextBoxData txtBoxData)
|
||||||
{
|
{
|
||||||
@@ -247,13 +229,38 @@ public static class UIAssist
|
|||||||
};
|
};
|
||||||
txtBox.Width = 180;
|
txtBox.Width = 180;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
public static ToggleButton AddToggleButton<T>(this RadioButtonGroup group, string name)
|
/// 在Revit现有的标签下(如不存在则创建),创建创建面板
|
||||||
where T : IExternalCommand
|
/// </summary>
|
||||||
|
/// <param name="application"></param>
|
||||||
|
/// <param name="panelName">创建的面板名称</param>
|
||||||
|
/// <param name="tabName">若Tab不存在,则创建对应名称的Tab</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static RibbonPanel AddUIPanel(this UIControlledApplication application, string tabName, string panelName)
|
||||||
{
|
{
|
||||||
//var addInPath = typeof(T).Assembly.Location;
|
var ribbonTab = adWin.ComponentManager.Ribbon.Tabs.FirstOrDefault(tab => tab.Id.Equals(tabName));
|
||||||
var toggleData = new ToggleButtonData(name, name, typeof(T).Assembly.Location, typeof(T).FullName);
|
|
||||||
return group.AddItem(toggleData);
|
if (ribbonTab == null)
|
||||||
|
{
|
||||||
|
application.CreateRibbonTab(tabName);
|
||||||
|
return application.CreateRibbonPanel(tabName, panelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
var ribbonPanel = application.GetRibbonPanels(tabName).Find(panel => panel.Name.Equals(panelName));
|
||||||
|
|
||||||
|
return ribbonPanel ?? application.CreateRibbonPanel(tabName, panelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static adWin.RibbonItem ConvertToAwRibbonItem(this RibbonButton btn)
|
||||||
|
{
|
||||||
|
return (adWin.RibbonItem)btn.GetType()
|
||||||
|
.InvokeMember(
|
||||||
|
"getRibbonItem",
|
||||||
|
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod,
|
||||||
|
Type.DefaultBinder,
|
||||||
|
btn,
|
||||||
|
null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -287,26 +294,82 @@ public static class UIAssist
|
|||||||
{
|
{
|
||||||
return new PushButtonData(typeof(T).FullName, name, typeof(T).Assembly.Location, typeof(T).FullName);
|
return new PushButtonData(typeof(T).FullName, name, typeof(T).Assembly.Location, typeof(T).FullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找内容
|
/// 查找面板
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hwndParent"></param>
|
/// <param name="rt"></param>
|
||||||
/// <param name="hwndChildAfter"></param>
|
/// <param name="panelName"></param>
|
||||||
/// <param name="lpszClass"></param>
|
|
||||||
/// <param name="lpszWindow"></param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[DllImport("user32.dll", EntryPoint = "FindWindowEx", SetLastError = true, CharSet = CharSet.Unicode)]
|
public static adWin.RibbonPanel FindAwPanel(this adWin.RibbonTab rt, string panelName)
|
||||||
private static extern IntPtr FindWindowEx(
|
{
|
||||||
IntPtr hwndParent,
|
return rt.Panels.FirstOrDefault(p => p.Source.Name == panelName);
|
||||||
IntPtr hwndChildAfter,
|
}
|
||||||
string lpszClass,
|
/// <summary>
|
||||||
string lpszWindow
|
/// 查找Tab
|
||||||
);
|
/// </summary>
|
||||||
|
/// <param name="tabName">标签名</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static adWin.RibbonTab FindAwTab(string tabName)
|
||||||
|
{
|
||||||
|
return adWin.ComponentManager.Ribbon.Tabs.FirstOrDefault(tab => tab.Id.Equals(tabName));
|
||||||
|
}
|
||||||
|
|
||||||
public static ToggleButton GetToggleButton(this RadioButtonGroup radioButtonGroup)
|
public static ToggleButton GetToggleButton(this RadioButtonGroup radioButtonGroup)
|
||||||
{
|
{
|
||||||
return radioButtonGroup.Current;
|
return radioButtonGroup.Current;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 创建按钮
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="showText"></param>
|
||||||
|
/// <param name="largeImage"></param>
|
||||||
|
/// <param name="image"></param>
|
||||||
|
/// <param name="command">RelayCommand</param>
|
||||||
|
/// <param name="parameter">命令的参数</param>
|
||||||
|
/// <param name="toolTip"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static adWin.RibbonButton NewAwButton(string showText, Bitmap largeImage, Bitmap image, ICommand command, object parameter, string toolTip = default)
|
||||||
|
{
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Image = image.ToBitmapSource(),
|
||||||
|
LargeImage = largeImage.ToBitmapSource(),
|
||||||
|
Size = adWin.RibbonItemSize.Standard,
|
||||||
|
ShowText = true,
|
||||||
|
Id = $"ID_{showText}",
|
||||||
|
Name = $"Btn_{showText}",
|
||||||
|
ToolTip = toolTip ?? showText,
|
||||||
|
Text = showText,
|
||||||
|
IsCheckable = true,
|
||||||
|
CommandHandler = command,
|
||||||
|
CommandParameter = parameter,
|
||||||
|
//Orientation = System.Windows.Controls.Orientation.Vertical
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 创建ToggleButton
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="showText"></param>
|
||||||
|
/// <param name="largeImage"></param>
|
||||||
|
/// <param name="toolTip"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static adWin.RibbonToggleButton NewAwToggleButton(string showText, Bitmap largeImage, string toolTip = null)
|
||||||
|
{
|
||||||
|
return new adWin.RibbonToggleButton()
|
||||||
|
{
|
||||||
|
LargeImage = largeImage?.ToBitmapSource(),
|
||||||
|
Size = adWin.RibbonItemSize.Large,
|
||||||
|
ToolTip = toolTip ?? showText,
|
||||||
|
ShowText = true,
|
||||||
|
Id = $"ID_{showText}",
|
||||||
|
Name = $"Tog_{showText}",
|
||||||
|
Text = showText,
|
||||||
|
IsCheckable = true,
|
||||||
|
Orientation = System.Windows.Controls.Orientation.Vertical,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Revit默认打开文件对话框
|
/// Revit默认打开文件对话框
|
||||||
@@ -332,24 +395,66 @@ public static class UIAssist
|
|||||||
|
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 设置按钮可用性
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="pushButtonData"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static PushButtonData SetAvailability<T>(this PushButtonData pushButtonData)
|
public static PushButtonData SetAvailability<T>(this PushButtonData pushButtonData)
|
||||||
where T : IExternalCommandAvailability
|
where T : IExternalCommandAvailability
|
||||||
{
|
{
|
||||||
pushButtonData.AvailabilityClassName = typeof(T).FullName;
|
pushButtonData.AvailabilityClassName = typeof(T).FullName;
|
||||||
return pushButtonData;
|
return pushButtonData;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 设置面板右下角箭头对话框
|
||||||
|
/// </summary>
|
||||||
|
public static void SetAwDialogLauncher(this adWin.RibbonPanel panel, adWin.RibbonCommandItem item)
|
||||||
|
{
|
||||||
|
if (panel != null)
|
||||||
|
{
|
||||||
|
panel.Source.DialogLauncher = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static adWin.RibbonItem SetAwImage(this adWin.RibbonItem ribbonItem, Bitmap image)
|
||||||
|
{
|
||||||
|
ribbonItem.Image = image.ToBitmapSource();
|
||||||
|
return ribbonItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetAwImage(this adWin.RibbonItem ribbonItem, string uri)
|
||||||
|
{
|
||||||
|
ribbonItem.Image = new BitmapImage(new Uri(uri, UriKind.RelativeOrAbsolute));
|
||||||
|
}
|
||||||
|
public static adWin.RibbonItem SetAwLargeImage(this adWin.RibbonItem ribbonItem, Bitmap largeImage)
|
||||||
|
{
|
||||||
|
ribbonItem.LargeImage = largeImage.ToBitmapSource();
|
||||||
|
return ribbonItem;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 指定决定按钮可用性的类别
|
/// 从 URI 源添加 32x32px-96dpi 图像
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="button">功能区中将受限制的按钮</param>
|
/// <param name="button">添加图标的按钮</param>
|
||||||
/// <typeparam name="T">类型继承 <see cref="Autodesk.Revit.UI.IExternalCommandAvailability"/></typeparam>
|
/// <param name="uri">图标的相对或绝对路径</param>
|
||||||
/// <remarks>T 类应与插件 "外部命令 "共享同一程序集</remarks>
|
/// <example>button.SetAwLargeImage("/RevitAddIn;component/Resources/Icons/RibbonIcon32.png")</example>
|
||||||
public static void SetAvailabilityController<T>(this PushButton button)
|
public static void SetAwLargeImage(this adWin.RibbonItem ribbonItem, string uri)
|
||||||
where T : IExternalCommandAvailability, new()
|
|
||||||
{
|
{
|
||||||
button.AvailabilityClassName = typeof(T).FullName;
|
ribbonItem.LargeImage = new BitmapImage(new Uri(uri, UriKind.RelativeOrAbsolute));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static adWin.RibbonItem SetAwShowText(this adWin.RibbonItem ribbonItem, string text)
|
||||||
|
{
|
||||||
|
ribbonItem.Text = text;
|
||||||
|
return ribbonItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static adWin.RibbonItem SetAwToolTip(this adWin.RibbonItem ribbonItem, string tooltip)
|
||||||
|
{
|
||||||
|
ribbonItem.ToolTip = tooltip;
|
||||||
|
return ribbonItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PushButtonData SetDescription(this PushButtonData pushButtonData, string longDescription)
|
public static PushButtonData SetDescription(this PushButtonData pushButtonData, string longDescription)
|
||||||
@@ -357,31 +462,26 @@ public static class UIAssist
|
|||||||
pushButtonData.LongDescription = longDescription;
|
pushButtonData.LongDescription = longDescription;
|
||||||
return pushButtonData;
|
return pushButtonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 右下角箭头对话框
|
/// 设置面板右下角箭头对话框
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void SetDialogLauncher(string panelName)
|
public static void SetDialogLauncher(string tabName, string panelName)
|
||||||
{
|
{
|
||||||
var group = adWin.ComponentManager.Ribbon.Tabs
|
var group = adWin.ComponentManager.Ribbon.Tabs
|
||||||
.First()
|
.FirstOrDefault(tab => tab.Name == tabName)
|
||||||
.Panels.FirstOrDefault(p => p.AutomationName == panelName);
|
.Panels.FirstOrDefault(p => p.AutomationName == panelName) ?? throw new ArgumentException("未找到标签或面板");
|
||||||
if (group != null)
|
|
||||||
{
|
|
||||||
group.Source.DialogLauncher = group.Source.Items.First() as adWin.RibbonCommandItem;
|
group.Source.DialogLauncher = group.Source.Items.First() as adWin.RibbonCommandItem;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 设置面板右下角箭头对话框
|
||||||
|
/// </summary>
|
||||||
|
public static void SetDialogLauncher(adWin.RibbonTab tab, string panelName)
|
||||||
|
{
|
||||||
|
var group = tab.Panels.FirstOrDefault(p => p.AutomationName == panelName) ?? throw new ArgumentException("未找到标签或面板");
|
||||||
|
|
||||||
|
group.Source.DialogLauncher = group.Source.Items.First() as adWin.RibbonCommandItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 右下角箭头对话框
|
|
||||||
/// </summary>
|
|
||||||
public static void SetDialogLauncher(this adWin.RibbonPanel panel, adWin.RibbonCommandItem item)
|
|
||||||
{
|
|
||||||
if (panel != null)
|
|
||||||
{
|
|
||||||
panel.Source.DialogLauncher = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 双击选项
|
/// 双击选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -392,14 +492,17 @@ public static class UIAssist
|
|||||||
doubleOpt.SetAction(target, clickAction);
|
doubleOpt.SetAction(target, clickAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 提示包含短视频
|
/// 提示包含短视频
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pushButtonData"></param>
|
/// <param name="pushButtonData"></param>
|
||||||
/// <param name="title"></param>
|
/// <param name="title"></param>
|
||||||
/// <param name="videoPath"></param>
|
/// <param name="videoPath">视频路径</param>
|
||||||
public static void SetExpandedVideo(this PushButtonData pushButtonData, string title, string videoPath)
|
public static void SetExpandedVideo(this PushButtonData pushButtonData, string title, string videoPath)
|
||||||
{
|
{
|
||||||
|
//拿到Autodesk.Windows的RibbonItem(转换)
|
||||||
var internalGetRibbonItemMethod = typeof(RibbonItem).GetMethod(
|
var internalGetRibbonItemMethod = typeof(RibbonItem).GetMethod(
|
||||||
"getRibbonItem",
|
"getRibbonItem",
|
||||||
BindingFlags.NonPublic | BindingFlags.Instance
|
BindingFlags.NonPublic | BindingFlags.Instance
|
||||||
@@ -410,17 +513,31 @@ public static class UIAssist
|
|||||||
button.ToolTip = new adWin.RibbonToolTip { Title = title, ExpandedVideo = new Uri(videoPath) };
|
button.ToolTip = new adWin.RibbonToolTip { Title = title, ExpandedVideo = new Uri(videoPath) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 设置16x16的小图片
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pushButtonData"></param>
|
||||||
|
/// <param name="image"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static PushButtonData SetImage(this PushButtonData pushButtonData, Bitmap image)
|
public static PushButtonData SetImage(this PushButtonData pushButtonData, Bitmap image)
|
||||||
{
|
{
|
||||||
pushButtonData.Image = ToBitmapSource(image);
|
pushButtonData.Image = image.ToBitmapSource();
|
||||||
|
return pushButtonData;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 使用Uri设置16x16的小图片
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pushButtonData"></param>
|
||||||
|
/// <param name="uri"></param>
|
||||||
|
public static PushButtonData SetImage(this PushButtonData pushButtonData, string uri)
|
||||||
|
{
|
||||||
|
pushButtonData.Image = new BitmapImage(new Uri(uri, UriKind.RelativeOrAbsolute));
|
||||||
return pushButtonData;
|
return pushButtonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetImage(this RibbonButton button, string uri)
|
|
||||||
{
|
|
||||||
button.Image = new BitmapImage(new Uri(uri, UriKind.RelativeOrAbsolute));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 消息中心
|
/// 消息中心
|
||||||
@@ -441,23 +558,30 @@ public static class UIAssist
|
|||||||
}; // 当鼠标点击气泡内容时触发此事件
|
}; // 当鼠标点击气泡内容时触发此事件
|
||||||
paletteMgr.ShowBalloon(resultItem);
|
paletteMgr.ShowBalloon(resultItem);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 设置32x32-96dpi的大图片
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pushButtonData"></param>
|
||||||
|
/// <param name="largeImage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static PushButtonData SetLargeImage(this PushButtonData pushButtonData, Bitmap largeImage)
|
public static PushButtonData SetLargeImage(this PushButtonData pushButtonData, Bitmap largeImage)
|
||||||
{
|
{
|
||||||
pushButtonData.LargeImage = ToBitmapSource(largeImage);
|
pushButtonData.LargeImage = largeImage.ToBitmapSource();
|
||||||
return pushButtonData;
|
return pushButtonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a 32x32px-96dpi image from the URI source
|
/// 从 URI 源添加 32x32px-96dpi 图像
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="button">Button to which the icon will be added</param>
|
/// <param name="pushButtonData">添加图标的按钮</param>
|
||||||
/// <param name="uri">Relative or Absolute path to the icon</param>
|
/// <param name="uri">图标的相对或绝对路径</param>
|
||||||
/// <example>button.SetLargeImage("/RevitAddIn;component/Resources/Icons/RibbonIcon32.png")</example>
|
/// <example>button.SetAwLargeImage("/RevitAddIn;component/Resources/Icons/RibbonIcon32.png")</example>
|
||||||
public static void SetLargeImage(this RibbonButton button, string uri)
|
public static void SetLargeImage(this PushButtonData pushButtonData, string uri)
|
||||||
{
|
{
|
||||||
button.LargeImage = new BitmapImage(new Uri(uri, UriKind.RelativeOrAbsolute));
|
pushButtonData.LargeImage = new BitmapImage(new Uri(uri, UriKind.RelativeOrAbsolute));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 状态栏
|
/// 状态栏
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -478,84 +602,36 @@ public static class UIAssist
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 基于Revit封装的RibbonButton设置其快捷键.
|
/// 设置显示文字
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="btn">RibbonButton.</param>
|
/// <param name="pushButtonData"></param>
|
||||||
/// <param name="key">快捷键字符串.</param>
|
/// <param name="text"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool SetShortCut(this Autodesk.Revit.UI.RibbonButton btn, string key)
|
|
||||||
{
|
|
||||||
if (btn == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var item = btn.GetType()
|
|
||||||
.InvokeMember(
|
|
||||||
"getRibbonItem",
|
|
||||||
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod,
|
|
||||||
Type.DefaultBinder,
|
|
||||||
btn,
|
|
||||||
null
|
|
||||||
);
|
|
||||||
|
|
||||||
return item != null && (item as Autodesk.Windows.RibbonItem).SetShortCut(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 基于通用库封装的RibbonCommandItem设置其快捷键.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="commandItem">RibbonCommandItem.</param>
|
|
||||||
/// <param name="key">快捷键字符串.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static bool SetShortCut(this Autodesk.Windows.RibbonItem commandItem, string key)
|
|
||||||
{
|
|
||||||
if (commandItem == null || string.IsNullOrEmpty(key))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Autodesk.Windows.ComponentManager.Ribbon.FindItem(
|
|
||||||
commandItem.Id,
|
|
||||||
false,
|
|
||||||
out var parentPanel,
|
|
||||||
out var parentTab,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
if (parentTab == null || parentPanel == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var path = string.Format("{0}>{1}", parentTab.Id, parentPanel.Source.Id);
|
|
||||||
var cmdId = ControlHelper.GetCommandId(commandItem);
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(cmdId))
|
|
||||||
{
|
|
||||||
cmdId = Guid.NewGuid().ToString();
|
|
||||||
ControlHelper.SetCommandId(commandItem, cmdId);
|
|
||||||
}
|
|
||||||
|
|
||||||
var shortcutItem = new ShortcutItem(commandItem.Text, cmdId, key, path)
|
|
||||||
{
|
|
||||||
ShortcutType = StType.RevitAPI
|
|
||||||
};
|
|
||||||
UIFrameworkServices.KeyboardShortcutService.applyShortcutChanges(
|
|
||||||
new Dictionary<string, ShortcutItem>() { { cmdId, shortcutItem } }
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PushButtonData SetShowText(this PushButtonData pushButtonData, string text)
|
public static PushButtonData SetShowText(this PushButtonData pushButtonData, string text)
|
||||||
{
|
{
|
||||||
pushButtonData.Text = text;
|
pushButtonData.Text = text;
|
||||||
return pushButtonData;
|
return pushButtonData;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 设置工具提示
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pushButtonData"></param>
|
||||||
|
/// <param name="tooltip"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static PushButtonData SetToolTip(this PushButtonData pushButtonData, string tooltip)
|
public static PushButtonData SetToolTip(this PushButtonData pushButtonData, string tooltip)
|
||||||
{
|
{
|
||||||
pushButtonData.ToolTip = tooltip;
|
pushButtonData.ToolTip = tooltip;
|
||||||
return pushButtonData;
|
return pushButtonData;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 设置工具提示图片
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pushButtonData"></param>
|
||||||
|
/// <param name="toolTipImage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static PushButtonData SetToolTipImage(this PushButtonData pushButtonData, Bitmap toolTipImage)
|
public static PushButtonData SetToolTipImage(this PushButtonData pushButtonData, Bitmap toolTipImage)
|
||||||
{
|
{
|
||||||
pushButtonData.ToolTipImage = ToBitmapSource(toolTipImage);
|
pushButtonData.ToolTipImage = toolTipImage.ToBitmapSource();
|
||||||
return pushButtonData;
|
return pushButtonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,15 +639,19 @@ public static class UIAssist
|
|||||||
/// 通过判断keyTip来区分原始Tab与插件Tab,然后切换插件Tab的可见性
|
/// 通过判断keyTip来区分原始Tab与插件Tab,然后切换插件Tab的可见性
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tabName"></param>
|
/// <param name="tabName"></param>
|
||||||
public static void SetVisible(string tabName)
|
/// <param name="visible"></param>
|
||||||
|
public static void SetVisible(string tabName, bool visible)
|
||||||
{
|
{
|
||||||
var ribbonControl = adWin.ComponentManager.Ribbon;
|
var ribbonControl = adWin.ComponentManager.Ribbon;
|
||||||
foreach (var tab in ribbonControl.Tabs)
|
var tab = ribbonControl.Tabs
|
||||||
|
.FirstOrDefault(
|
||||||
|
tab => !tab.IsContextualTab &&
|
||||||
|
!tab.IsMergedContextualTab &&
|
||||||
|
tab.KeyTip == null &&
|
||||||
|
tabName == tab.Name);
|
||||||
|
if (tab != null)
|
||||||
{
|
{
|
||||||
if (!tab.IsContextualTab && !tab.IsMergedContextualTab && tab.KeyTip == null && tabName == tab.Name)
|
tab.IsVisible = visible;
|
||||||
{
|
|
||||||
tab.IsVisible = !tab.IsVisible;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,23 +659,23 @@ public static class UIAssist
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新建命令按钮
|
/// 新建命令按钮
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="Command"></typeparam>
|
||||||
/// <param name="text"></param>
|
/// <param name="text"></param>
|
||||||
/// <param name="image"></param>
|
/// <param name="image"></param>
|
||||||
/// <param name="largeImage"></param>
|
/// <param name="largeImage"></param>
|
||||||
/// <param name="toolTip"></param>
|
/// <param name="toolTip"></param>
|
||||||
/// <param name="longDescription"></param>
|
/// <param name="longDescription"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static PushButtonData NewButtonData<T>(
|
public static PushButtonData NewPushButtonData<Command>(
|
||||||
string text,
|
string text,
|
||||||
Bitmap largeImage = null,
|
Bitmap largeImage = null,
|
||||||
Bitmap image = null,
|
Bitmap image = null,
|
||||||
string toolTip = null,
|
string toolTip = null,
|
||||||
string longDescription = null
|
string longDescription = null
|
||||||
)
|
)
|
||||||
where T : class, IExternalCommand
|
where Command : class, IExternalCommand
|
||||||
{
|
{
|
||||||
return new(typeof(T).FullName, text, AddInPath, typeof(T).FullName)
|
return new(typeof(Command).FullName, text, AddInPath, typeof(Command).FullName)
|
||||||
{
|
{
|
||||||
LargeImage = largeImage?.ToBitmapSource(),
|
LargeImage = largeImage?.ToBitmapSource(),
|
||||||
Image = image?.ToBitmapSource(),
|
Image = image?.ToBitmapSource(),
|
||||||
@@ -607,32 +687,33 @@ public static class UIAssist
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新建可控的命令按钮
|
/// 新建可控的命令按钮
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="Command"></typeparam>
|
||||||
/// <typeparam name="V"></typeparam>
|
/// <typeparam name="Availablility"></typeparam>
|
||||||
/// <param name="text"></param>
|
/// <param name="text"></param>
|
||||||
/// <param name="bitmap"></param>
|
/// <param name="bitmap"></param>
|
||||||
/// <param name="largeBitmap"></param>
|
/// <param name="largeBitmap"></param>
|
||||||
/// <param name="toolTip"></param>
|
/// <param name="toolTip"></param>
|
||||||
/// <param name="longDescription"></param>
|
/// <param name="longDescription"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static PushButtonData NewButtonData<T, V>(
|
public static PushButtonData NewButtonData<Command, Availablility>(
|
||||||
string text,
|
string text,
|
||||||
Bitmap largeBitmap = null,
|
Bitmap largeBitmap = null,
|
||||||
Bitmap bitmap = null,
|
Bitmap bitmap = null,
|
||||||
string toolTip = null,
|
string toolTip = null,
|
||||||
string longDescription = null
|
string longDescription = null
|
||||||
)
|
)
|
||||||
where T : class, IExternalCommand
|
where Command : class, IExternalCommand
|
||||||
where V : class, IExternalCommandAvailability
|
where Availablility : class, IExternalCommandAvailability
|
||||||
{
|
{
|
||||||
return new(typeof(T).FullName, text, AddInPath, typeof(T).FullName)
|
return new(typeof(Command).FullName, text, AddInPath, typeof(Command).FullName)
|
||||||
{
|
{
|
||||||
LargeImage = largeBitmap?.ToBitmapSource(),
|
LargeImage = largeBitmap?.ToBitmapSource(),
|
||||||
Image = bitmap?.ToBitmapSource(),
|
Image = bitmap?.ToBitmapSource(),
|
||||||
ToolTip = toolTip ?? text,
|
ToolTip = toolTip ?? text,
|
||||||
LongDescription = longDescription,
|
LongDescription = longDescription,
|
||||||
AvailabilityClassName = typeof(V).FullName
|
AvailabilityClassName = typeof(Availablility).FullName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Autodesk.Revit.UI;
|
|||||||
|
|
||||||
|
|
||||||
using UIFramework;
|
using UIFramework;
|
||||||
|
|
||||||
using UIFrameworkServices;
|
using UIFrameworkServices;
|
||||||
|
|
||||||
namespace Sai.Toolkit.Revit.Helpers
|
namespace Sai.Toolkit.Revit.Helpers
|
||||||
@@ -77,6 +78,70 @@ namespace Sai.Toolkit.Revit.Helpers
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#region 组合使用
|
||||||
|
/// 基于Revit封装的RibbonButton设置其快捷键.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="btn">RibbonButton.</param>
|
||||||
|
/// <param name="key">快捷键字符串.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool SetShortCut(Autodesk.Revit.UI.RibbonButton btn, string key)
|
||||||
|
{
|
||||||
|
if (btn == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var item = btn.GetType()
|
||||||
|
.InvokeMember(
|
||||||
|
"getRibbonItem",
|
||||||
|
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod,
|
||||||
|
Type.DefaultBinder,
|
||||||
|
btn,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
return item != null && (item is Autodesk.Windows.RibbonItem ribbonItem) && SetAdShortCut(ribbonItem, key);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 基于通用库封装的RibbonCommandItem设置其快捷键.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="commandItem">RibbonCommandItem.</param>
|
||||||
|
/// <param name="key">快捷键字符串.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static bool SetAdShortCut(Autodesk.Windows.RibbonItem commandItem, string key)
|
||||||
|
{
|
||||||
|
if (commandItem == null || string.IsNullOrEmpty(key))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Autodesk.Windows.ComponentManager.Ribbon.FindItem(
|
||||||
|
commandItem.Id,
|
||||||
|
false,
|
||||||
|
out var parentPanel,
|
||||||
|
out var parentTab,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
if (parentTab == null || parentPanel == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var path = string.Format("{0}>{1}", parentTab.Id, parentPanel.Source.Id);
|
||||||
|
var cmdId = ControlHelper.GetCommandId(commandItem);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(cmdId))
|
||||||
|
{
|
||||||
|
cmdId = Guid.NewGuid().ToString();
|
||||||
|
ControlHelper.SetCommandId(commandItem, cmdId);
|
||||||
|
}
|
||||||
|
|
||||||
|
var shortcutItem = new ShortcutItem(commandItem.Text, cmdId, key, path)
|
||||||
|
{
|
||||||
|
ShortcutType = StType.RevitAPI
|
||||||
|
};
|
||||||
|
UIFrameworkServices.KeyboardShortcutService.applyShortcutChanges(
|
||||||
|
new Dictionary<string, ShortcutItem>() { { cmdId, shortcutItem } }
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 移除菜单快捷键
|
/// 移除菜单快捷键
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\DocumentAssist.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Assist\DocumentAssist.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\HostObjectAssist.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Assist\HostObjectAssist.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\ApplicationAssist.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Assist\ApplicationAssist.cs" />
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)Assist\JIGAssist.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\KeyboardShortcutExtension.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Assist\KeyboardShortcutExtension.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\DuplicateTypeNamesHandler.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Helpers\DuplicateTypeNamesHandler.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\ElementAssist.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Assist\ElementAssist.cs" />
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
|
|
||||||
namespace Wpf.Ui.Extend.Models;
|
namespace Wpf.Ui.Extend.Models;
|
||||||
|
|
||||||
|
|
||||||
public partial class TreeModel : ObservableObject, IComparable
|
public partial class TreeModel : INotifyPropertyChanged, IComparable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构造
|
/// 构造
|
||||||
@@ -16,22 +16,30 @@ public partial class TreeModel : ObservableObject, IComparable
|
|||||||
public TreeModel()
|
public TreeModel()
|
||||||
{
|
{
|
||||||
Children = new ObservableCollection<TreeModel>();
|
Children = new ObservableCollection<TreeModel>();
|
||||||
isChecked = false;
|
IsChecked = false;
|
||||||
Icon = "./Resources/File_16px.png";
|
//Icon = "./Resources/File_16px.png";
|
||||||
//TitleIcon = FamilyPlugins.Properties.Resources.Folder_32px;
|
//TitleIcon = FamilyPlugins.Properties.Resources.Folder_32px;
|
||||||
IsExpanded = false;
|
IsExpanded = false;
|
||||||
}
|
}
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
protected void SetProperty<T>(ref T prop, T value, [CallerMemberName] string propertyName = null)
|
||||||
|
{
|
||||||
|
if (EqualityComparer<T>.Default.Equals(prop, value) == false)
|
||||||
|
{
|
||||||
|
prop = value;
|
||||||
|
OnPropertyChanged(propertyName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnPropertyChanged(string propertyName)
|
||||||
|
{
|
||||||
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 选中状态
|
|
||||||
/// </summary>
|
|
||||||
[ObservableProperty]
|
|
||||||
private bool? isChecked;
|
private bool? isChecked;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 折叠状态
|
|
||||||
/// </summary>
|
|
||||||
[ObservableProperty]
|
|
||||||
private bool isExpanded;
|
private bool isExpanded;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -72,6 +80,22 @@ public partial class TreeModel : ObservableObject, IComparable
|
|||||||
/// 父项
|
/// 父项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TreeModel Parent { get; set; }
|
public TreeModel Parent { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 选中状态
|
||||||
|
/// </summary>
|
||||||
|
public bool? IsChecked
|
||||||
|
{
|
||||||
|
get => isChecked;
|
||||||
|
set => SetProperty(ref isChecked, value);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 折叠状态
|
||||||
|
/// </summary>
|
||||||
|
public bool IsExpanded
|
||||||
|
{
|
||||||
|
get => isExpanded;
|
||||||
|
set => SetProperty(ref isExpanded, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 排序
|
/// 排序
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
<AppendRuntimeIdentifierToOutputPath>False</AppendRuntimeIdentifierToOutputPath>
|
<AppendRuntimeIdentifierToOutputPath>False</AppendRuntimeIdentifierToOutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
|
|
||||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||||
<PackageReference Include="System.Runtime" Version="4.3.1" />
|
<PackageReference Include="System.Runtime" Version="4.3.1" />
|
||||||
<PackageReference Include="WPF-UI" Version="4.0.0-rc.2" />
|
<PackageReference Include="WPF-UI" Version="4.0.0-rc.2" />
|
||||||
|
|||||||
Reference in New Issue
Block a user